Merge pull request #1860 from coreos-inc/notification-issue-json

Fix build should_perform for empty JSON
This commit is contained in:
josephschorr 2016-09-21 15:02:11 -04:00 committed by GitHub
commit c0ae8e301b
2 changed files with 11 additions and 0 deletions

View file

@ -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:

View file

@ -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': '{}',