Clean up and test OwnershipProcessor

This commit is contained in:
Ross McFarland
2021-04-27 09:25:24 -07:00
parent f387a61561
commit 540fb27263
2 changed files with 5 additions and 19 deletions
+1 -13
View File
@@ -6,12 +6,11 @@ from __future__ import absolute_import, division, print_function, \
unicode_literals
from collections import defaultdict
from pprint import pprint
from ..provider.plan import Plan
from ..record import Record
from . import BaseProcessor
from .base import BaseProcessor
# Mark anything octoDNS is managing that way it can know it's safe to modify or
@@ -71,8 +70,6 @@ class OwnershipProcessor(BaseProcessor):
name = ''
owned[name][_type.upper()] = True
pprint(dict(owned))
# Cases:
# - Configured in source
# - We'll fully CRU/manage it adding ownership TXT,
@@ -83,17 +80,10 @@ class OwnershipProcessor(BaseProcessor):
# - Special records like octodns-meta
# - Should be left alone and should not have ownerthis TXTs
pprint(plan.changes)
filtered_changes = []
for change in plan.changes:
record = change.record
pprint([change,
not self._is_ownership(record),
record._type not in owned[record.name],
record.name != 'octodns-meta'])
if not self._is_ownership(record) and \
record._type not in owned[record.name] and \
record.name != 'octodns-meta':
@@ -105,8 +95,6 @@ class OwnershipProcessor(BaseProcessor):
# change is we should do
filtered_changes.append(change)
pprint(filtered_changes)
if plan.changes != filtered_changes:
return Plan(plan.existing, plan.desired, filtered_changes,
plan.exists, plan.update_pcent_threshold,
+4 -6
View File
@@ -5,8 +5,6 @@
from __future__ import absolute_import, division, print_function, \
unicode_literals
from logging import getLogger
from six import StringIO, text_type
from unittest import TestCase
from octodns.processor.filter import TypeAllowlistFilter, TypeRejectlistFilter
@@ -57,12 +55,12 @@ class TestTypeAllowListFilter(TestCase):
self.assertEquals(['aaaa'], sorted([r.name for r in got.records]))
filter_txt = TypeAllowlistFilter('only-txt', ['TXT'])
got = filter_txt.process_source_zone(zone)
got = filter_txt.process_target_zone(zone)
self.assertEquals(['txt', 'txt2'],
sorted([r.name for r in got.records]))
filter_a_aaaa = TypeAllowlistFilter('only-aaaa', set(('A', 'AAAA')))
got = filter_a_aaaa.process_source_zone(zone)
got = filter_a_aaaa.process_target_zone(zone)
self.assertEquals(['a', 'a2', 'aaaa'],
sorted([r.name for r in got.records]))
@@ -82,11 +80,11 @@ class TestTypeRejectListFilter(TestCase):
sorted([r.name for r in got.records]))
filter_txt = TypeRejectlistFilter('not-txt', ['TXT'])
got = filter_txt.process_source_zone(zone)
got = filter_txt.process_target_zone(zone)
self.assertEquals(['a', 'a2', 'aaaa'],
sorted([r.name for r in got.records]))
filter_a_aaaa = TypeRejectlistFilter('not-a-aaaa', set(('A', 'AAAA')))
got = filter_a_aaaa.process_source_zone(zone)
got = filter_a_aaaa.process_target_zone(zone)
self.assertEquals(['txt', 'txt2'],
sorted([r.name for r in got.records]))