github_webhook: throw an exception on unhandled events types.

This commit is contained in:
Tomasz Kolek
2016-04-20 21:34:16 +02:00
committed by Tim Abbott
parent fafc9cb742
commit 09e40b27c2

View File

@@ -16,6 +16,10 @@ ZULIP_TEST_REPO_ID = 6893087
def is_test_repository(repository):
return repository['name'] == ZULIP_TEST_REPO_NAME and repository['id'] == ZULIP_TEST_REPO_ID
class UnknownEventType(Exception):
pass
def github_generic_subject(noun, topic_focus, blob):
# issue and pull_request objects have the same fields we're interested in
return "%s: %s %d: %s" % (topic_focus, noun, blob['number'], blob['title'])
@@ -113,6 +117,9 @@ def api_github_v2(user_profile, event, payload, branches, default_stream, commit
content += "\n\n~~~ quote\n%s\n~~~" % (comment['body'],)
else:
raise UnknownEventType(u'Event %s is unknown and cannot be handled' % (event,))
return target_stream, subject, content
@authenticated_api_view