Object model: require "priority" field
Add tests Closes-Bug: #1516350 Change-Id: I91ac97f5f6b860f1649b91cf53d9c268c4df0de6
This commit is contained in:
parent
c2a0af1aa8
commit
ee5efbf52a
@ -32,6 +32,7 @@ class PoolNsRecord(base.DictObjectMixin, base.PersistentObjectMixin,
|
||||
'minimum': 1,
|
||||
'maximum': 10000
|
||||
},
|
||||
'required': True
|
||||
},
|
||||
'hostname': {
|
||||
'schema': {
|
||||
|
@ -307,6 +307,18 @@ class ApiV2PoolsTest(ApiV2TestCase):
|
||||
[n['hostname'] for n in
|
||||
response.json['ns_records']])
|
||||
|
||||
def test_update_pool_ns_records_without_priority(self):
|
||||
pool = self.create_pool()
|
||||
body = {'ns_records': [
|
||||
{'hostname': 'new-ns1.example.org.'},
|
||||
{'hostname': 'new-ns2.example.org.'},
|
||||
]}
|
||||
url = '/pools/%s' % pool['id']
|
||||
# The missing "apriority" field triggers an object validation error
|
||||
response = self.client.patch_json(url, body, status=400)
|
||||
errmsg = response.json['errors']['errors'][0]['message']
|
||||
self.assertEqual("'priority' is a required property", errmsg)
|
||||
|
||||
def test_update_pool_attributes(self):
|
||||
# Create a pool
|
||||
pool = self.create_pool()
|
||||
|
@ -2911,6 +2911,15 @@ class CentralServiceTest(CentralTestCase):
|
||||
self.assertEqual(set([n.hostname for n in pool.ns_records]),
|
||||
set([n.data for n in ns_recordset.records]))
|
||||
|
||||
def test_update_pool_add_ns_record_without_priority(self):
|
||||
pool = self.create_pool(fixture=0)
|
||||
self.create_zone(pool_id=pool.id)
|
||||
new_ns_record = objects.PoolNsRecord(hostname='ns-new.example.org.')
|
||||
pool.ns_records.append(new_ns_record)
|
||||
# PoolNsRecord without "priority" triggers a DB exception
|
||||
with testtools.ExpectedException(db_exception.DBError):
|
||||
self.central_service.update_pool(self.admin_context, pool)
|
||||
|
||||
def test_update_pool_remove_ns_record(self):
|
||||
# Create a server pool and zone
|
||||
pool = self.create_pool(fixture=0)
|
||||
|
Loading…
Reference in New Issue
Block a user