mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Make SUPPORTS_DYNAMIC an optional property, defaulting to False
This commit is contained in:
@@ -16,13 +16,14 @@ class BaseSource(object):
|
||||
if not hasattr(self, 'SUPPORTS_GEO'):
|
||||
raise NotImplementedError('Abstract base class, SUPPORTS_GEO '
|
||||
'property missing')
|
||||
if not hasattr(self, 'SUPPORTS_DYNAMIC'):
|
||||
raise NotImplementedError('Abstract base class, SUPPORTS_DYNAMIC '
|
||||
'property missing')
|
||||
if not hasattr(self, 'SUPPORTS'):
|
||||
raise NotImplementedError('Abstract base class, SUPPORTS '
|
||||
'property missing')
|
||||
|
||||
@property
|
||||
def SUPPORTS_DYNAMIC(self):
|
||||
return False
|
||||
|
||||
def populate(self, zone, target=False, lenient=False):
|
||||
'''
|
||||
Loads all records the provider knows about for the provided zone
|
||||
|
@@ -61,27 +61,29 @@ class TestBaseProvider(TestCase):
|
||||
class HasSupportsGeo(HasLog):
|
||||
SUPPORTS_GEO = False
|
||||
|
||||
with self.assertRaises(NotImplementedError) as ctx:
|
||||
HasSupportsGeo('hassupportsgeo')
|
||||
self.assertEquals('Abstract base class, SUPPORTS_DYNAMIC '
|
||||
'property missing', ctx.exception.message)
|
||||
|
||||
class HasSupportsDyanmic(HasSupportsGeo):
|
||||
SUPPORTS_DYNAMIC = False
|
||||
|
||||
zone = Zone('unit.tests.', ['sub'])
|
||||
with self.assertRaises(NotImplementedError) as ctx:
|
||||
HasSupportsDyanmic('hassupportsdynamic').populate(zone)
|
||||
HasSupportsGeo('hassupportsgeo').populate(zone)
|
||||
self.assertEquals('Abstract base class, SUPPORTS property missing',
|
||||
ctx.exception.message)
|
||||
|
||||
class HasSupports(HasSupportsDyanmic):
|
||||
class HasSupports(HasSupportsGeo):
|
||||
SUPPORTS = set(('A',))
|
||||
with self.assertRaises(NotImplementedError) as ctx:
|
||||
HasSupports('hassupports').populate(zone)
|
||||
self.assertEquals('Abstract base class, populate method missing',
|
||||
ctx.exception.message)
|
||||
|
||||
# SUPPORTS_DYNAMIC has a default/fallback
|
||||
self.assertFalse(HasSupports('hassupports').SUPPORTS_DYNAMIC)
|
||||
|
||||
# But can be overridden
|
||||
class HasSupportsDyanmic(HasSupports):
|
||||
SUPPORTS_DYNAMIC = True
|
||||
|
||||
self.assertTrue(HasSupportsDyanmic('hassupportsdynamic')
|
||||
.SUPPORTS_DYNAMIC)
|
||||
|
||||
class HasPopulate(HasSupports):
|
||||
|
||||
def populate(self, zone, target=False, lenient=False):
|
||||
|
Reference in New Issue
Block a user