-
Notifications
You must be signed in to change notification settings - Fork 140
Expand file tree
/
Copy pathtest_url_utils.py
More file actions
36 lines (27 loc) · 1.49 KB
/
test_url_utils.py
File metadata and controls
36 lines (27 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""Tests for URL utility functions."""
import pytest
from databricks.sql.common.url_utils import normalize_host_with_protocol
class TestNormalizeHostWithProtocol:
"""Tests for normalize_host_with_protocol function."""
@pytest.mark.parametrize("input_host,expected_output", [
# Hostname without protocol - should add https://
("myserver.com", "https://myserver.com"),
("workspace.databricks.com", "https://workspace.databricks.com"),
# Hostname with https:// - should not duplicate
("https://myserver.com", "https://myserver.com"),
("https://workspace.databricks.com", "https://workspace.databricks.com"),
# Hostname with http:// - should preserve
("http://localhost", "http://localhost"),
("http://myserver.com:8080", "http://myserver.com:8080"),
# Hostname with port numbers
("myserver.com:443", "https://myserver.com:443"),
("https://myserver.com:443", "https://myserver.com:443"),
("http://localhost:8080", "http://localhost:8080"),
# Trailing slash - should be removed
("myserver.com/", "https://myserver.com"),
("https://myserver.com/", "https://myserver.com"),
("http://localhost/", "http://localhost"),
])
def test_normalize_host_with_protocol(self, input_host, expected_output):
"""Test host normalization with various input formats."""
assert normalize_host_with_protocol(input_host) == expected_output