1
0
mirror of https://github.com/github/octodns.git synced 2024-05-11 05:55:00 +00:00
Files
github-octodns/tests/helpers.py
Ross McFarland a97818b6ec populating existing provider state is lenient
- adds lenient flag to Record.new, problems during validation are just
  warnings if it's true
- target populate calls during the plan phase pass lenient=True
- make all of the provider.populate call logging consistent including both
  target and lenient
- add source=self to Record.new in a few places that were missing it
2017-06-23 09:01:25 -07:00

71 lines
1.3 KiB
Python

#
#
#
from __future__ import absolute_import, division, print_function, \
unicode_literals
from shutil import rmtree
from tempfile import mkdtemp
class SimpleSource(object):
def __init__(self, id='test'):
pass
class SimpleProvider(object):
SUPPORTS_GEO = False
SUPPORTS = set(('A',))
def __init__(self, id='test'):
pass
def populate(self, zone, source=False, lenient=False):
pass
def supports(self, record):
return True
def __repr__(self):
return self.__class__.__name__
class GeoProvider(object):
SUPPORTS_GEO = True
def __init__(self, id='test'):
pass
def populate(self, zone, source=False, lenient=False):
pass
def supports(self, record):
return True
def __repr__(self):
return self.__class__.__name__
class NoSshFpProvider(SimpleProvider):
def supports(self, record):
return record._type != 'SSHFP'
class TemporaryDirectory(object):
def __init__(self, delete_on_exit=True):
self.delete_on_exit = delete_on_exit
def __enter__(self):
self.dirname = mkdtemp()
return self
def __exit__(self, *args, **kwargs):
if self.delete_on_exit:
rmtree(self.dirname)
else:
raise Exception(self.dirname)