Change get_sample_data API to not require the custom notification tuple
This commit is contained in:
parent
e7dbc4ee91
commit
e7fec9dd20
3 changed files with 21 additions and 31 deletions
|
@ -40,7 +40,7 @@ class NotificationEvent(object):
|
|||
'notification_data': notification_data
|
||||
})
|
||||
|
||||
def get_sample_data(self, notification):
|
||||
def get_sample_data(self, repository, event_config):
|
||||
"""
|
||||
Returns sample data for testing the raising of this notification, with an example notification.
|
||||
"""
|
||||
|
@ -95,8 +95,8 @@ class RepoPushEvent(NotificationEvent):
|
|||
def get_summary(self, event_data, notification_data):
|
||||
return 'Repository %s updated' % (event_data['repository'])
|
||||
|
||||
def get_sample_data(self, notification):
|
||||
return build_event_data(notification.repository, {
|
||||
def get_sample_data(self, repository, event_config):
|
||||
return build_event_data(repository, {
|
||||
'updated_tags': {'latest': 'someimageid', 'foo': 'anotherimage'},
|
||||
'pruned_image_count': 3
|
||||
})
|
||||
|
@ -129,10 +129,9 @@ class VulnerabilityFoundEvent(NotificationEvent):
|
|||
|
||||
return 'info'
|
||||
|
||||
def get_sample_data(self, notification):
|
||||
event_config = notification.event_config_dict
|
||||
def get_sample_data(self, repository, event_config):
|
||||
level = event_config.get(VulnerabilityFoundEvent.CONFIG_LEVEL, 'Critical')
|
||||
return build_event_data(notification.repository, {
|
||||
return build_event_data(repository, {
|
||||
'tags': ['latest', 'prod', 'foo', 'bar', 'baz'],
|
||||
'image': 'some-image-id',
|
||||
'vulnerability': {
|
||||
|
@ -217,9 +216,9 @@ class BuildQueueEvent(BaseBuildEvent):
|
|||
def get_level(self, event_data, notification_data):
|
||||
return 'info'
|
||||
|
||||
def get_sample_data(self, notification):
|
||||
def get_sample_data(self, repository, event_config):
|
||||
build_uuid = 'fake-build-id'
|
||||
return build_event_data(notification.repository, {
|
||||
return build_event_data(repository, {
|
||||
'is_manual': False,
|
||||
'build_id': build_uuid,
|
||||
'build_name': 'some-fake-build',
|
||||
|
@ -255,9 +254,9 @@ class BuildStartEvent(BaseBuildEvent):
|
|||
def get_level(self, event_data, notification_data):
|
||||
return 'info'
|
||||
|
||||
def get_sample_data(self, notification):
|
||||
def get_sample_data(self, repository, event_config):
|
||||
build_uuid = 'fake-build-id'
|
||||
return build_event_data(notification.repository, {
|
||||
return build_event_data(repository, {
|
||||
'build_id': build_uuid,
|
||||
'build_name': 'some-fake-build',
|
||||
'docker_tags': ['latest', 'foo', 'bar'],
|
||||
|
@ -282,9 +281,9 @@ class BuildSuccessEvent(BaseBuildEvent):
|
|||
def get_level(self, event_data, notification_data):
|
||||
return 'success'
|
||||
|
||||
def get_sample_data(self, notification):
|
||||
def get_sample_data(self, repository, event_config):
|
||||
build_uuid = 'fake-build-id'
|
||||
return build_event_data(notification.repository, {
|
||||
return build_event_data(repository, {
|
||||
'build_id': build_uuid,
|
||||
'build_name': 'some-fake-build',
|
||||
'docker_tags': ['latest', 'foo', 'bar'],
|
||||
|
@ -310,9 +309,9 @@ class BuildFailureEvent(BaseBuildEvent):
|
|||
def get_level(self, event_data, notification_data):
|
||||
return 'error'
|
||||
|
||||
def get_sample_data(self, notification):
|
||||
def get_sample_data(self, repository, event_config):
|
||||
build_uuid = 'fake-build-id'
|
||||
return build_event_data(notification.repository, {
|
||||
return build_event_data(repository, {
|
||||
'build_id': build_uuid,
|
||||
'build_name': 'some-fake-build',
|
||||
'docker_tags': ['latest', 'foo', 'bar'],
|
||||
|
@ -349,9 +348,9 @@ class BuildCancelledEvent(BaseBuildEvent):
|
|||
def get_level(self, event_data, notification_data):
|
||||
return 'info'
|
||||
|
||||
def get_sample_data(self, notification):
|
||||
def get_sample_data(self, repository, event_config):
|
||||
build_uuid = 'fake-build-id'
|
||||
return build_event_data(notification.repository, {
|
||||
return build_event_data(repository, {
|
||||
'build_id': build_uuid,
|
||||
'build_name': 'some-fake-build',
|
||||
'docker_tags': ['latest', 'foo', 'bar'],
|
||||
|
|
Reference in a new issue