Make readonly field tests use exception from oslo.versionedobjects
This cleans up a tactical change in the previous patch by removing the readonly exception from nova's module and modifying the tests that check for this behavior to catch the library's exception directly. Related to blueprint use-oslo-objects Change-Id: I49ef7f10ea73744e886d95423e49f86c8be93258
This commit is contained in:
parent
d8c129274f
commit
2a6d85bb00
|
@ -28,7 +28,6 @@ import sys
|
|||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import excutils
|
||||
from oslo_versionedobjects import exception as ovo_exc
|
||||
import six
|
||||
import webob.exc
|
||||
|
||||
|
@ -1520,11 +1519,6 @@ class IncompatibleObjectVersion(NovaException):
|
|||
'maximum supported version is: %(supported)s')
|
||||
|
||||
|
||||
# FIXME(danms): Remove this and convert existing object tests to catch
|
||||
# the oslo_versionedobjects exception themselves
|
||||
ReadOnlyFieldError = ovo_exc.ReadOnlyFieldError
|
||||
|
||||
|
||||
class ObjectActionError(NovaException):
|
||||
msg_fmt = _('Object action %(action)s failed because: %(reason)s')
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
import mock
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import timeutils
|
||||
from oslo_versionedobjects import exception as ovo_exc
|
||||
|
||||
from nova import db
|
||||
from nova import exception
|
||||
|
@ -307,7 +308,7 @@ class _TestComputeNodeObject(object):
|
|||
def test_set_id_failure(self, db_mock):
|
||||
compute = compute_node.ComputeNode(context=self.context)
|
||||
compute.create()
|
||||
self.assertRaises(exception.ReadOnlyFieldError, setattr,
|
||||
self.assertRaises(ovo_exc.ReadOnlyFieldError, setattr,
|
||||
compute, 'id', 124)
|
||||
|
||||
def test_destroy(self):
|
||||
|
|
|
@ -14,8 +14,9 @@
|
|||
|
||||
import mock
|
||||
|
||||
from oslo_versionedobjects import exception as ovo_exc
|
||||
|
||||
from nova import db
|
||||
from nova import exception
|
||||
from nova import objects
|
||||
from nova.tests.unit.objects import test_objects
|
||||
from nova.tests.unit.objects import test_security_group
|
||||
|
@ -81,7 +82,7 @@ class _TestSecurityGroupRuleObject(object):
|
|||
def test_set_id_failure(self, db_mock):
|
||||
rule = objects.SecurityGroupRule(context=self.context)
|
||||
rule.create()
|
||||
self.assertRaises(exception.ReadOnlyFieldError, setattr,
|
||||
self.assertRaises(ovo_exc.ReadOnlyFieldError, setattr,
|
||||
rule, 'id', 124)
|
||||
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
import mock
|
||||
from oslo_utils import timeutils
|
||||
from oslo_versionedobjects import exception as ovo_exc
|
||||
|
||||
from nova import db
|
||||
from nova import exception
|
||||
|
@ -138,7 +139,7 @@ class _TestServiceObject(object):
|
|||
def test_set_id_failure(self, db_mock):
|
||||
service_obj = service.Service(context=self.context)
|
||||
service_obj.create()
|
||||
self.assertRaises(exception.ReadOnlyFieldError, setattr,
|
||||
self.assertRaises(ovo_exc.ReadOnlyFieldError, setattr,
|
||||
service_obj, 'id', 124)
|
||||
|
||||
def _test_destroy(self):
|
||||
|
|
Loading…
Reference in New Issue