Merge "Handle multiple samples per versioned notification"
This commit is contained in:
commit
7cfe2f37ae
@ -51,9 +51,10 @@ class VersionedNotificationDirective(Directive):
|
|||||||
|
|
||||||
payload_name = cls.fields['payload'].objname
|
payload_name = cls.fields['payload'].objname
|
||||||
payload_cls = ovos[payload_name][0]
|
payload_cls = ovos[payload_name][0]
|
||||||
|
for sample in cls.samples:
|
||||||
notifications.append((full_name(cls), full_name(payload_cls),
|
notifications.append((full_name(cls),
|
||||||
cls.sample))
|
full_name(payload_cls),
|
||||||
|
sample))
|
||||||
return notifications
|
return notifications
|
||||||
|
|
||||||
def _build_markup(self, notifications):
|
def _build_markup(self, notifications):
|
||||||
|
@ -149,6 +149,9 @@ def notification_sample(sample):
|
|||||||
root.
|
root.
|
||||||
"""
|
"""
|
||||||
def wrap(cls):
|
def wrap(cls):
|
||||||
cls.sample = sample
|
if not getattr(cls, 'samples', None):
|
||||||
|
cls.samples = [sample]
|
||||||
|
else:
|
||||||
|
cls.samples.append(sample)
|
||||||
return cls
|
return cls
|
||||||
return wrap
|
return wrap
|
||||||
|
@ -64,6 +64,8 @@ class TestNotificationBase(test.NoDBTestCase):
|
|||||||
'extra_field': fields.StringField(), # filled by ctor
|
'extra_field': fields.StringField(), # filled by ctor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@notification.notification_sample('test-update-1.json')
|
||||||
|
@notification.notification_sample('test-update-2.json')
|
||||||
@base.NovaObjectRegistry.register_if(False)
|
@base.NovaObjectRegistry.register_if(False)
|
||||||
class TestNotification(notification.NotificationBase):
|
class TestNotification(notification.NotificationBase):
|
||||||
VERSION = '1.0'
|
VERSION = '1.0'
|
||||||
@ -246,6 +248,11 @@ class TestNotificationBase(test.NoDBTestCase):
|
|||||||
'nova_object.version': '1.0',
|
'nova_object.version': '1.0',
|
||||||
'nova_object.namespace': 'nova'})
|
'nova_object.namespace': 'nova'})
|
||||||
|
|
||||||
|
def test_sample_decorator(self):
|
||||||
|
self.assertEqual(2, len(self.TestNotification.samples))
|
||||||
|
self.assertIn('test-update-1.json', self.TestNotification.samples)
|
||||||
|
self.assertIn('test-update-2.json', self.TestNotification.samples)
|
||||||
|
|
||||||
|
|
||||||
notification_object_data = {
|
notification_object_data = {
|
||||||
'EventType': '1.1-8291570eed00192197c7fa02ac677cd4',
|
'EventType': '1.1-8291570eed00192197c7fa02ac677cd4',
|
||||||
|
Loading…
Reference in New Issue
Block a user