@@ -131,151 +131,147 @@ def test_request_had_headers(webhook, handler, mock_request):
131131
132132# From https://developer.github.com/v3/activity/events/types/#pushevent
133133example_push_event = {
134- "ref" : "refs/tags/simple-tag" ,
135- "before" : "a10867b14bb761a232cd80139fbd4c0d33264240" ,
136- "after" : "0000000000000000000000000000000000000000" ,
137- "created" : False ,
138- "deleted" : True ,
139- "forced" : False ,
140- "base_ref" : None ,
141- "compare" : "https://github.com/Codertocat/Hello-World/compare/a10867b14bb7...000000000000" ,
142- "commits" : [
143-
144- ],
145- "head_commit" : None ,
146- "repository" : {
147- "id" : 135493233 ,
148- "node_id" : "MDEwOlJlcG9zaXRvcnkxMzU0OTMyMzM=" ,
149- "name" : "Hello-World" ,
150- "full_name" : "Codertocat/Hello-World" ,
151- "owner" : {
152- "name" : "Codertocat" ,
153- "email" : "21031067+Codertocat@users.noreply.github.com" ,
154- "login" : "Codertocat" ,
155- "id" : 21031067 ,
156- "node_id" : "MDQ6VXNlcjIxMDMxMDY3" ,
157- "avatar_url" : "https://avatars1.githubusercontent.com/u/21031067?v=4" ,
158- "gravatar_id" : "" ,
159- "url" : "https://api.github.com/users/Codertocat" ,
160- "html_url" : "https://github.com/Codertocat" ,
161- "followers_url" : "https://api.github.com/users/Codertocat/followers" ,
162- "following_url" : "https://api.github.com/users/Codertocat/following{/other_user}" ,
163- "gists_url" : "https://api.github.com/users/Codertocat/gists{/gist_id}" ,
164- "starred_url" : "https://api.github.com/users/Codertocat/starred{/owner}{/repo}" ,
165- "subscriptions_url" : "https://api.github.com/users/Codertocat/subscriptions" ,
166- "organizations_url" : "https://api.github.com/users/Codertocat/orgs" ,
167- "repos_url" : "https://api.github.com/users/Codertocat/repos" ,
168- "events_url" : "https://api.github.com/users/Codertocat/events{/privacy}" ,
169- "received_events_url" : "https://api.github.com/users/Codertocat/received_events" ,
170- "type" : "User" ,
171- "site_admin" : False
134+ "ref" : "refs/tags/simple-tag" ,
135+ "before" : "a10867b14bb761a232cd80139fbd4c0d33264240" ,
136+ "after" : "0000000000000000000000000000000000000000" ,
137+ "created" : False ,
138+ "deleted" : True ,
139+ "forced" : False ,
140+ "base_ref" : None ,
141+ "compare" : "https://github.com/Codertocat/Hello-World/compare/a10867b14bb7...000000000000" ,
142+ "commits" : [],
143+ "head_commit" : None ,
144+ "repository" : {
145+ "id" : 135493233 ,
146+ "node_id" : "MDEwOlJlcG9zaXRvcnkxMzU0OTMyMzM=" ,
147+ "name" : "Hello-World" ,
148+ "full_name" : "Codertocat/Hello-World" ,
149+ "owner" : {
150+ "name" : "Codertocat" ,
151+ "email" : "21031067+Codertocat@users.noreply.github.com" ,
152+ "login" : "Codertocat" ,
153+ "id" : 21031067 ,
154+ "node_id" : "MDQ6VXNlcjIxMDMxMDY3" ,
155+ "avatar_url" : "https://avatars1.githubusercontent.com/u/21031067?v=4" ,
156+ "gravatar_id" : "" ,
157+ "url" : "https://api.github.com/users/Codertocat" ,
158+ "html_url" : "https://github.com/Codertocat" ,
159+ "followers_url" : "https://api.github.com/users/Codertocat/followers" ,
160+ "following_url" : "https://api.github.com/users/Codertocat/following{/other_user}" ,
161+ "gists_url" : "https://api.github.com/users/Codertocat/gists{/gist_id}" ,
162+ "starred_url" : "https://api.github.com/users/Codertocat/starred{/owner}{/repo}" ,
163+ "subscriptions_url" : "https://api.github.com/users/Codertocat/subscriptions" ,
164+ "organizations_url" : "https://api.github.com/users/Codertocat/orgs" ,
165+ "repos_url" : "https://api.github.com/users/Codertocat/repos" ,
166+ "events_url" : "https://api.github.com/users/Codertocat/events{/privacy}" ,
167+ "received_events_url" : "https://api.github.com/users/Codertocat/received_events" ,
168+ "type" : "User" ,
169+ "site_admin" : False ,
170+ },
171+ "private" : False ,
172+ "html_url" : "https://github.com/Codertocat/Hello-World" ,
173+ "description" : None ,
174+ "fork" : False ,
175+ "url" : "https://github.com/Codertocat/Hello-World" ,
176+ "forks_url" : "https://api.github.com/repos/Codertocat/Hello-World/forks" ,
177+ "keys_url" : "https://api.github.com/repos/Codertocat/Hello-World/keys{/key_id}" ,
178+ "collaborators_url" : "https://api.github.com/repos/Codertocat/Hello-World/collaborators{/collaborator}" ,
179+ "teams_url" : "https://api.github.com/repos/Codertocat/Hello-World/teams" ,
180+ "hooks_url" : "https://api.github.com/repos/Codertocat/Hello-World/hooks" ,
181+ "issue_events_url" : "https://api.github.com/repos/Codertocat/Hello-World/issues/events{/number}" ,
182+ "events_url" : "https://api.github.com/repos/Codertocat/Hello-World/events" ,
183+ "assignees_url" : "https://api.github.com/repos/Codertocat/Hello-World/assignees{/user}" ,
184+ "branches_url" : "https://api.github.com/repos/Codertocat/Hello-World/branches{/branch}" ,
185+ "tags_url" : "https://api.github.com/repos/Codertocat/Hello-World/tags" ,
186+ "blobs_url" : "https://api.github.com/repos/Codertocat/Hello-World/git/blobs{/sha}" ,
187+ "git_tags_url" : "https://api.github.com/repos/Codertocat/Hello-World/git/tags{/sha}" ,
188+ "git_refs_url" : "https://api.github.com/repos/Codertocat/Hello-World/git/refs{/sha}" ,
189+ "trees_url" : "https://api.github.com/repos/Codertocat/Hello-World/git/trees{/sha}" ,
190+ "statuses_url" : "https://api.github.com/repos/Codertocat/Hello-World/statuses/{sha}" ,
191+ "languages_url" : "https://api.github.com/repos/Codertocat/Hello-World/languages" ,
192+ "stargazers_url" : "https://api.github.com/repos/Codertocat/Hello-World/stargazers" ,
193+ "contributors_url" : "https://api.github.com/repos/Codertocat/Hello-World/contributors" ,
194+ "subscribers_url" : "https://api.github.com/repos/Codertocat/Hello-World/subscribers" ,
195+ "subscription_url" : "https://api.github.com/repos/Codertocat/Hello-World/subscription" ,
196+ "commits_url" : "https://api.github.com/repos/Codertocat/Hello-World/commits{/sha}" ,
197+ "git_commits_url" : "https://api.github.com/repos/Codertocat/Hello-World/git/commits{/sha}" ,
198+ "comments_url" : "https://api.github.com/repos/Codertocat/Hello-World/comments{/number}" ,
199+ "issue_comment_url" : "https://api.github.com/repos/Codertocat/Hello-World/issues/comments{/number}" ,
200+ "contents_url" : "https://api.github.com/repos/Codertocat/Hello-World/contents/{+path}" ,
201+ "compare_url" : "https://api.github.com/repos/Codertocat/Hello-World/compare/{base}...{head}" ,
202+ "merges_url" : "https://api.github.com/repos/Codertocat/Hello-World/merges" ,
203+ "archive_url" : "https://api.github.com/repos/Codertocat/Hello-World/{archive_format}{/ref}" ,
204+ "downloads_url" : "https://api.github.com/repos/Codertocat/Hello-World/downloads" ,
205+ "issues_url" : "https://api.github.com/repos/Codertocat/Hello-World/issues{/number}" ,
206+ "pulls_url" : "https://api.github.com/repos/Codertocat/Hello-World/pulls{/number}" ,
207+ "milestones_url" : "https://api.github.com/repos/Codertocat/Hello-World/milestones{/number}" ,
208+ "notifications_url" : "https://api.github.com/repos/Codertocat/Hello-World/notifications{?since,all,participating}" ,
209+ "labels_url" : "https://api.github.com/repos/Codertocat/Hello-World/labels{/name}" ,
210+ "releases_url" : "https://api.github.com/repos/Codertocat/Hello-World/releases{/id}" ,
211+ "deployments_url" : "https://api.github.com/repos/Codertocat/Hello-World/deployments" ,
212+ "created_at" : 1527711484 ,
213+ "updated_at" : "2018-05-30T20:18:35Z" ,
214+ "pushed_at" : 1527711528 ,
215+ "git_url" : "git://github.com/Codertocat/Hello-World.git" ,
216+ "ssh_url" : "git@github.com:Codertocat/Hello-World.git" ,
217+ "clone_url" : "https://github.com/Codertocat/Hello-World.git" ,
218+ "svn_url" : "https://github.com/Codertocat/Hello-World" ,
219+ "homepage" : None ,
220+ "size" : 0 ,
221+ "stargazers_count" : 0 ,
222+ "watchers_count" : 0 ,
223+ "language" : None ,
224+ "has_issues" : True ,
225+ "has_projects" : True ,
226+ "has_downloads" : True ,
227+ "has_wiki" : True ,
228+ "has_pages" : True ,
229+ "forks_count" : 0 ,
230+ "mirror_url" : None ,
231+ "archived" : False ,
232+ "open_issues_count" : 2 ,
233+ "license" : None ,
234+ "forks" : 0 ,
235+ "open_issues" : 2 ,
236+ "watchers" : 0 ,
237+ "default_branch" : "master" ,
238+ "stargazers" : 0 ,
239+ "master_branch" : "master" ,
240+ },
241+ "pusher" : {"name" : "Codertocat" , "email" : "21031067+Codertocat@users.noreply.github.com" },
242+ "sender" : {
243+ "login" : "Codertocat" ,
244+ "id" : 21031067 ,
245+ "node_id" : "MDQ6VXNlcjIxMDMxMDY3" ,
246+ "avatar_url" : "https://avatars1.githubusercontent.com/u/21031067?v=4" ,
247+ "gravatar_id" : "" ,
248+ "url" : "https://api.github.com/users/Codertocat" ,
249+ "html_url" : "https://github.com/Codertocat" ,
250+ "followers_url" : "https://api.github.com/users/Codertocat/followers" ,
251+ "following_url" : "https://api.github.com/users/Codertocat/following{/other_user}" ,
252+ "gists_url" : "https://api.github.com/users/Codertocat/gists{/gist_id}" ,
253+ "starred_url" : "https://api.github.com/users/Codertocat/starred{/owner}{/repo}" ,
254+ "subscriptions_url" : "https://api.github.com/users/Codertocat/subscriptions" ,
255+ "organizations_url" : "https://api.github.com/users/Codertocat/orgs" ,
256+ "repos_url" : "https://api.github.com/users/Codertocat/repos" ,
257+ "events_url" : "https://api.github.com/users/Codertocat/events{/privacy}" ,
258+ "received_events_url" : "https://api.github.com/users/Codertocat/received_events" ,
259+ "type" : "User" ,
260+ "site_admin" : False ,
172261 },
173- "private" : False ,
174- "html_url" : "https://github.com/Codertocat/Hello-World" ,
175- "description" : None ,
176- "fork" : False ,
177- "url" : "https://github.com/Codertocat/Hello-World" ,
178- "forks_url" : "https://api.github.com/repos/Codertocat/Hello-World/forks" ,
179- "keys_url" : "https://api.github.com/repos/Codertocat/Hello-World/keys{/key_id}" ,
180- "collaborators_url" : "https://api.github.com/repos/Codertocat/Hello-World/collaborators{/collaborator}" ,
181- "teams_url" : "https://api.github.com/repos/Codertocat/Hello-World/teams" ,
182- "hooks_url" : "https://api.github.com/repos/Codertocat/Hello-World/hooks" ,
183- "issue_events_url" : "https://api.github.com/repos/Codertocat/Hello-World/issues/events{/number}" ,
184- "events_url" : "https://api.github.com/repos/Codertocat/Hello-World/events" ,
185- "assignees_url" : "https://api.github.com/repos/Codertocat/Hello-World/assignees{/user}" ,
186- "branches_url" : "https://api.github.com/repos/Codertocat/Hello-World/branches{/branch}" ,
187- "tags_url" : "https://api.github.com/repos/Codertocat/Hello-World/tags" ,
188- "blobs_url" : "https://api.github.com/repos/Codertocat/Hello-World/git/blobs{/sha}" ,
189- "git_tags_url" : "https://api.github.com/repos/Codertocat/Hello-World/git/tags{/sha}" ,
190- "git_refs_url" : "https://api.github.com/repos/Codertocat/Hello-World/git/refs{/sha}" ,
191- "trees_url" : "https://api.github.com/repos/Codertocat/Hello-World/git/trees{/sha}" ,
192- "statuses_url" : "https://api.github.com/repos/Codertocat/Hello-World/statuses/{sha}" ,
193- "languages_url" : "https://api.github.com/repos/Codertocat/Hello-World/languages" ,
194- "stargazers_url" : "https://api.github.com/repos/Codertocat/Hello-World/stargazers" ,
195- "contributors_url" : "https://api.github.com/repos/Codertocat/Hello-World/contributors" ,
196- "subscribers_url" : "https://api.github.com/repos/Codertocat/Hello-World/subscribers" ,
197- "subscription_url" : "https://api.github.com/repos/Codertocat/Hello-World/subscription" ,
198- "commits_url" : "https://api.github.com/repos/Codertocat/Hello-World/commits{/sha}" ,
199- "git_commits_url" : "https://api.github.com/repos/Codertocat/Hello-World/git/commits{/sha}" ,
200- "comments_url" : "https://api.github.com/repos/Codertocat/Hello-World/comments{/number}" ,
201- "issue_comment_url" : "https://api.github.com/repos/Codertocat/Hello-World/issues/comments{/number}" ,
202- "contents_url" : "https://api.github.com/repos/Codertocat/Hello-World/contents/{+path}" ,
203- "compare_url" : "https://api.github.com/repos/Codertocat/Hello-World/compare/{base}...{head}" ,
204- "merges_url" : "https://api.github.com/repos/Codertocat/Hello-World/merges" ,
205- "archive_url" : "https://api.github.com/repos/Codertocat/Hello-World/{archive_format}{/ref}" ,
206- "downloads_url" : "https://api.github.com/repos/Codertocat/Hello-World/downloads" ,
207- "issues_url" : "https://api.github.com/repos/Codertocat/Hello-World/issues{/number}" ,
208- "pulls_url" : "https://api.github.com/repos/Codertocat/Hello-World/pulls{/number}" ,
209- "milestones_url" : "https://api.github.com/repos/Codertocat/Hello-World/milestones{/number}" ,
210- "notifications_url" : "https://api.github.com/repos/Codertocat/Hello-World/notifications{?since,all,participating}" ,
211- "labels_url" : "https://api.github.com/repos/Codertocat/Hello-World/labels{/name}" ,
212- "releases_url" : "https://api.github.com/repos/Codertocat/Hello-World/releases{/id}" ,
213- "deployments_url" : "https://api.github.com/repos/Codertocat/Hello-World/deployments" ,
214- "created_at" : 1527711484 ,
215- "updated_at" : "2018-05-30T20:18:35Z" ,
216- "pushed_at" : 1527711528 ,
217- "git_url" : "git://github.com/Codertocat/Hello-World.git" ,
218- "ssh_url" : "git@github.com:Codertocat/Hello-World.git" ,
219- "clone_url" : "https://github.com/Codertocat/Hello-World.git" ,
220- "svn_url" : "https://github.com/Codertocat/Hello-World" ,
221- "homepage" : None ,
222- "size" : 0 ,
223- "stargazers_count" : 0 ,
224- "watchers_count" : 0 ,
225- "language" : None ,
226- "has_issues" : True ,
227- "has_projects" : True ,
228- "has_downloads" : True ,
229- "has_wiki" : True ,
230- "has_pages" : True ,
231- "forks_count" : 0 ,
232- "mirror_url" : None ,
233- "archived" : False ,
234- "open_issues_count" : 2 ,
235- "license" : None ,
236- "forks" : 0 ,
237- "open_issues" : 2 ,
238- "watchers" : 0 ,
239- "default_branch" : "master" ,
240- "stargazers" : 0 ,
241- "master_branch" : "master"
242- },
243- "pusher" : {
244- "name" : "Codertocat" ,
245- "email" : "21031067+Codertocat@users.noreply.github.com"
246- },
247- "sender" : {
248- "login" : "Codertocat" ,
249- "id" : 21031067 ,
250- "node_id" : "MDQ6VXNlcjIxMDMxMDY3" ,
251- "avatar_url" : "https://avatars1.githubusercontent.com/u/21031067?v=4" ,
252- "gravatar_id" : "" ,
253- "url" : "https://api.github.com/users/Codertocat" ,
254- "html_url" : "https://github.com/Codertocat" ,
255- "followers_url" : "https://api.github.com/users/Codertocat/followers" ,
256- "following_url" : "https://api.github.com/users/Codertocat/following{/other_user}" ,
257- "gists_url" : "https://api.github.com/users/Codertocat/gists{/gist_id}" ,
258- "starred_url" : "https://api.github.com/users/Codertocat/starred{/owner}{/repo}" ,
259- "subscriptions_url" : "https://api.github.com/users/Codertocat/subscriptions" ,
260- "organizations_url" : "https://api.github.com/users/Codertocat/orgs" ,
261- "repos_url" : "https://api.github.com/users/Codertocat/repos" ,
262- "events_url" : "https://api.github.com/users/Codertocat/events{/privacy}" ,
263- "received_events_url" : "https://api.github.com/users/Codertocat/received_events" ,
264- "type" : "User" ,
265- "site_admin" : False
266- }
267262}
268263
264+
269265def test_push_request ():
270266 """ Uses the example event defined in the GitHub documentation to ensure
271267 that our webhook app can receive the event.
272268 """
273269
274270 # GIVEN
275271 app = Flask (__name__ ) # Standard Flask app
276- webhook = Webhook (app ) # Defines '/postreceive' endpoint
272+ webhook = Webhook (app ) # Defines '/postreceive' endpoint
277273
278- @webhook .hook () # Defines a handler for the 'push' event
274+ @webhook .hook () # Defines a handler for the 'push' event
279275 def on_push (data ):
280276 flag = data ["repository" ]["full_name" ] == "Codertocat/Hello-World"
281277 if not flag :
@@ -284,13 +280,14 @@ def on_push(data):
284280 # WHEN
285281 resp = None
286282 with app .test_client () as client :
287- resp = client .post ('/postreceive' ,
288- json = example_push_event ,
289- headers = { "X-Github-Event" : "push" , "X-Github-Delivery" : 0 } )
283+ resp = client .post (
284+ "/postreceive" , json = example_push_event , headers = { "X-Github-Event" : "push" , "X-Github-Delivery" : 0 }
285+ )
290286
291287 # THEN
292288 assert resp .status_code == 204
293289
290+
294291# -----------------------------------------------------------------------------
295292# Copyright 2015 Bloomberg Finance L.P.
296293#
0 commit comments