Add tests for all notification event calls
This commit is contained in:
parent
48db77b521
commit
3813d0d23d
1 changed files with 33 additions and 0 deletions
33
endpoints/test/test_notificationevent.py
Normal file
33
endpoints/test/test_notificationevent.py
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import json
|
||||||
|
|
||||||
|
from endpoints.notificationevent import NotificationEvent
|
||||||
|
from endpoints.test.fixtures import app, appconfig, database_uri, init_db_path, sqlitedb_file
|
||||||
|
|
||||||
|
from util.morecollections import AttrDict
|
||||||
|
|
||||||
|
def test_all_notifications(app):
|
||||||
|
# Create a test notification.
|
||||||
|
test_notification = AttrDict({
|
||||||
|
'repository': AttrDict({
|
||||||
|
'namespace_user': AttrDict(dict(username='foo')),
|
||||||
|
'name': 'bar',
|
||||||
|
}),
|
||||||
|
'event_config_json': json.dumps({
|
||||||
|
'level': 'low',
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
|
||||||
|
for subc in NotificationEvent.__subclasses__():
|
||||||
|
if subc.event_name() is not None:
|
||||||
|
# Create the notification event.
|
||||||
|
found = NotificationEvent.get_event(subc.event_name())
|
||||||
|
sample_data = found.get_sample_data(test_notification)
|
||||||
|
|
||||||
|
# Make sure all calls succeed.
|
||||||
|
notification_data = {
|
||||||
|
'performer_data': {},
|
||||||
|
}
|
||||||
|
|
||||||
|
found.get_level(sample_data, notification_data)
|
||||||
|
found.get_summary(sample_data, notification_data)
|
||||||
|
found.get_message(sample_data, notification_data)
|
Reference in a new issue