Handle the case where we have lookup_user but no username

This commit is contained in:
Joseph Schorr 2015-09-28 17:12:56 -04:00
parent c4f938898a
commit eaf81959f5
2 changed files with 26 additions and 1 deletions

View file

@ -171,6 +171,30 @@ class TestPrepareTrigger(unittest.TestCase):
self.assertSchema('github_webhook', expected, gh_webhook, lookup_user=lookup_user)
def test_github_webhook_payload_missing_fields_with_lookup(self):
expected = {
'commit': u'410f4cdf8ff09b87f245b13845e8497f90b90a4c',
'ref': u'refs/heads/master',
'git_url': u'git@github.com:josephschorr/anothertest.git',
'commit_info': {
'url': u'https://github.com/josephschorr/anothertest/commit/410f4cdf8ff09b87f245b13845e8497f90b90a4c',
'date': u'2015-09-11T14:26:16-04:00',
'message': u'Update Dockerfile'
},
}
def lookup_user(username):
if not username:
raise Exception('Fail!')
return {
'html_url': 'http://github.com/josephschorr',
'avatar_url': 'http://some/avatar/url'
}
self.assertSchema('github_webhook_missing', expected, gh_webhook, lookup_user=lookup_user)
def test_gitlab_webhook_payload(self):
expected = {
'commit': u'fb88379ee45de28a0a4590fddcbd8eff8b36026e',