def test_array_to_zone_with_data(self): data = """sprout 300 IN A 10.0.5.1 sprout 300 IN NAPTR 1 1 "S" "SIP+D2T" "" _sip._tcp.sprout _sip._tcp.sprout 300 IN SRV 0 0 5054 sprout-0 sprout-0 300 IN A 10.0.5.1""".split('\n') zp = ZoneParser('orangebox.com') zp.array_to_zone(data) cont = zp.zone.contents self.assertEqual(cont['A'], [{'alias': 'sprout', 'addr': '10.0.5.1', 'ttl': '300'}, {'alias': 'sprout-0', 'addr': '10.0.5.1', 'ttl': '300'}]) self.assertEqual(cont['NAPTR'], [{'alias': 'sprout', 'order': '1', 'pref': '1', 'params': '"SIP+D2T"', 'regexp': '""', 'flag': '"S"', 'replace': '_sip._tcp.sprout', 'ttl': '300'}]) self.assertEqual(cont['SRV'], [{'alias': '_sip._tcp.sprout', 'port': '5054', 'ttl': '300', 'priority': '0', 'target': 'sprout-0', 'weight': '0'}])
def test_array_to_zone_with_data(self): data = """sprout 300 IN A 10.0.5.1 sprout 300 IN NAPTR 1 1 "S" "SIP+D2T" "" _sip._tcp.sprout _sip._tcp.sprout 300 IN SRV 0 0 5054 sprout-0 sprout-0 300 IN A 10.0.5.1""".split('\n') zp = ZoneParser('orangebox.com') zp.array_to_zone(data) cont = zp.zone.contents self.assertEqual(cont['A'], [{ 'alias': 'sprout', 'addr': '10.0.5.1', 'ttl': '300' }, { 'alias': 'sprout-0', 'addr': '10.0.5.1', 'ttl': '300' }]) self.assertEqual(cont['NAPTR'], [{ 'alias': 'sprout', 'order': '1', 'pref': '1', 'params': '"SIP+D2T"', 'regexp': '""', 'flag': '"S"', 'replace': '_sip._tcp.sprout', 'ttl': '300' }]) self.assertEqual(cont['SRV'], [{ 'alias': '_sip._tcp.sprout', 'port': '5054', 'ttl': '300', 'priority': '0', 'target': 'sprout-0', 'weight': '0' }])
def test_array_to_zone(self, soam, nsm, am): zp = ZoneParser('orangebox.com') zp.contents = self.ez zp.array_to_zone() soam.assert_called_with(self.ez[5].split()) nsm.assert_called_with(self.ez[6].split()) am.assert_called_with(self.ez[7].split())