def test_populate(self, fake_http): zone = Zone('unit.tests.', []) fake_http.get(f'{self.API_URL}/unit.tests/records/', json=self.api_record) fake_http.get(f'{self.API_URL}/', json=self.domain) fake_http.head(f'{self.API_URL}/unit.tests/records/', headers={'X-Total-Count': str(len(self.api_record))}) fake_http.head(f'{self.API_URL}/', headers={'X-Total-Count': str(len(self.domain))}) provider = SelectelProvider(123, 'secret_token') provider.populate(zone) self.assertEquals(self.expected, zone.records)
def test_populate_invalid_record(self, fake_http): more_record = self.api_record more_record.append({ "name": "unit.tests", "id": 100001, "content": "support.unit.tests.", "ttl": 300, "ns": "ns1.unit.tests", "type": "SOA", "email": "*****@*****.**" }) zone = Zone('unit.tests.', []) fake_http.get('{}/unit.tests/records/'.format(self.API_URL), json=more_record) fake_http.get('{}/'.format(self.API_URL), json=self.domain) fake_http.head('{}/unit.tests/records/'.format(self.API_URL), headers={'X-Total-Count': str(len(self.api_record))}) fake_http.head('{}/'.format(self.API_URL), headers={'X-Total-Count': str(len(self.domain))}) zone.add_record( Record.new( self.zone, 'unsup', { 'ttl': 200, 'type': 'NAPTR', 'value': { 'order': 40, 'preference': 70, 'flags': 'U', 'service': 'SIP+D2U', 'regexp': '!^.*$!sip:[email protected]!', 'replacement': '.', } })) provider = SelectelProvider(123, 'secret_token') provider.populate(zone) self.assertNotEqual(self.expected, zone.records)