From 6fffc22b8ae36366fe3fec7c8fe9336b2ed92777 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Wed, 21 Sep 2016 14:59:01 -0400 Subject: [PATCH] Fix build should_perform for empty JSON --- endpoints/notificationevent.py | 3 +++ test/test_notifications.py | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/endpoints/notificationevent.py b/endpoints/notificationevent.py index 8d720d986..2f7fb34fb 100644 --- a/endpoints/notificationevent.py +++ b/endpoints/notificationevent.py @@ -156,6 +156,9 @@ class BaseBuildEvent(NotificationEvent): return None def should_perform(self, event_data, notification_data): + if not notification_data.event_config_json: + return True + event_config = json.loads(notification_data.event_config_json) ref_regex = event_config.get('ref-regex') or None if ref_regex is None: diff --git a/test/test_notifications.py b/test/test_notifications.py index 301fcea26..336670261 100644 --- a/test/test_notifications.py +++ b/test/test_notifications.py @@ -13,6 +13,14 @@ class TestCreate(unittest.TestCase): class TestShouldPerform(unittest.TestCase): + def test_build_emptyjson(self): + notification_data = AttrDict({ + 'event_config_json': None, + }) + + # No build data at all. + self.assertTrue(BuildSuccessEvent().should_perform({}, notification_data)) + def test_build_nofilter(self): notification_data = AttrDict({ 'event_config_json': '{}',