Browse Source

Ensure pool caching works for Constellix Provider

The caching of pools for the Constellix provider will now cache based
on the type of pool and the name. Previously it was caching based on
the name only.
pull/616/head
mintopia 5 years ago
parent
commit
e89f309179
2 changed files with 52 additions and 1 deletions
  1. +1
    -1
      octodns/provider/constellix.py
  2. +51
    -0
      tests/test_octodns_provider_constellix.py

+ 1
- 1
octodns/provider/constellix.py View File

@ -178,7 +178,7 @@ class ConstellixClient(object):
def pool(self, pool_type, pool_name): def pool(self, pool_type, pool_name):
pools = self.pools(pool_type) pools = self.pools(pool_type)
for pool in pools: for pool in pools:
if pool['name'] == pool_name:
if pool['name'] == pool_name and pool['type'] == pool_type:
return pool return pool
return None return None


+ 51
- 0
tests/test_octodns_provider_constellix.py View File

@ -521,3 +521,54 @@ class TestConstellixProvider(TestCase):
self.assertIsNone(provider._client.pool_by_id('A', 1)) self.assertIsNone(provider._client.pool_by_id('A', 1))
self.assertIsNone(provider._client.pool('A', 'foobar')) self.assertIsNone(provider._client.pool('A', 'foobar'))
def test_pools_are_cached_correctly(self):
provider = ConstellixProvider('test', 'api', 'secret')
provider._client.pools = Mock(return_value=[{
"id": 1808521,
"name": "unit.tests.:www.dynamic:A:two",
"type": "A",
"values": [
{
"value": "1.2.3.4",
"weight": 1
}
]
}])
found = provider._client.pool('A', 'unit.tests.:www.dynamic:A:two')
self.assertIsNotNone(found)
not_found = provider._client.pool('AAAA',
'unit.tests.:www.dynamic:A:two')
self.assertIsNone(not_found)
provider._client.pools = Mock(return_value=[{
"id": 42,
"name": "unit.tests.:www.dynamic:A:two",
"type": "A",
"values": [
{
"value": "1.2.3.4",
"weight": 1
}
]
}, {
"id": 451,
"name": "unit.tests.:www.dynamic:A:two",
"type": "AAAA",
"values": [
{
"value": "1.2.3.4",
"weight": 1
}
]
}])
a_pool = provider._client.pool('A', 'unit.tests.:www.dynamic:A:two')
self.assertEquals(42, a_pool['id'])
aaaa_pool = provider._client.pool('AAAA',
'unit.tests.:www.dynamic:A:two')
self.assertEquals(451, aaaa_pool['id'])

Loading…
Cancel
Save