Notification method tests
This commit is contained in:
parent
5e5e191f87
commit
348b544f23
2 changed files with 165 additions and 5 deletions
|
@ -57,7 +57,7 @@ class NotificationMethod(object):
|
|||
"""
|
||||
Performs the notification method.
|
||||
|
||||
notification_obj: The noticication namedtuple.
|
||||
notification_obj: The notification namedtuple.
|
||||
event_handler: The NotificationEvent handler.
|
||||
notification_data: The dict of notification data placed in the queue.
|
||||
"""
|
||||
|
@ -83,7 +83,9 @@ class QuayNotificationMethod(NotificationMethod):
|
|||
raise CannotValidateNotificationMethodException(err_message)
|
||||
|
||||
def find_targets(self, repository, config_data):
|
||||
target_info = config_data['target']
|
||||
target_info = config_data.get('target', None)
|
||||
if not target_info or not target_info.get('kind'):
|
||||
return (True, 'Missing target', [])
|
||||
|
||||
if target_info['kind'] == 'user':
|
||||
target = model.user.get_nonrobot_user(target_info['name'])
|
||||
|
@ -93,9 +95,9 @@ class QuayNotificationMethod(NotificationMethod):
|
|||
|
||||
return (True, None, [target])
|
||||
elif target_info['kind'] == 'org':
|
||||
target = model.organization.get_organization(target_info['name'])
|
||||
if not target:
|
||||
# Just to be safe.
|
||||
try:
|
||||
target = model.organization.get_organization(target_info['name'])
|
||||
except model.organization.InvalidOrganizationException:
|
||||
return (True, 'Unknown organization %s' % target_info['name'], None)
|
||||
|
||||
# Only repositories under the organization can cause notifications to that org.
|
||||
|
|
Reference in a new issue