Browse Source

Implement YamlProvider.supports that always says yes

pull/924/head
Ross McFarland 3 years ago
parent
commit
557b80f784
No known key found for this signature in database GPG Key ID: 943B179E15D3B22A
2 changed files with 22 additions and 0 deletions
  1. +8
    -0
      octodns/provider/yaml.py
  2. +14
    -0
      tests/test_octodns_provider_yaml.py

+ 8
- 0
octodns/provider/yaml.py View File

@ -167,6 +167,14 @@ class YamlProvider(BaseProvider):
del args['log']
return self.__class__(**args)
def supports(self, record):
# We're overriding this as a performance tweak, namely to avoid calling
# the implementation of the SUPPORTS property to create a set from a
# dict_keys every single time something checked whether we support a
# record, the answer is always yes so that's overkill and we can just
# return True here and be done with it
return True
@property
def SUPPORTS_ROOT_NS(self):
return self.supports_root_ns


+ 14
- 0
tests/test_octodns_provider_yaml.py View File

@ -217,6 +217,20 @@ class TestYamlProvider(TestCase):
str(ctx.exception),
)
def test_supports_everything(self):
source = YamlProvider('test', join(dirname(__file__), 'config'))
class DummyType(object):
def __init__(self, _type):
self._type = _type
# No matter what we check it's always supported
self.assertTrue(source.supports(DummyType(None)))
self.assertTrue(source.supports(DummyType(42)))
self.assertTrue(source.supports(DummyType('A')))
self.assertTrue(source.supports(DummyType(source)))
self.assertTrue(source.supports(DummyType(self)))
class TestSplitYamlProvider(TestCase):
def test_list_all_yaml_files(self):


Loading…
Cancel
Save