Change notificationworker to use a data interface

This commit is contained in:
Joseph Schorr 2017-07-12 15:50:47 +03:00
parent 8ec198228c
commit b6f1782642
10 changed files with 149 additions and 56 deletions

View file

@ -18,7 +18,7 @@ class TestCreate(unittest.TestCase):
class TestShouldPerform(unittest.TestCase):
def test_build_emptyjson(self):
notification_data = AttrDict({
'event_config_json': None,
'event_config_dict': None,
})
# No build data at all.
@ -26,7 +26,7 @@ class TestShouldPerform(unittest.TestCase):
def test_build_nofilter(self):
notification_data = AttrDict({
'event_config_json': '{}',
'event_config_dict': {},
})
# No build data at all.
@ -47,7 +47,7 @@ class TestShouldPerform(unittest.TestCase):
def test_build_emptyfilter(self):
notification_data = AttrDict({
'event_config_json': '{"ref-regex": ""}',
'event_config_dict': {"ref-regex": ""},
})
# No build data at all.
@ -68,7 +68,7 @@ class TestShouldPerform(unittest.TestCase):
def test_build_invalidfilter(self):
notification_data = AttrDict({
'event_config_json': '{"ref-regex": "]["}',
'event_config_dict': {"ref-regex": "]["},
})
# No build data at all.
@ -89,7 +89,7 @@ class TestShouldPerform(unittest.TestCase):
def test_build_withfilter(self):
notification_data = AttrDict({
'event_config_json': '{"ref-regex": "refs/heads/master"}',
'event_config_dict': {"ref-regex": "refs/heads/master"},
})
# No build data at all.
@ -117,7 +117,7 @@ class TestShouldPerform(unittest.TestCase):
def test_build_withwildcardfilter(self):
notification_data = AttrDict({
'event_config_json': '{"ref-regex": "refs/heads/.+"}',
'event_config_dict': {"ref-regex": "refs/heads/.+"},
})
# No build data at all.
@ -152,7 +152,7 @@ class TestShouldPerform(unittest.TestCase):
def test_vulnerability_notification_nolevel(self):
notification_data = AttrDict({
'event_config_json': '{}',
'event_config_dict': {},
})
# No level specified.
@ -161,7 +161,7 @@ class TestShouldPerform(unittest.TestCase):
def test_vulnerability_notification_nopvulninfo(self):
notification_data = AttrDict({
'event_config_json': '{"level": 3}',
'event_config_dict': {"level": 3},
})
# No vuln info.
@ -170,7 +170,7 @@ class TestShouldPerform(unittest.TestCase):
def test_vulnerability_notification_normal(self):
notification_data = AttrDict({
'event_config_json': '{"level": 3}',
'event_config_dict': {"level": 3},
})
info = {"vulnerability": {"priority": "Critical"}}