Add a test for missing optional fields in prepare trigger
This commit is contained in:
parent
8e4a3af590
commit
97a478e05b
2 changed files with 153 additions and 0 deletions
|
@ -159,6 +159,26 @@ class TestPrepareTrigger(unittest.TestCase):
|
|||
validate(created, METADATA_SCHEMA)
|
||||
|
||||
|
||||
def test_github_webhook_payload_missing_fields(self):
|
||||
with open('test/triggerjson/github_webhook_missing.json') as f:
|
||||
payload = json.loads(f.read())
|
||||
|
||||
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'
|
||||
},
|
||||
}
|
||||
|
||||
created = gh_webhook(payload)
|
||||
self.assertEquals(expected, created)
|
||||
validate(created, METADATA_SCHEMA)
|
||||
|
||||
|
||||
def test_gitlab_webhook_payload_with_lookup(self):
|
||||
with open('test/triggerjson/gitlab_webhook.json') as f:
|
||||
payload = json.loads(f.read())
|
||||
|
|
133
test/triggerjson/github_webhook_missing.json
Normal file
133
test/triggerjson/github_webhook_missing.json
Normal file
|
@ -0,0 +1,133 @@
|
|||
{
|
||||
"ref": "refs/heads/master",
|
||||
"before": "9ea43cab474709d4a61afb7e3340de1ffc405b41",
|
||||
"after": "410f4cdf8ff09b87f245b13845e8497f90b90a4c",
|
||||
"created": false,
|
||||
"deleted": false,
|
||||
"forced": false,
|
||||
"base_ref": null,
|
||||
"compare": "https://github.com/josephschorr/anothertest/compare/9ea43cab4747...410f4cdf8ff0",
|
||||
"commits": [
|
||||
{
|
||||
"id": "410f4cdf8ff09b87f245b13845e8497f90b90a4c",
|
||||
"distinct": true,
|
||||
"message": "Update Dockerfile",
|
||||
"timestamp": "2015-09-11T14:26:16-04:00",
|
||||
"url": "https://github.com/josephschorr/anothertest/commit/410f4cdf8ff09b87f245b13845e8497f90b90a4c",
|
||||
"added": [],
|
||||
"removed": [],
|
||||
"modified": [
|
||||
"Dockerfile"
|
||||
]
|
||||
}
|
||||
],
|
||||
"head_commit": {
|
||||
"id": "410f4cdf8ff09b87f245b13845e8497f90b90a4c",
|
||||
"distinct": true,
|
||||
"message": "Update Dockerfile",
|
||||
"timestamp": "2015-09-11T14:26:16-04:00",
|
||||
"url": "https://github.com/josephschorr/anothertest/commit/410f4cdf8ff09b87f245b13845e8497f90b90a4c",
|
||||
"added": [],
|
||||
"removed": [],
|
||||
"modified": [
|
||||
"Dockerfile"
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
"id": 34876107,
|
||||
"name": "anothertest",
|
||||
"full_name": "josephschorr/anothertest",
|
||||
"owner": {
|
||||
"name": "josephschorr",
|
||||
"email": "josephschorr@users.noreply.github.com"
|
||||
},
|
||||
"private": false,
|
||||
"html_url": "https://github.com/josephschorr/anothertest",
|
||||
"description": "",
|
||||
"fork": false,
|
||||
"url": "https://github.com/josephschorr/anothertest",
|
||||
"forks_url": "https://api.github.com/repos/josephschorr/anothertest/forks",
|
||||
"keys_url": "https://api.github.com/repos/josephschorr/anothertest/keys{/key_id}",
|
||||
"collaborators_url": "https://api.github.com/repos/josephschorr/anothertest/collaborators{/collaborator}",
|
||||
"teams_url": "https://api.github.com/repos/josephschorr/anothertest/teams",
|
||||
"hooks_url": "https://api.github.com/repos/josephschorr/anothertest/hooks",
|
||||
"issue_events_url": "https://api.github.com/repos/josephschorr/anothertest/issues/events{/number}",
|
||||
"events_url": "https://api.github.com/repos/josephschorr/anothertest/events",
|
||||
"assignees_url": "https://api.github.com/repos/josephschorr/anothertest/assignees{/user}",
|
||||
"branches_url": "https://api.github.com/repos/josephschorr/anothertest/branches{/branch}",
|
||||
"tags_url": "https://api.github.com/repos/josephschorr/anothertest/tags",
|
||||
"blobs_url": "https://api.github.com/repos/josephschorr/anothertest/git/blobs{/sha}",
|
||||
"git_tags_url": "https://api.github.com/repos/josephschorr/anothertest/git/tags{/sha}",
|
||||
"git_refs_url": "https://api.github.com/repos/josephschorr/anothertest/git/refs{/sha}",
|
||||
"trees_url": "https://api.github.com/repos/josephschorr/anothertest/git/trees{/sha}",
|
||||
"statuses_url": "https://api.github.com/repos/josephschorr/anothertest/statuses/{sha}",
|
||||
"languages_url": "https://api.github.com/repos/josephschorr/anothertest/languages",
|
||||
"stargazers_url": "https://api.github.com/repos/josephschorr/anothertest/stargazers",
|
||||
"contributors_url": "https://api.github.com/repos/josephschorr/anothertest/contributors",
|
||||
"subscribers_url": "https://api.github.com/repos/josephschorr/anothertest/subscribers",
|
||||
"subscription_url": "https://api.github.com/repos/josephschorr/anothertest/subscription",
|
||||
"commits_url": "https://api.github.com/repos/josephschorr/anothertest/commits{/sha}",
|
||||
"git_commits_url": "https://api.github.com/repos/josephschorr/anothertest/git/commits{/sha}",
|
||||
"comments_url": "https://api.github.com/repos/josephschorr/anothertest/comments{/number}",
|
||||
"issue_comment_url": "https://api.github.com/repos/josephschorr/anothertest/issues/comments{/number}",
|
||||
"contents_url": "https://api.github.com/repos/josephschorr/anothertest/contents/{+path}",
|
||||
"compare_url": "https://api.github.com/repos/josephschorr/anothertest/compare/{base}...{head}",
|
||||
"merges_url": "https://api.github.com/repos/josephschorr/anothertest/merges",
|
||||
"archive_url": "https://api.github.com/repos/josephschorr/anothertest/{archive_format}{/ref}",
|
||||
"downloads_url": "https://api.github.com/repos/josephschorr/anothertest/downloads",
|
||||
"issues_url": "https://api.github.com/repos/josephschorr/anothertest/issues{/number}",
|
||||
"pulls_url": "https://api.github.com/repos/josephschorr/anothertest/pulls{/number}",
|
||||
"milestones_url": "https://api.github.com/repos/josephschorr/anothertest/milestones{/number}",
|
||||
"notifications_url": "https://api.github.com/repos/josephschorr/anothertest/notifications{?since,all,participating}",
|
||||
"labels_url": "https://api.github.com/repos/josephschorr/anothertest/labels{/name}",
|
||||
"releases_url": "https://api.github.com/repos/josephschorr/anothertest/releases{/id}",
|
||||
"created_at": 1430426945,
|
||||
"updated_at": "2015-04-30T20:49:05Z",
|
||||
"pushed_at": 1441995976,
|
||||
"git_url": "git://github.com/josephschorr/anothertest.git",
|
||||
"ssh_url": "git@github.com:josephschorr/anothertest.git",
|
||||
"clone_url": "https://github.com/josephschorr/anothertest.git",
|
||||
"svn_url": "https://github.com/josephschorr/anothertest",
|
||||
"homepage": null,
|
||||
"size": 144,
|
||||
"stargazers_count": 0,
|
||||
"watchers_count": 0,
|
||||
"language": null,
|
||||
"has_issues": true,
|
||||
"has_downloads": true,
|
||||
"has_wiki": true,
|
||||
"has_pages": false,
|
||||
"forks_count": 0,
|
||||
"mirror_url": null,
|
||||
"open_issues_count": 0,
|
||||
"forks": 0,
|
||||
"open_issues": 0,
|
||||
"watchers": 0,
|
||||
"default_branch": "master",
|
||||
"stargazers": 0,
|
||||
"master_branch": "master"
|
||||
},
|
||||
"pusher": {
|
||||
"name": "josephschorr",
|
||||
"email": "josephschorr@users.noreply.github.com"
|
||||
},
|
||||
"sender": {
|
||||
"login": "josephschorr",
|
||||
"id": 4073002,
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/4073002?v=3",
|
||||
"gravatar_id": "",
|
||||
"url": "https://api.github.com/users/josephschorr",
|
||||
"html_url": "https://github.com/josephschorr",
|
||||
"followers_url": "https://api.github.com/users/josephschorr/followers",
|
||||
"following_url": "https://api.github.com/users/josephschorr/following{/other_user}",
|
||||
"gists_url": "https://api.github.com/users/josephschorr/gists{/gist_id}",
|
||||
"starred_url": "https://api.github.com/users/josephschorr/starred{/owner}{/repo}",
|
||||
"subscriptions_url": "https://api.github.com/users/josephschorr/subscriptions",
|
||||
"organizations_url": "https://api.github.com/users/josephschorr/orgs",
|
||||
"repos_url": "https://api.github.com/users/josephschorr/repos",
|
||||
"events_url": "https://api.github.com/users/josephschorr/events{/privacy}",
|
||||
"received_events_url": "https://api.github.com/users/josephschorr/received_events",
|
||||
"type": "User",
|
||||
"site_admin": false
|
||||
}
|
||||
}
|
Reference in a new issue