Additional recordset validation testing
- Minor modification to record __repr__ to make testing easier. Change-Id: I094a2ee9ccd19aa75cf3e7adcd3ce09f033d3527
This commit is contained in:
parent
fad3d708dc
commit
29097ed559
@ -68,7 +68,7 @@ class Record(base.DesignateObject, base.PersistentObjectMixin,
|
||||
|
||||
def __repr__(self):
|
||||
record = self.to_dict()
|
||||
if 'data' in record:
|
||||
if record.get('data') is not None:
|
||||
record['data'] = record['data'][:35]
|
||||
return self._make_obj_str(record)
|
||||
|
||||
|
@ -16,6 +16,8 @@
|
||||
import itertools
|
||||
from unittest import mock
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_config import fixture as cfg_fixture
|
||||
from oslo_log import log as logging
|
||||
import oslotest.base
|
||||
|
||||
@ -23,6 +25,7 @@ from designate import exceptions
|
||||
from designate import objects
|
||||
from designate.objects.adapters import DesignateAdapter
|
||||
|
||||
CONF = cfg.CONF
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@ -41,6 +44,10 @@ def create_test_recordset():
|
||||
|
||||
|
||||
class RecordSetTest(oslotest.base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(RecordSetTest, self).setUp()
|
||||
self.useFixture(cfg_fixture.Config(CONF))
|
||||
|
||||
def test_init(self):
|
||||
record_set = create_test_recordset()
|
||||
self.assertEqual('www.example.org.', record_set.name)
|
||||
@ -227,6 +234,47 @@ class RecordSetTest(oslotest.base.BaseTestCase):
|
||||
record_set = create_test_recordset()
|
||||
record_set.validate()
|
||||
|
||||
def test_validate_attribute_error(self):
|
||||
record_set = objects.RecordSet(
|
||||
name='www.example.org.',
|
||||
type='NAPTR',
|
||||
records=objects.RecordList(objects=[
|
||||
objects.Record(data=None),
|
||||
])
|
||||
)
|
||||
self.assertRaisesRegex(
|
||||
exceptions.InvalidObject,
|
||||
'Provided object does not match schema',
|
||||
record_set.validate
|
||||
)
|
||||
|
||||
def test_validate_type_error(self):
|
||||
record_set = objects.RecordSet(
|
||||
name='www.example.org.',
|
||||
type='TXT',
|
||||
records=objects.RecordList(objects=[
|
||||
objects.Record(data=None),
|
||||
])
|
||||
)
|
||||
self.assertRaisesRegex(
|
||||
exceptions.InvalidObject,
|
||||
'Provided object does not match schema',
|
||||
record_set.validate
|
||||
)
|
||||
|
||||
def test_validate_unsupported_recordset_type(self):
|
||||
CONF.set_override('supported_record_type', ['A', 'AAAA', 'CNAME'])
|
||||
|
||||
record_set = objects.RecordSet(
|
||||
name='www.example.org.', type='PTR',
|
||||
records=[]
|
||||
)
|
||||
self.assertRaisesRegex(
|
||||
exceptions.InvalidObject,
|
||||
'Provided object does not match schema',
|
||||
record_set.validate
|
||||
)
|
||||
|
||||
def test_validate_handle_exception(self):
|
||||
record_set = create_test_recordset()
|
||||
rs_module = record_set.__class__.__bases__[0].__module__
|
||||
|
Loading…
Reference in New Issue
Block a user