Archived
Refactor UI assets and harden quality checks
This commit is contained in:
1 parent
23ab466c52
commit
4ecc8eb874
62 files changed
+3314
-3206
No files matched your search
@@ -0,0 +1,57 @@
|
||||
import pytest
|
||||
|
||||
from karldns.services.ddns import (
|
||||
INITIAL_PLACEHOLDER_IPV4,
|
||||
BadIpError,
|
||||
UpdateIpParams,
|
||||
_initial_dns_plan,
|
||||
_required_ip_param,
|
||||
)
|
||||
|
||||
|
||||
def test_update_ip_params_expose_initial_plan_arguments() -> None:
|
||||
params = UpdateIpParams(myip="203.0.113.9", ipaddr=None, myipv6="2001:db8::9", ip6addr=None)
|
||||
|
||||
assert params.initial_plan_args == ("203.0.113.9", None, "2001:db8::9", None)
|
||||
|
||||
|
||||
def test_required_ip_param_rejects_invalid_or_wrong_version_values() -> None:
|
||||
assert _required_ip_param("myip", "203.0.113.77", version=4) == "203.0.113.77"
|
||||
|
||||
with pytest.raises(BadIpError, match="valid IPv4"):
|
||||
_required_ip_param("myip", "not-an-ip", version=4)
|
||||
|
||||
with pytest.raises(BadIpError, match="IPv4"):
|
||||
_required_ip_param("myip", "2001:db8::1", version=4)
|
||||
|
||||
|
||||
def test_initial_dns_plan_uses_placeholder_without_supplied_or_public_source_ip() -> None:
|
||||
plan = _initial_dns_plan(
|
||||
source_ip="172.18.0.5",
|
||||
myip=None,
|
||||
ipaddr=None,
|
||||
myipv6=None,
|
||||
ip6addr=None,
|
||||
)
|
||||
|
||||
assert plan.ipv4 == INITIAL_PLACEHOLDER_IPV4
|
||||
assert plan.ipv6 is None
|
||||
assert plan.update_ipv4 is True
|
||||
assert plan.update_ipv6 is False
|
||||
assert plan.detail == "initial placeholder dns registered"
|
||||
|
||||
|
||||
def test_initial_dns_plan_uses_supplied_ip_values() -> None:
|
||||
plan = _initial_dns_plan(
|
||||
source_ip="172.18.0.5",
|
||||
myip="203.0.113.77",
|
||||
ipaddr=None,
|
||||
myipv6=None,
|
||||
ip6addr=None,
|
||||
)
|
||||
|
||||
assert plan.ipv4 == "203.0.113.77"
|
||||
assert plan.ipv6 is None
|
||||
assert plan.update_ipv4 is True
|
||||
assert plan.update_ipv6 is False
|
||||
assert plan.detail == "initial dns registered"
|
||||
Reference in new issue
Block a user