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,46 @@
|
||||
from karldns.routers.management import _activation_ip_params_from_query
|
||||
from karldns.services.ddns import UpdateIpParams
|
||||
from karldns.web.templates_management import ManagementPageContext, _management_page_view, _user_event_row_view
|
||||
|
||||
|
||||
def test_management_page_context_builds_account_for_secret_urls() -> None:
|
||||
context = ManagementPageContext(
|
||||
management_slug="manage-secret",
|
||||
account={"hostname": "home.example.net", "update_slug": "update-secret"},
|
||||
csrf_token="csrf",
|
||||
)
|
||||
|
||||
assert context.account_for_url == {
|
||||
"hostname": "home.example.net",
|
||||
"update_slug": "update-secret",
|
||||
"management_slug": "manage-secret",
|
||||
}
|
||||
|
||||
|
||||
def test_management_page_view_escapes_missing_status_values() -> None:
|
||||
context = ManagementPageContext(
|
||||
management_slug="manage-secret",
|
||||
account={"hostname": "home.example.net", "update_slug": "update-secret"},
|
||||
csrf_token="csrf",
|
||||
)
|
||||
|
||||
view = _management_page_view(update_url="https://example.test/update", context=context)
|
||||
|
||||
assert view.hostname == "home.example.net"
|
||||
assert view.ipv4 == "-"
|
||||
assert view.ipv6 == "-"
|
||||
assert view.updated == "Never"
|
||||
|
||||
|
||||
def test_activation_ip_params_from_query_builds_domain_params() -> None:
|
||||
assert _activation_ip_params_from_query(myip=None, ipaddr="203.0.113.8", myipv6=None, ip6addr=None) == (
|
||||
UpdateIpParams(ipaddr="203.0.113.8")
|
||||
)
|
||||
|
||||
|
||||
def test_user_event_row_normalizes_status_badge() -> None:
|
||||
row = _user_event_row_view({"status": "dns_failed", "detail": ""})
|
||||
|
||||
assert row.status == "DNS update failed"
|
||||
assert row.badge_class == "status-badge-error"
|
||||
assert row.detail == "-"
|
||||
Reference in new issue
Block a user