mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
f-strings for tests pass 1
This commit is contained in:
@@ -616,7 +616,7 @@ class TestAzureDnsProvider(TestCase):
|
||||
'/resourceGroups/' + rg + \
|
||||
'/providers/Microsoft.Network/trafficManagerProfiles/'
|
||||
prefix = 'foo--unit--tests'
|
||||
name_format = prefix + '-{}'
|
||||
name_format = prefix + '-'
|
||||
id_format = base_id + name_format
|
||||
|
||||
header = MonitorConfigCustomHeadersItem(name='Host',
|
||||
@@ -628,8 +628,8 @@ class TestAzureDnsProvider(TestCase):
|
||||
|
||||
profiles = [
|
||||
Profile(
|
||||
id=id_format.format('pool-two'),
|
||||
name=name_format.format('pool-two'),
|
||||
id=f'{id_format}pool-two',
|
||||
name=f'{name_format}pool-two',
|
||||
traffic_routing_method='Weighted',
|
||||
dns_config=DnsConfig(ttl=60),
|
||||
monitor_config=monitor,
|
||||
@@ -649,8 +649,8 @@ class TestAzureDnsProvider(TestCase):
|
||||
],
|
||||
),
|
||||
Profile(
|
||||
id=id_format.format('rule-one'),
|
||||
name=name_format.format('rule-one'),
|
||||
id=f'{id_format}rule-one',
|
||||
name=f'{name_format}rule-one',
|
||||
traffic_routing_method='Priority',
|
||||
dns_config=DnsConfig(ttl=60),
|
||||
monitor_config=monitor,
|
||||
@@ -664,7 +664,7 @@ class TestAzureDnsProvider(TestCase):
|
||||
Endpoint(
|
||||
name='two',
|
||||
type=nested,
|
||||
target_resource_id=id_format.format('pool-two'),
|
||||
target_resource_id=f'{id_format}pool-two',
|
||||
priority=2,
|
||||
),
|
||||
Endpoint(
|
||||
@@ -682,8 +682,8 @@ class TestAzureDnsProvider(TestCase):
|
||||
],
|
||||
),
|
||||
Profile(
|
||||
id=id_format.format('rule-two'),
|
||||
name=name_format.format('rule-two'),
|
||||
id=f'{id_format}rule-two',
|
||||
name=f'{name_format}rule-two',
|
||||
traffic_routing_method='Priority',
|
||||
dns_config=DnsConfig(ttl=60),
|
||||
monitor_config=monitor,
|
||||
@@ -691,7 +691,7 @@ class TestAzureDnsProvider(TestCase):
|
||||
Endpoint(
|
||||
name='two',
|
||||
type=nested,
|
||||
target_resource_id=id_format.format('pool-two'),
|
||||
target_resource_id=f'{id_format}pool-two',
|
||||
priority=1,
|
||||
),
|
||||
Endpoint(
|
||||
@@ -719,13 +719,13 @@ class TestAzureDnsProvider(TestCase):
|
||||
geo_mapping=['GEO-AF', 'DE', 'US-CA', 'GEO-AP'],
|
||||
name='one',
|
||||
type=nested,
|
||||
target_resource_id=id_format.format('rule-one'),
|
||||
target_resource_id=f'{id_format}rule-one',
|
||||
),
|
||||
Endpoint(
|
||||
geo_mapping=['WORLD'],
|
||||
name='two',
|
||||
type=nested,
|
||||
target_resource_id=id_format.format('rule-two'),
|
||||
target_resource_id=f'{id_format}rule-two',
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -923,8 +923,8 @@ class TestAzureDnsProvider(TestCase):
|
||||
tm_id = provider._profile_name_to_id
|
||||
root_profile_name = _root_traffic_manager_name(record)
|
||||
extra_profile = Profile(
|
||||
id=tm_id('{}-pool-random'.format(root_profile_name)),
|
||||
name='{}-pool-random'.format(root_profile_name),
|
||||
id=tm_id(f'{root_profile_name}-pool-random'),
|
||||
name=f'{root_profile_name}-pool-random',
|
||||
traffic_routing_method='Weighted',
|
||||
dns_config=sample_profile.dns_config,
|
||||
monitor_config=sample_profile.monitor_config,
|
||||
@@ -1150,7 +1150,7 @@ class TestAzureDnsProvider(TestCase):
|
||||
target_resource=SubResource(id=profiles[-1].id),
|
||||
)
|
||||
azrecord.name = record.name or '@'
|
||||
azrecord.type = 'Microsoft.Network/dnszones/{}'.format(record._type)
|
||||
azrecord.type = f'Microsoft.Network/dnszones/{record._type}'
|
||||
record2 = provider._populate_record(zone, azrecord)
|
||||
self.assertEqual(record2.dynamic._data(), record.dynamic._data())
|
||||
|
||||
@@ -1191,7 +1191,7 @@ class TestAzureDnsProvider(TestCase):
|
||||
target_resource=SubResource(id=tm_id(tm_suffix)),
|
||||
)
|
||||
azrecord.name = record.name or '@'
|
||||
azrecord.type = 'Microsoft.Network/dnszones/{}'.format(record._type)
|
||||
azrecord.type = f'Microsoft.Network/dnszones/{record._type}'
|
||||
with self.assertRaises(AzureException) as ctx:
|
||||
provider._populate_record(zone, azrecord)
|
||||
self.assertTrue(text_type(ctx).startswith(
|
||||
@@ -1261,7 +1261,7 @@ class TestAzureDnsProvider(TestCase):
|
||||
target_resource=SubResource(id=profiles[-1].id),
|
||||
)
|
||||
azrecord.name = record.name or '@'
|
||||
azrecord.type = 'Microsoft.Network/dnszones/{}'.format(record._type)
|
||||
azrecord.type = f'Microsoft.Network/dnszones/{record._type}'
|
||||
record2 = provider._populate_record(zone, azrecord)
|
||||
self.assertEqual(record2.dynamic._data(), record.dynamic._data())
|
||||
|
||||
@@ -1320,7 +1320,7 @@ class TestAzureDnsProvider(TestCase):
|
||||
target_resource=SubResource(id=profiles[-1].id),
|
||||
)
|
||||
azrecord.name = record.name or '@'
|
||||
azrecord.type = 'Microsoft.Network/dnszones/{}'.format(record._type)
|
||||
azrecord.type = f'Microsoft.Network/dnszones/{record._type}'
|
||||
record2 = provider._populate_record(zone, azrecord)
|
||||
self.assertEqual(record2.dynamic._data(), record.dynamic._data())
|
||||
|
||||
@@ -1416,7 +1416,7 @@ class TestAzureDnsProvider(TestCase):
|
||||
target_resource=SubResource(id=profiles[-1].id),
|
||||
)
|
||||
azrecord.name = record.name or '@'
|
||||
azrecord.type = 'Microsoft.Network/dnszones/{}'.format(record._type)
|
||||
azrecord.type = f'Microsoft.Network/dnszones/{record._type}'
|
||||
record2 = provider._populate_record(zone, azrecord)
|
||||
self.assertEqual(record2.dynamic._data(), record.dynamic._data())
|
||||
|
||||
@@ -1496,7 +1496,7 @@ class TestAzureDnsProvider(TestCase):
|
||||
target_resource=SubResource(id=profiles[-1].id),
|
||||
)
|
||||
azrecord.name = record.name or '@'
|
||||
azrecord.type = 'Microsoft.Network/dnszones/{}'.format(record._type)
|
||||
azrecord.type = f'Microsoft.Network/dnszones/{record._type}'
|
||||
record2 = provider._populate_record(zone, azrecord)
|
||||
self.assertEqual(record2.dynamic._data(), record.dynamic._data())
|
||||
|
||||
@@ -1604,7 +1604,7 @@ class TestAzureDnsProvider(TestCase):
|
||||
target_resource=SubResource(id=profiles[-1].id),
|
||||
)
|
||||
azrecord.name = record.name or '@'
|
||||
azrecord.type = 'Microsoft.Network/dnszones/{}'.format(record._type)
|
||||
azrecord.type = f'Microsoft.Network/dnszones/{record._type}'
|
||||
record2 = provider._populate_record(zone, azrecord)
|
||||
self.assertEqual(record2.dynamic._data(), record.dynamic._data())
|
||||
|
||||
@@ -1711,7 +1711,7 @@ class TestAzureDnsProvider(TestCase):
|
||||
target_resource=SubResource(id=profiles[-1].id),
|
||||
)
|
||||
azrecord.name = record.name or '@'
|
||||
azrecord.type = 'Microsoft.Network/dnszones/{}'.format(record._type)
|
||||
azrecord.type = f'Microsoft.Network/dnszones/{record._type}'
|
||||
record2 = provider._populate_record(zone, azrecord)
|
||||
self.assertEqual(record2.dynamic._data(), record.dynamic._data())
|
||||
|
||||
@@ -1857,7 +1857,7 @@ class TestAzureDnsProvider(TestCase):
|
||||
azrecord = RecordSet(
|
||||
ttl=60, target_resource=SubResource(id=None))
|
||||
azrecord.name = record.name or '@'
|
||||
azrecord.type = 'Microsoft.Network/dnszones/{}'.format(record._type)
|
||||
azrecord.type = f'Microsoft.Network/dnszones/{record._type}'
|
||||
record2 = provider._populate_record(zone, azrecord)
|
||||
self.assertEqual(record2.values, ['255.255.255.255'])
|
||||
|
||||
@@ -1870,7 +1870,7 @@ class TestAzureDnsProvider(TestCase):
|
||||
target_resource=SubResource(id=profiles[-1].id),
|
||||
)
|
||||
azrecord.name = record.name or '@'
|
||||
azrecord.type = 'Microsoft.Network/dnszones/{}'.format(record._type)
|
||||
azrecord.type = f'Microsoft.Network/dnszones/{record._type}'
|
||||
record2 = provider._populate_record(zone, azrecord)
|
||||
self.assertEqual(record2.dynamic._data(), record.dynamic._data())
|
||||
|
||||
@@ -1939,7 +1939,7 @@ class TestAzureDnsProvider(TestCase):
|
||||
azrecord = RecordSet(
|
||||
ttl=60, target_resource=SubResource(id=None))
|
||||
azrecord.name = record.name or '@'
|
||||
azrecord.type = 'Microsoft.Network/dnszones/{}'.format(record._type)
|
||||
azrecord.type = f'Microsoft.Network/dnszones/{record._type}'
|
||||
record2 = provider._populate_record(zone, azrecord)
|
||||
self.assertEqual(record2.values, ['::1'])
|
||||
|
||||
@@ -1951,7 +1951,7 @@ class TestAzureDnsProvider(TestCase):
|
||||
target_resource=SubResource(id=profiles[-1].id),
|
||||
)
|
||||
azrecord.name = record.name or '@'
|
||||
azrecord.type = 'Microsoft.Network/dnszones/{}'.format(record._type)
|
||||
azrecord.type = f'Microsoft.Network/dnszones/{record._type}'
|
||||
record2 = provider._populate_record(zone, azrecord)
|
||||
self.assertEqual(record2.dynamic._data(), record.dynamic._data())
|
||||
|
||||
@@ -1969,8 +1969,8 @@ class TestAzureDnsProvider(TestCase):
|
||||
|
||||
prefix = 'foo--unit--tests'
|
||||
expected_seen = {
|
||||
prefix, '{}-pool-two'.format(prefix),
|
||||
'{}-rule-one'.format(prefix), '{}-rule-two'.format(prefix),
|
||||
prefix, f'{prefix}-pool-two', f'{prefix}-rule-one',
|
||||
f'{prefix}-rule-two',
|
||||
}
|
||||
|
||||
# test no change
|
||||
@@ -1997,9 +1997,7 @@ class TestAzureDnsProvider(TestCase):
|
||||
tm_sync.assert_called_once()
|
||||
|
||||
# test that new profile was successfully inserted in cache
|
||||
new_profile = provider._get_tm_profile_by_name(
|
||||
'{}-pool-two'.format(prefix)
|
||||
)
|
||||
new_profile = provider._get_tm_profile_by_name(f'{prefix}-pool-two')
|
||||
self.assertEqual(new_profile.endpoints[0].weight, 14)
|
||||
|
||||
def test_sync_traffic_managers_duplicate(self):
|
||||
@@ -2028,8 +2026,8 @@ class TestAzureDnsProvider(TestCase):
|
||||
prefix2 = _root_traffic_manager_name(record2)
|
||||
tm_id = provider._profile_name_to_id
|
||||
extra_profile = Profile(
|
||||
id=tm_id('{}-pool-random'.format(prefix2)),
|
||||
name='{}-pool-random'.format(prefix2),
|
||||
id=tm_id(f'{prefix2}-pool-random'),
|
||||
name=f'{prefix2}-pool-random',
|
||||
traffic_routing_method='Weighted',
|
||||
dns_config=sample_profile.dns_config,
|
||||
monitor_config=sample_profile.monitor_config,
|
||||
@@ -2042,8 +2040,8 @@ class TestAzureDnsProvider(TestCase):
|
||||
# implicitly asserts that non-matching profile is not included
|
||||
prefix = _root_traffic_manager_name(record)
|
||||
self.assertEqual(provider._find_traffic_managers(record), {
|
||||
prefix, '{}-pool-two'.format(prefix),
|
||||
'{}-rule-one'.format(prefix), '{}-rule-two'.format(prefix),
|
||||
prefix, f'{prefix}-pool-two', f'{prefix}-rule-one',
|
||||
f'{prefix}-rule-two',
|
||||
})
|
||||
|
||||
def test_traffic_manager_gc(self):
|
||||
@@ -2158,8 +2156,8 @@ class TestAzureDnsProvider(TestCase):
|
||||
tm_id = provider._profile_name_to_id
|
||||
root_profile_name = _root_traffic_manager_name(dynamic_record)
|
||||
extra_profile = Profile(
|
||||
id=tm_id('{}-pool-random'.format(root_profile_name)),
|
||||
name='{}-pool-random'.format(root_profile_name),
|
||||
id=tm_id(f'{root_profile_name}-pool-random'),
|
||||
name=f'{root_profile_name}-pool-random',
|
||||
traffic_routing_method='Weighted',
|
||||
dns_config=sample_profile.dns_config,
|
||||
monitor_config=sample_profile.monitor_config,
|
||||
@@ -2183,7 +2181,7 @@ class TestAzureDnsProvider(TestCase):
|
||||
azrecord = RecordSet(
|
||||
ttl=record1.ttl, target_resource=SubResource(id=None))
|
||||
azrecord.name = record1.name or '@'
|
||||
azrecord.type = 'Microsoft.Network/dnszones/{}'.format(record1._type)
|
||||
azrecord.type = f'Microsoft.Network/dnszones/{record1._type}'
|
||||
|
||||
record2 = provider._populate_record(zone, azrecord)
|
||||
self.assertEqual(record2.value, 'iam.invalid.')
|
||||
|
||||
@@ -77,9 +77,9 @@ class TestDigitalOceanProvider(TestCase):
|
||||
base = 'https://api.digitalocean.com/v2/domains/unit.tests/' \
|
||||
'records?page='
|
||||
with open('tests/fixtures/digitalocean-page-1.json') as fh:
|
||||
mock.get('{}{}'.format(base, 1), text=fh.read())
|
||||
mock.get(f'{base}1', text=fh.read())
|
||||
with open('tests/fixtures/digitalocean-page-2.json') as fh:
|
||||
mock.get('{}{}'.format(base, 2), text=fh.read())
|
||||
mock.get(f'{base}2', text=fh.read())
|
||||
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider.populate(zone)
|
||||
|
||||
@@ -73,11 +73,9 @@ class TestEasyDNSProvider(TestCase):
|
||||
with requests_mock() as mock:
|
||||
base = 'https://rest.easydns.net/zones/records/'
|
||||
with open('tests/fixtures/easydns-records.json') as fh:
|
||||
mock.get('{}{}'.format(base, 'parsed/unit.tests'),
|
||||
text=fh.read())
|
||||
mock.get(f'{base}parsed/unit.tests', text=fh.read())
|
||||
with open('tests/fixtures/easydns-records.json') as fh:
|
||||
mock.get('{}{}'.format(base, 'all/unit.tests'),
|
||||
text=fh.read())
|
||||
mock.get(f'{base}all/unit.tests', text=fh.read())
|
||||
|
||||
provider.populate(zone)
|
||||
self.assertEquals(15, len(zone.records))
|
||||
@@ -97,7 +95,7 @@ class TestEasyDNSProvider(TestCase):
|
||||
|
||||
with requests_mock() as mock:
|
||||
base = 'https://rest.easydns.net/'
|
||||
mock.get('{}{}'.format(base, 'domain/unit.tests'), status_code=400,
|
||||
mock.get(f'{base}domain/unit.tests', status_code=400,
|
||||
text='{"id":"not_found","message":"The resource you '
|
||||
'were accessing could not be found."}')
|
||||
|
||||
@@ -120,18 +118,16 @@ class TestEasyDNSProvider(TestCase):
|
||||
|
||||
with requests_mock() as mock:
|
||||
base = 'https://rest.easydns.net/'
|
||||
mock.get('{}{}'.format(base, 'domain/unit.tests'), status_code=404,
|
||||
mock.get(f'{base}domain/unit.tests', status_code=404,
|
||||
text='{"id":"not_found","message":"The resource you '
|
||||
'were accessing could not be found."}')
|
||||
mock.put('{}{}'.format(base, 'domains/add/unit.tests'),
|
||||
status_code=200,
|
||||
mock.put(f'{base}domains/add/unit.tests', status_code=200,
|
||||
text='{"id":"OK","message":"Zone created."}')
|
||||
mock.get('{}{}'.format(base, 'zones/records/parsed/unit.tests'),
|
||||
mock.get(f'{base}zones/records/parsed/unit.tests',
|
||||
status_code=404,
|
||||
text='{"id":"not_found","message":"The resource you '
|
||||
'were accessing could not be found."}')
|
||||
mock.get('{}{}'.format(base, 'zones/records/all/unit.tests'),
|
||||
status_code=404,
|
||||
mock.get(f'{base}zones/records/all/unit.tests', status_code=404,
|
||||
text='{"id":"not_found","message":"The resource you '
|
||||
'were accessing could not be found."}')
|
||||
|
||||
@@ -188,9 +184,9 @@ class TestEasyDNSProvider(TestCase):
|
||||
}
|
||||
with requests_mock() as mock:
|
||||
base = 'https://rest.easydns.net/'
|
||||
mock.put('{}{}'.format(base, 'domains/add/unit.tests'),
|
||||
mock.put(f'{base}domains/add/unit.tests',
|
||||
status_code=201, text='{"id":"OK"}')
|
||||
mock.get('{}{}'.format(base, 'zones/records/all/unit.tests'),
|
||||
mock.get(f'{base}zones/records/all/unit.tests',
|
||||
text=json.dumps(domain_after_creation))
|
||||
mock.delete(ANY, text='{"id":"OK"}')
|
||||
provider._client.domain_create('unit.tests')
|
||||
|
||||
@@ -291,8 +291,8 @@ class TestRoute53Provider(TestCase):
|
||||
record = Record.new(expected, name, data)
|
||||
expected.add_record(record)
|
||||
|
||||
caller_ref = '{}:A:unit.tests.:1324' \
|
||||
.format(Route53Provider.HEALTH_CHECK_VERSION)
|
||||
caller_ref = f'{Route53Provider.HEALTH_CHECK_VERSION}:A:unit.tests.:1324'
|
||||
|
||||
health_checks = [{
|
||||
'Id': '42',
|
||||
'CallerReference': caller_ref,
|
||||
@@ -1243,8 +1243,7 @@ class TestRoute53Provider(TestCase):
|
||||
provider, stubber = self._get_stubbed_provider()
|
||||
|
||||
# No match based on type
|
||||
caller_ref = \
|
||||
'{}:AAAA:foo1234'.format(Route53Provider.HEALTH_CHECK_VERSION)
|
||||
caller_ref = f'{Route53Provider.HEALTH_CHECK_VERSION}:AAAA:foo1234'
|
||||
health_checks = [{
|
||||
'Id': '42',
|
||||
# No match based on version
|
||||
|
||||
@@ -196,12 +196,12 @@ class TestSelectelProvider(TestCase):
|
||||
@requests_mock.Mocker()
|
||||
def test_populate(self, fake_http):
|
||||
zone = Zone('unit.tests.', [])
|
||||
fake_http.get('{}/unit.tests/records/'.format(self.API_URL),
|
||||
fake_http.get(f'{self.API_URL}/unit.tests/records/',
|
||||
json=self.api_record)
|
||||
fake_http.get('{}/'.format(self.API_URL), json=self.domain)
|
||||
fake_http.head('{}/unit.tests/records/'.format(self.API_URL),
|
||||
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('{}/'.format(self.API_URL),
|
||||
fake_http.head(f'{self.API_URL}/',
|
||||
headers={'X-Total-Count': str(len(self.domain))})
|
||||
|
||||
provider = SelectelProvider(123, 'secret_token')
|
||||
@@ -220,12 +220,12 @@ class TestSelectelProvider(TestCase):
|
||||
"email": "support@unit.tests"})
|
||||
|
||||
zone = Zone('unit.tests.', [])
|
||||
fake_http.get('{}/unit.tests/records/'.format(self.API_URL),
|
||||
fake_http.get(f'{self.API_URL}/unit.tests/records/',
|
||||
json=more_record)
|
||||
fake_http.get('{}/'.format(self.API_URL), json=self.domain)
|
||||
fake_http.head('{}/unit.tests/records/'.format(self.API_URL),
|
||||
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('{}/'.format(self.API_URL),
|
||||
fake_http.head(f'{self.API_URL}/',
|
||||
headers={'X-Total-Count': str(len(self.domain))})
|
||||
|
||||
zone.add_record(Record.new(self.zone, 'unsup', {
|
||||
@@ -249,14 +249,13 @@ class TestSelectelProvider(TestCase):
|
||||
@requests_mock.Mocker()
|
||||
def test_apply(self, fake_http):
|
||||
|
||||
fake_http.get('{}/unit.tests/records/'.format(self.API_URL),
|
||||
json=list())
|
||||
fake_http.get('{}/'.format(self.API_URL), json=self.domain)
|
||||
fake_http.head('{}/unit.tests/records/'.format(self.API_URL),
|
||||
fake_http.get(f'{self.API_URL}/unit.tests/records/', json=list())
|
||||
fake_http.get(f'{self.API_URL}/', json=self.domain)
|
||||
fake_http.head(f'{self.API_URL}/unit.tests/records/',
|
||||
headers={'X-Total-Count': '0'})
|
||||
fake_http.head('{}/'.format(self.API_URL),
|
||||
fake_http.head(f'{self.API_URL}/',
|
||||
headers={'X-Total-Count': str(len(self.domain))})
|
||||
fake_http.post('{}/100000/records/'.format(self.API_URL), json=list())
|
||||
fake_http.post(f'{self.API_URL}/100000/records/', json=list())
|
||||
|
||||
provider = SelectelProvider(123, 'test_token')
|
||||
|
||||
@@ -271,8 +270,8 @@ class TestSelectelProvider(TestCase):
|
||||
|
||||
@requests_mock.Mocker()
|
||||
def test_domain_list(self, fake_http):
|
||||
fake_http.get('{}/'.format(self.API_URL), json=self.domain)
|
||||
fake_http.head('{}/'.format(self.API_URL),
|
||||
fake_http.get(f'{self.API_URL}/', json=self.domain)
|
||||
fake_http.head(f'{self.API_URL}/',
|
||||
headers={'X-Total-Count': str(len(self.domain))})
|
||||
|
||||
expected = {'unit.tests': self.domain[0]}
|
||||
@@ -283,8 +282,8 @@ class TestSelectelProvider(TestCase):
|
||||
|
||||
@requests_mock.Mocker()
|
||||
def test_authentication_fail(self, fake_http):
|
||||
fake_http.get('{}/'.format(self.API_URL), status_code=401)
|
||||
fake_http.head('{}/'.format(self.API_URL),
|
||||
fake_http.get(f'{self.API_URL}/', status_code=401)
|
||||
fake_http.head(f'{self.API_URL}/',
|
||||
headers={'X-Total-Count': str(len(self.domain))})
|
||||
|
||||
with self.assertRaises(Exception) as ctx:
|
||||
@@ -294,20 +293,17 @@ class TestSelectelProvider(TestCase):
|
||||
|
||||
@requests_mock.Mocker()
|
||||
def test_not_exist_domain(self, fake_http):
|
||||
fake_http.get('{}/'.format(self.API_URL), status_code=404, json='')
|
||||
fake_http.head('{}/'.format(self.API_URL),
|
||||
fake_http.get(f'{self.API_URL}/', status_code=404, json='')
|
||||
fake_http.head(f'{self.API_URL}/',
|
||||
headers={'X-Total-Count': str(len(self.domain))})
|
||||
|
||||
fake_http.post('{}/'.format(self.API_URL),
|
||||
json={"name": "unit.tests",
|
||||
"create_date": 1507154178,
|
||||
"id": 100000})
|
||||
fake_http.get('{}/unit.tests/records/'.format(self.API_URL),
|
||||
json=list())
|
||||
fake_http.head('{}/unit.tests/records/'.format(self.API_URL),
|
||||
fake_http.post(f'{self.API_URL}/', json={"name": "unit.tests",
|
||||
"create_date": 1507154178,
|
||||
"id": 100000})
|
||||
fake_http.get(f'{self.API_URL}/unit.tests/records/', json=list())
|
||||
fake_http.head(f'{self.API_URL}/unit.tests/records/',
|
||||
headers={'X-Total-Count': str(len(self.api_record))})
|
||||
fake_http.post('{}/100000/records/'.format(self.API_URL),
|
||||
json=list())
|
||||
fake_http.post(f'{self.API_URL}/100000/records/', json=list())
|
||||
|
||||
provider = SelectelProvider(123, 'test_token')
|
||||
|
||||
@@ -322,11 +318,11 @@ class TestSelectelProvider(TestCase):
|
||||
|
||||
@requests_mock.Mocker()
|
||||
def test_delete_no_exist_record(self, fake_http):
|
||||
fake_http.get('{}/'.format(self.API_URL), json=self.domain)
|
||||
fake_http.get('{}/100000/records/'.format(self.API_URL), json=list())
|
||||
fake_http.head('{}/'.format(self.API_URL),
|
||||
fake_http.get(f'{self.API_URL}/', json=self.domain)
|
||||
fake_http.get(f'{self.API_URL}/100000/records/', json=list())
|
||||
fake_http.head(f'{self.API_URL}/',
|
||||
headers={'X-Total-Count': str(len(self.domain))})
|
||||
fake_http.head('{}/unit.tests/records/'.format(self.API_URL),
|
||||
fake_http.head(f'{self.API_URL}/unit.tests/records/',
|
||||
headers={'X-Total-Count': '0'})
|
||||
|
||||
provider = SelectelProvider(123, 'test_token')
|
||||
@@ -348,23 +344,19 @@ class TestSelectelProvider(TestCase):
|
||||
"type": "A",
|
||||
"id": 100002,
|
||||
"name": "unit.tests"}] # exist
|
||||
fake_http.get('{}/unit.tests/records/'.format(self.API_URL),
|
||||
json=exist_record)
|
||||
fake_http.get('{}/'.format(self.API_URL), json=self.domain)
|
||||
fake_http.get('{}/100000/records/'.format(self.API_URL),
|
||||
json=exist_record)
|
||||
fake_http.head('{}/unit.tests/records/'.format(self.API_URL),
|
||||
fake_http.get(f'{self.API_URL}/unit.tests/records/', json=exist_record)
|
||||
fake_http.get(f'{self.API_URL}/', json=self.domain)
|
||||
fake_http.get(f'{self.API_URL}/100000/records/', json=exist_record)
|
||||
fake_http.head(f'{self.API_URL}/unit.tests/records/',
|
||||
headers={'X-Total-Count': str(len(exist_record))})
|
||||
fake_http.head('{}/'.format(self.API_URL),
|
||||
fake_http.head(f'{self.API_URL}/',
|
||||
headers={'X-Total-Count': str(len(self.domain))})
|
||||
fake_http.head('{}/100000/records/'.format(self.API_URL),
|
||||
fake_http.head(f'{self.API_URL}/100000/records/',
|
||||
headers={'X-Total-Count': str(len(exist_record))})
|
||||
fake_http.post('{}/100000/records/'.format(self.API_URL),
|
||||
fake_http.post(f'{self.API_URL}/100000/records/',
|
||||
json=list())
|
||||
fake_http.delete('{}/100000/records/100001'.format(self.API_URL),
|
||||
text="")
|
||||
fake_http.delete('{}/100000/records/100002'.format(self.API_URL),
|
||||
text="")
|
||||
fake_http.delete(f'{self.API_URL}/100000/records/100001', text="")
|
||||
fake_http.delete(f'{self.API_URL}/100000/records/100002', text="")
|
||||
|
||||
provider = SelectelProvider(123, 'test_token')
|
||||
|
||||
@@ -379,8 +371,8 @@ class TestSelectelProvider(TestCase):
|
||||
|
||||
@requests_mock.Mocker()
|
||||
def test_include_change_returns_false(self, fake_http):
|
||||
fake_http.get('{}/'.format(self.API_URL), json=self.domain)
|
||||
fake_http.head('{}/'.format(self.API_URL),
|
||||
fake_http.get(f'{self.API_URL}/', json=self.domain)
|
||||
fake_http.head(f'{self.API_URL}/',
|
||||
headers={'X-Total-Count': str(len(self.domain))})
|
||||
provider = SelectelProvider(123, 'test_token')
|
||||
zone = Zone('unit.tests.', [])
|
||||
|
||||
@@ -309,7 +309,7 @@ class TestSplitYamlProvider(TestCase):
|
||||
# ensure correctness.
|
||||
for record_name in ('_srv._tcp', 'mx', 'naptr', 'sub', 'txt',
|
||||
'urlfwd'):
|
||||
yaml_file = join(zone_dir, '{}.yaml'.format(record_name))
|
||||
yaml_file = join(zone_dir, f'{record_name}.yaml')
|
||||
self.assertTrue(isfile(yaml_file))
|
||||
with open(yaml_file) as fh:
|
||||
data = safe_load(fh.read())
|
||||
@@ -318,7 +318,7 @@ class TestSplitYamlProvider(TestCase):
|
||||
# These are stored as singular "value." Again, check each file.
|
||||
for record_name in ('aaaa', 'cname', 'dname', 'included', 'ptr',
|
||||
'spf', 'www.sub', 'www'):
|
||||
yaml_file = join(zone_dir, '{}.yaml'.format(record_name))
|
||||
yaml_file = join(zone_dir, f'{record_name}.yaml')
|
||||
self.assertTrue(isfile(yaml_file))
|
||||
with open(yaml_file) as fh:
|
||||
data = safe_load(fh.read())
|
||||
@@ -327,7 +327,7 @@ class TestSplitYamlProvider(TestCase):
|
||||
# Again with the plural, this time checking dynamic.tests.
|
||||
for record_name in ('a', 'aaaa', 'real-ish-a'):
|
||||
yaml_file = join(
|
||||
dynamic_zone_dir, '{}.yaml'.format(record_name))
|
||||
dynamic_zone_dir, f'{record_name}.yaml')
|
||||
self.assertTrue(isfile(yaml_file))
|
||||
with open(yaml_file) as fh:
|
||||
data = safe_load(fh.read())
|
||||
@@ -337,8 +337,7 @@ class TestSplitYamlProvider(TestCase):
|
||||
|
||||
# Singular again.
|
||||
for record_name in ('cname', 'simple-weighted'):
|
||||
yaml_file = join(
|
||||
dynamic_zone_dir, '{}.yaml'.format(record_name))
|
||||
yaml_file = join(dynamic_zone_dir, f'{record_name}.yaml')
|
||||
self.assertTrue(isfile(yaml_file))
|
||||
with open(yaml_file) as fh:
|
||||
data = safe_load(fh.read())
|
||||
|
||||
@@ -2664,7 +2664,7 @@ class TestRecordValidation(TestCase):
|
||||
'ttl': 600,
|
||||
'value': v
|
||||
})
|
||||
self.assertEquals(['missing {}'.format(k)], ctx.exception.reasons)
|
||||
self.assertEquals([f'missing {k}'], ctx.exception.reasons)
|
||||
|
||||
# non-int order
|
||||
v = dict(value)
|
||||
|
||||
Reference in New Issue
Block a user