Browse Source

Clean up and test OwnershipProcessor

pull/637/head
Ross McFarland 5 years ago
parent
commit
540fb27263
No known key found for this signature in database GPG Key ID: 943B179E15D3B22A
2 changed files with 5 additions and 19 deletions
  1. +1
    -13
      octodns/processor/ownership.py
  2. +4
    -6
      tests/test_octodns_processor_filter.py

+ 1
- 13
octodns/processor/ownership.py 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
tests/test_octodns_processor_filter.py 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]))

Loading…
Cancel
Save