Remove NotificationEventTypeError as not needed
The exception NotificationEventTypeError was used when an invalid status was used. But it is not possible to assign an invalid status without causing a ValueError. Add a unit test to show that changing status to an invalid value does raise a ValueError. Remove check for valid status value. Change-Id: I58fb50f963ca4a8e8d0185b9165c9bcda3bb7a25
This commit is contained in:
parent
77c7a710fc
commit
11fcf6b710
@ -611,11 +611,6 @@ class IncompleteLookup(Invalid):
|
|||||||
"is required")
|
"is required")
|
||||||
|
|
||||||
|
|
||||||
class NotificationEventTypeError(IronicException):
|
|
||||||
_msg_fmt = _('Expected "status" to be one of "start", "end", '
|
|
||||||
'"error", or "success", but got "%(status)s"')
|
|
||||||
|
|
||||||
|
|
||||||
class NotificationSchemaObjectError(IronicException):
|
class NotificationSchemaObjectError(IronicException):
|
||||||
_msg_fmt = _("Expected object %(obj)s when populating notification payload"
|
_msg_fmt = _("Expected object %(obj)s when populating notification payload"
|
||||||
" but got object %(source)s")
|
" but got object %(source)s")
|
||||||
|
@ -51,8 +51,6 @@ class EventType(base.IronicObject):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def to_event_type_field(self):
|
def to_event_type_field(self):
|
||||||
if self.status not in ['start', 'end', 'error', 'success']:
|
|
||||||
raise exception.NotificationEventTypeError(status=self.status)
|
|
||||||
parts = ['baremetal', self.object, self.action, self.status]
|
parts = ['baremetal', self.object, self.action, self.status]
|
||||||
return '.'.join(parts)
|
return '.'.join(parts)
|
||||||
|
|
||||||
|
@ -246,3 +246,11 @@ class TestNotificationBase(test_base.TestCase):
|
|||||||
self.assertRaises(ValueError,
|
self.assertRaises(ValueError,
|
||||||
notification.EventType, object="some_obj",
|
notification.EventType, object="some_obj",
|
||||||
action="some_action", status="invalid")
|
action="some_action", status="invalid")
|
||||||
|
|
||||||
|
def test_event_type_make_status_invalid(self):
|
||||||
|
def make_status_invalid():
|
||||||
|
event_type.status = "Roar"
|
||||||
|
|
||||||
|
event_type = notification.EventType(
|
||||||
|
object='test_object', action='test', status='start')
|
||||||
|
self.assertRaises(ValueError, make_status_invalid)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user