From 3813d0d23d819e0290549dc377684a99410bca5c Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Fri, 10 Mar 2017 11:26:12 -0500 Subject: [PATCH] Add tests for all notification event calls --- endpoints/test/test_notificationevent.py | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 endpoints/test/test_notificationevent.py diff --git a/endpoints/test/test_notificationevent.py b/endpoints/test/test_notificationevent.py new file mode 100644 index 000000000..65497f20c --- /dev/null +++ b/endpoints/test/test_notificationevent.py @@ -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)