mirror of
https://github.com/home-assistant/core.git
synced 2026-03-02 07:29:28 +00:00
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
39 lines
1.4 KiB
Python
39 lines
1.4 KiB
Python
"""Test Teltonika utility helpers."""
|
|
|
|
from homeassistant.components.teltonika.util import get_url_variants, normalize_url
|
|
|
|
|
|
def test_normalize_url_adds_https_scheme() -> None:
|
|
"""Test normalize_url adds HTTPS scheme for bare hostnames."""
|
|
assert normalize_url("teltonika") == "https://teltonika"
|
|
|
|
|
|
def test_normalize_url_preserves_scheme() -> None:
|
|
"""Test normalize_url preserves explicitly provided scheme."""
|
|
assert normalize_url("http://teltonika") == "http://teltonika"
|
|
assert normalize_url("https://teltonika") == "https://teltonika"
|
|
|
|
|
|
def test_normalize_url_strips_path() -> None:
|
|
"""Test normalize_url removes any path component."""
|
|
assert normalize_url("https://teltonika/api") == "https://teltonika"
|
|
assert normalize_url("http://teltonika/other/path") == "http://teltonika"
|
|
|
|
|
|
def test_get_url_variants_with_https_scheme() -> None:
|
|
"""Test get_url_variants with explicit HTTPS scheme returns only HTTPS."""
|
|
assert get_url_variants("https://teltonika") == ["https://teltonika"]
|
|
|
|
|
|
def test_get_url_variants_with_http_scheme() -> None:
|
|
"""Test get_url_variants with explicit HTTP scheme returns only HTTP."""
|
|
assert get_url_variants("http://teltonika") == ["http://teltonika"]
|
|
|
|
|
|
def test_get_url_variants_without_scheme() -> None:
|
|
"""Test get_url_variants without scheme returns both HTTPS and HTTP."""
|
|
assert get_url_variants("teltonika") == [
|
|
"https://teltonika",
|
|
"http://teltonika",
|
|
]
|