mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
_process_desired_zone after populate, test/enforce order
This commit is contained in:
@@ -168,13 +168,6 @@ class BaseProvider(BaseSource):
|
||||
def plan(self, desired, processors=[]):
|
||||
self.log.info('plan: desired=%s', desired.name)
|
||||
|
||||
# Make a (shallow) copy of the desired state so that everything from
|
||||
# now on (in this target) can modify it as they see fit without
|
||||
# worrying about impacting other targets.
|
||||
desired = desired.copy()
|
||||
|
||||
desired = self._process_desired_zone(desired)
|
||||
|
||||
existing = Zone(desired.name, desired.sub_zones)
|
||||
exists = self.populate(existing, target=True, lenient=True)
|
||||
if exists is None:
|
||||
@@ -183,6 +176,13 @@ class BaseProvider(BaseSource):
|
||||
self.log.warning('Provider %s used in target mode did not return '
|
||||
'exists', self.id)
|
||||
|
||||
# Make a (shallow) copy of the desired state so that everything from
|
||||
# now on (in this target) can modify it as they see fit without
|
||||
# worrying about impacting other targets.
|
||||
desired = desired.copy()
|
||||
|
||||
desired = self._process_desired_zone(desired)
|
||||
|
||||
existing = self._process_existing_zone(existing)
|
||||
|
||||
for processor in processors:
|
||||
|
||||
@@ -277,6 +277,37 @@ class TestBaseProvider(TestCase):
|
||||
# We filtered out the only change
|
||||
self.assertFalse(plan)
|
||||
|
||||
def test_plan_order_of_operations(self):
|
||||
|
||||
class MockProvider(BaseProvider):
|
||||
log = getLogger('mock-provider')
|
||||
SUPPORTS = set(('A',))
|
||||
SUPPORTS_GEO = False
|
||||
|
||||
def __init__(self):
|
||||
super().__init__('mock-provider')
|
||||
self.calls = []
|
||||
|
||||
def populate(self, *args, **kwargs):
|
||||
self.calls.append('populate')
|
||||
|
||||
def _process_desired_zone(self, *args, **kwargs):
|
||||
self.calls.append('_process_desired_zone')
|
||||
return super()._process_desired_zone(*args, **kwargs)
|
||||
|
||||
def _process_existing_zone(self, *args, **kwargs):
|
||||
self.calls.append('_process_existing_zone')
|
||||
return super()._process_existing_zone(*args, **kwargs)
|
||||
|
||||
provider = MockProvider()
|
||||
|
||||
zone = Zone('unit.tests.', [])
|
||||
self.assertFalse(provider.plan(zone))
|
||||
# ensure the calls were made in the expected order, populate comes
|
||||
# first, then desired, then existing
|
||||
self.assertEqual(['populate', '_process_desired_zone',
|
||||
'_process_existing_zone'], provider.calls)
|
||||
|
||||
def test_process_desired_zone(self):
|
||||
provider = HelperProvider('test')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user