From e3ec8b5edf5e8f2fdfba288555ddd8d1abf548a0 Mon Sep 17 00:00:00 2001 From: Peter Eckel Date: Sat, 21 Sep 2024 16:36:42 +0200 Subject: [PATCH] Added test for correct functionylity of the "Disable DNSsync" CF --- .../tests/ipam_dnssync/test_ipaddress.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/netbox_dns/tests/ipam_dnssync/test_ipaddress.py b/netbox_dns/tests/ipam_dnssync/test_ipaddress.py index 2da69e0e..32b3fbc5 100644 --- a/netbox_dns/tests/ipam_dnssync/test_ipaddress.py +++ b/netbox_dns/tests/ipam_dnssync/test_ipaddress.py @@ -623,6 +623,27 @@ def test_update_ip_address_name_missing_zone(self): self.assertFalse(Record.objects.filter(type=RecordTypeChoices.A).exists()) self.assertFalse(Record.objects.filter(type=RecordTypeChoices.AAAA).exists()) + def test_update_ip_address_disable_dnssync(self): + ipv4_address = IPAddress.objects.create( + address=IPNetwork("10.0.0.1/24"), dns_name="name1.zone1.example.com" + ) + ipv6_address = IPAddress.objects.create( + address=IPNetwork("fe80:dead:beef::1/64"), + dns_name="name2.zone1.example.com", + ) + + self.assertTrue(Record.objects.filter(ipam_ip_address=ipv4_address).exists()) + self.assertTrue(Record.objects.filter(ipam_ip_address=ipv6_address).exists()) + + ipv4_address.custom_field_data = {"ipaddress_dns_disabled": True} + ipv4_address.save() + + ipv6_address.custom_field_data = {"ipaddress_dns_disabled": True} + ipv6_address.save() + + self.assertFalse(Record.objects.filter(type=RecordTypeChoices.A).exists()) + self.assertFalse(Record.objects.filter(type=RecordTypeChoices.AAAA).exists()) + def test_update_ip_address_name_duplicate_record(self): records = ( Record(