feat(firmware): Trailer, Versionsordnung, WLAN-Pruefung und Firmware-Katalog
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
"""Validation of the address lamps use to reach Home Assistant."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from custom_components.ninlight.urls import firmware_url, validate_lamp_base_url
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"url", ["http://192.168.1.50:8123", "http://ha.local:8123/", "http://192.168.1.50"]
|
||||
)
|
||||
def test_valid_base_urls(url: str) -> None:
|
||||
assert validate_lamp_base_url(url) is None
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"url",
|
||||
[
|
||||
"https://192.168.1.50:8123",
|
||||
"http://",
|
||||
"ftp://ha.local",
|
||||
"http://user:pass@ha.local:8123",
|
||||
"http://ha.local:8123/ha",
|
||||
"http://ha.local:8123?x=1",
|
||||
"http://ha.local:8123#frag",
|
||||
"http://ha.local:99999",
|
||||
"192.168.1.50:8123",
|
||||
],
|
||||
)
|
||||
def test_invalid_base_urls(url: str) -> None:
|
||||
assert validate_lamp_base_url(url) == "invalid_base_url"
|
||||
|
||||
|
||||
def test_length_boundary_is_the_lamps_255_characters() -> None:
|
||||
longest_ok = "http://" + "a" * 182
|
||||
assert len(firmware_url(longest_ok, "k" * 43)) == 255
|
||||
assert validate_lamp_base_url(longest_ok) is None
|
||||
assert validate_lamp_base_url(longest_ok + "a") == "base_url_too_long"
|
||||
|
||||
|
||||
def test_firmware_url_joins_without_double_slash() -> None:
|
||||
assert (
|
||||
firmware_url("http://ha.local:8123/", "abc")
|
||||
== "http://ha.local:8123/api/ninlight/firmware/abc"
|
||||
)
|
||||
Reference in New Issue
Block a user