#!/usr/bin/env python3 import re from updater import ( diff_zones, RECORD_LINE_PATTERN, ) def test_record_pattern(): assert re.match(RECORD_LINE_PATTERN, "foo 300 IN A 1.1.1.1") assert re.match(RECORD_LINE_PATTERN, "foo\t 300\t IN \tA\t 1.1.1.1") AT_RECORD = { "comment": None, "rrset_name": "@", "rrset_ttl": 300, "rrset_type": "A", "rrset_values": ["67.166.27.157"], } A_RECORD = { "comment": None, "rrset_name": "www", "rrset_ttl": 300, "rrset_type": "A", "rrset_values": ["67.166.27.157"], } REGISTRY_RECORD = { "comment": None, "rrset_name": "registry", "rrset_ttl": 300, "rrset_type": "A", "rrset_values": ["67.166.27.157"], } MIRROR_RECORD = { "comment": None, "rrset_name": "mirror", "rrset_ttl": 300, "rrset_type": "A", "rrset_values": ["67.166.27.157"], } def test_diff_zones(): z1 = [AT_RECORD, A_RECORD] z2 = [] assert diff_zones(z1, z2) == (z1, []) z1 = [AT_RECORD, A_RECORD] z2 = [AT_RECORD] assert diff_zones(z1, z2) == ([A_RECORD], []) z1 = [AT_RECORD, A_RECORD] z2 = [A_RECORD] assert diff_zones(z1, z2) == ([AT_RECORD], []) z2 = [AT_RECORD, A_RECORD] z1 = [A_RECORD] assert diff_zones(z1, z2) == ([], [AT_RECORD])