Handle multiple samples per versioned notification
The notification_sample decorator is changed to handle attaching multiple sample files to a notification object. Change-Id: I4c3df17d93282f6946221da65d26d0ca3194d3df
This commit is contained in:
parent
6329d721ef
commit
8279b1ea2e
@ -51,9 +51,10 @@ class VersionedNotificationDirective(Directive):
|
||||
|
||||
payload_name = cls.fields['payload'].objname
|
||||
payload_cls = ovos[payload_name][0]
|
||||
|
||||
notifications.append((full_name(cls), full_name(payload_cls),
|
||||
cls.sample))
|
||||
for sample in cls.samples:
|
||||
notifications.append((full_name(cls),
|
||||
full_name(payload_cls),
|
||||
sample))
|
||||
return notifications
|
||||
|
||||
def _build_markup(self, notifications):
|
||||
|
@ -149,6 +149,9 @@ def notification_sample(sample):
|
||||
root.
|
||||
"""
|
||||
def wrap(cls):
|
||||
cls.sample = sample
|
||||
if not getattr(cls, 'samples', None):
|
||||
cls.samples = [sample]
|
||||
else:
|
||||
cls.samples.append(sample)
|
||||
return cls
|
||||
return wrap
|
||||
|
@ -64,6 +64,8 @@ class TestNotificationBase(test.NoDBTestCase):
|
||||
'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)
|
||||
class TestNotification(notification.NotificationBase):
|
||||
VERSION = '1.0'
|
||||
@ -246,6 +248,11 @@ class TestNotificationBase(test.NoDBTestCase):
|
||||
'nova_object.version': '1.0',
|
||||
'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 = {
|
||||
'EventType': '1.1-8291570eed00192197c7fa02ac677cd4',
|
||||
|
Loading…
Reference in New Issue
Block a user