Merge "Make central service tests py3 compatible"

This commit is contained in:
Jenkins 2017-07-12 21:15:58 +00:00 committed by Gerrit Code Review
commit 8902c4e129
3 changed files with 6 additions and 10 deletions

View File

@ -470,6 +470,8 @@ class Service(service.RPCService, service.Service):
return subzones
def _is_valid_ttl(self, context, ttl):
if ttl is None:
return
min_ttl = cfg.CONF['service:central'].min_ttl
if min_ttl is not None and ttl < int(min_ttl):
try:
@ -846,8 +848,7 @@ class Service(service.RPCService, service.Service):
self._is_valid_zone_name(context, zone.name)
# Ensure TTL is above the minimum
if zone.ttl is not None:
self._is_valid_ttl(context, zone.ttl)
self._is_valid_ttl(context, zone.ttl)
# Get a pool id
zone.pool_id = self.scheduler.schedule_zone(context, zone)
@ -1026,9 +1027,8 @@ class Service(service.RPCService, service.Service):
raise exceptions.BadRequest('Renaming a zone is not allowed')
# Ensure TTL is above the minimum
ttl = changes.get('ttl', None)
if ttl is not None:
self._is_valid_ttl(context, ttl)
ttl = changes.get('ttl')
self._is_valid_ttl(context, ttl)
return self._update_zone(context, zone, increment_serial, changes)
@ -1268,8 +1268,7 @@ class Service(service.RPCService, service.Service):
changes = recordset.obj_get_changes()
ttl = changes.get('ttl', None)
if ttl is not None:
self._is_valid_ttl(context, ttl)
self._is_valid_ttl(context, ttl)
# Ensure the recordset name and placement is valid
self._is_valid_recordset_name(context, zone, recordset.name)

View File

@ -1267,7 +1267,6 @@ class CentralZoneTestCase(CentralBasic):
self.service._is_valid_recordset_name = Mock()
self.service._is_valid_recordset_placement = Mock()
self.service._is_valid_recordset_placement_subzone = Mock()
self.service._is_valid_ttl = Mock()
self.service._update_zone_in_storage = Mock()
self.service._enforce_record_quota = mock.Mock()
@ -1291,7 +1290,6 @@ class CentralZoneTestCase(CentralBasic):
self.service._is_valid_recordset_placement_subzone.
call_args[0][2]
)
assert not self.service._is_valid_ttl.called
assert not self.service._update_zone_in_storage.called
assert self.service.storage.update_recordset.called
assert self.service._enforce_record_quota.called

View File

@ -1,4 +1,3 @@
# Blacklist of tests failing on Python 3
designate.tests.unit.test_central.test_basic
designate.tests.unit.test_pool
designate.tests.unit.test_producer.test_tasks