mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Merge pull request #317 from github/supports_dynamic_optional
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'):
|
if not hasattr(self, 'SUPPORTS_GEO'):
|
||||||
raise NotImplementedError('Abstract base class, SUPPORTS_GEO '
|
raise NotImplementedError('Abstract base class, SUPPORTS_GEO '
|
||||||
'property missing')
|
'property missing')
|
||||||
if not hasattr(self, 'SUPPORTS_DYNAMIC'):
|
|
||||||
raise NotImplementedError('Abstract base class, SUPPORTS_DYNAMIC '
|
|
||||||
'property missing')
|
|
||||||
if not hasattr(self, 'SUPPORTS'):
|
if not hasattr(self, 'SUPPORTS'):
|
||||||
raise NotImplementedError('Abstract base class, SUPPORTS '
|
raise NotImplementedError('Abstract base class, SUPPORTS '
|
||||||
'property missing')
|
'property missing')
|
||||||
|
|
||||||
|
@property
|
||||||
|
def SUPPORTS_DYNAMIC(self):
|
||||||
|
return False
|
||||||
|
|
||||||
def populate(self, zone, target=False, lenient=False):
|
def populate(self, zone, target=False, lenient=False):
|
||||||
'''
|
'''
|
||||||
Loads all records the provider knows about for the provided zone
|
Loads all records the provider knows about for the provided zone
|
||||||
|
|||||||
@@ -61,27 +61,29 @@ class TestBaseProvider(TestCase):
|
|||||||
class HasSupportsGeo(HasLog):
|
class HasSupportsGeo(HasLog):
|
||||||
SUPPORTS_GEO = False
|
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'])
|
zone = Zone('unit.tests.', ['sub'])
|
||||||
with self.assertRaises(NotImplementedError) as ctx:
|
with self.assertRaises(NotImplementedError) as ctx:
|
||||||
HasSupportsDyanmic('hassupportsdynamic').populate(zone)
|
HasSupportsGeo('hassupportsgeo').populate(zone)
|
||||||
self.assertEquals('Abstract base class, SUPPORTS property missing',
|
self.assertEquals('Abstract base class, SUPPORTS property missing',
|
||||||
ctx.exception.message)
|
ctx.exception.message)
|
||||||
|
|
||||||
class HasSupports(HasSupportsDyanmic):
|
class HasSupports(HasSupportsGeo):
|
||||||
SUPPORTS = set(('A',))
|
SUPPORTS = set(('A',))
|
||||||
with self.assertRaises(NotImplementedError) as ctx:
|
with self.assertRaises(NotImplementedError) as ctx:
|
||||||
HasSupports('hassupports').populate(zone)
|
HasSupports('hassupports').populate(zone)
|
||||||
self.assertEquals('Abstract base class, populate method missing',
|
self.assertEquals('Abstract base class, populate method missing',
|
||||||
ctx.exception.message)
|
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):
|
class HasPopulate(HasSupports):
|
||||||
|
|
||||||
def populate(self, zone, target=False, lenient=False):
|
def populate(self, zone, target=False, lenient=False):
|
||||||
|
|||||||
Reference in New Issue
Block a user