PR#1027: [kojihub] add strict parameter in getBuildNotification

Merges #1027
https://pagure.io/koji/pull-request/1027

Fixes: #1009
https://pagure.io/koji/issue/1009
getBuildNotification API call should raise GenericError exception for non existing notification ID
This commit is contained in:
Mike McLean 2018-08-08 10:09:52 -04:00
commit e05f871b4a

View file

@ -11011,15 +11011,17 @@ class RootExports(object):
userID = get_user(userID, strict=True)['id']
return get_build_notifications(userID)
def getBuildNotification(self, id):
"""Get the build notification with the given ID. Return None
if there is no notification with the given ID."""
def getBuildNotification(self, id, strict=False):
"""Get the build notification with the given ID.
If there is no notification with the given ID, when strict is True,
raise GenericError, else return None.
"""
fields = ('id', 'user_id', 'package_id', 'tag_id', 'success_only', 'email')
query = """SELECT %s
FROM build_notifications
WHERE id = %%(id)i
""" % ', '.join(fields)
return _singleRow(query, locals(), fields)
return _singleRow(query, locals(), fields, strict=strict)
def updateNotification(self, id, package_id, tag_id, success_only):
"""Update an existing build notification with new data. If the notification