Archived
35 lines
1012 B
Python
35 lines
1012 B
Python
from karldns.store.records import RecordUpdateInput, UpdateEventInput, _planned_record_update
|
|||
|
|
|
||
|
|
|
||
|
|
def test_planned_record_update_preserves_disabled_ip_versions() -> None:
|
||
|
|
plan = _planned_record_update(
|
||
|
|
RecordUpdateInput(
|
||
|
|
hostname="home.example.net",
|
||
|
|
ipv4="203.0.113.10",
|
||
|
|
ipv6=None,
|
||
|
|
update_ipv4=True,
|
||
|
|
update_ipv6=False,
|
||
|
|
),
|
||
|
|
current_ipv4="198.51.100.4",
|
||
|
|
current_ipv6="2001:db8::4",
|
||
|
|
existing=True,
|
||
|
|
)
|
||
|
|
|
||
|
|
assert plan.ipv4 == "203.0.113.10"
|
||
|
|
assert plan.ipv6 == "2001:db8::4"
|
||
|
|
assert plan.changed is True
|
||
|
|
|
||
|
|
|
||
|
|
def test_update_event_input_preserves_event_fields() -> None:
|
||
|
|
event = UpdateEventInput(
|
||
|
|
hostname="home.example.net",
|
||
|
|
ipv4="203.0.113.10",
|
||
|
|
ipv6=None,
|
||
|
|
status="updated",
|
||
|
|
detail="ok",
|
||
|
|
source_ip="198.51.100.1",
|
||
|
|
)
|
||
|
|
|
||
|
|
assert event.hostname == "home.example.net"
|
||
|
|
assert event.ipv4 == "203.0.113.10"
|
||
|
|
assert event.source_ip == "198.51.100.1"
|