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:
John L. Villalovos 2016-09-16 14:31:57 -07:00
parent 77c7a710fc
commit 11fcf6b710
3 changed files with 8 additions and 7 deletions

View File

@ -611,11 +611,6 @@ class IncompleteLookup(Invalid):
"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):
_msg_fmt = _("Expected object %(obj)s when populating notification payload"
" but got object %(source)s")

View File

@ -51,8 +51,6 @@ class EventType(base.IronicObject):
}
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]
return '.'.join(parts)

View File

@ -246,3 +246,11 @@ class TestNotificationBase(test_base.TestCase):
self.assertRaises(ValueError,
notification.EventType, object="some_obj",
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)