12
12
13
13
class FakeGH :
14
14
15
- def __init__ (self , * , getitem = None , post = None ):
15
+ def __init__ (self , * , getitem = None , post = None , patch = None ):
16
16
self ._getitem_return = getitem
17
17
self ._post_return = post
18
+ self ._patch_return = patch
18
19
self .post_url = []
19
20
self .post_data = []
21
+ self .patch_url = []
22
+ self .patch_data = []
20
23
21
24
async def getitem (self , url ):
22
25
if isinstance (self ._getitem_return , Exception ):
@@ -28,7 +31,6 @@ async def post(self, url, *, data):
28
31
self .post_data .append (data )
29
32
return self ._post_return
30
33
31
-
32
34
@pytest .mark .asyncio
33
35
@pytest .mark .parametrize ("action" , ["opened" , "synchronize" , "reopened" ])
34
36
async def test_set_status_failure (action , monkeypatch ):
@@ -40,6 +42,7 @@ async def test_set_status_failure(action, monkeypatch):
40
42
"statuses_url" : "https://api.github.com/blah/blah/git-sha" ,
41
43
"title" : "No issue in title" ,
42
44
"issue_url" : "issue URL" ,
45
+ "url" : "url" ,
43
46
},
44
47
}
45
48
issue_data = {
@@ -68,6 +71,8 @@ async def test_set_status_failure_via_issue_not_found_on_github(action, monkeypa
68
71
"pull_request" : {
69
72
"statuses_url" : "https://api.github.com/blah/blah/git-sha" ,
70
73
"title" : "gh-123: Invalid issue number" ,
74
+ "issue_url" : "issue URL" ,
75
+ "url" : "url" ,
71
76
},
72
77
}
73
78
event = sansio .Event (data , event = "pull_request" , delivery_id = "12345" )
@@ -88,7 +93,9 @@ async def test_set_status_success_issue_found_on_bpo(action):
88
93
"action" : action ,
89
94
"pull_request" : {
90
95
"statuses_url" : "https://api.github.com/blah/blah/git-sha" ,
91
- "title" : "bpo-12345: an issue!" ,
96
+ "title" : "bpo-12345: An issue on b.p.o" ,
97
+ "issue_url" : "issue URL" ,
98
+ "url" : "url" ,
92
99
},
93
100
}
94
101
event = sansio .Event (data , event = "pull_request" , delivery_id = "12345" )
@@ -112,6 +119,7 @@ async def test_set_status_success(action, monkeypatch):
112
119
"action" : action ,
113
120
"pull_request" : {
114
121
"statuses_url" : "https://api.github.com/blah/blah/git-sha" ,
122
+ "url" : "" ,
115
123
"title" : "[3.6] gh-1234: an issue!" ,
116
124
},
117
125
}
@@ -137,6 +145,7 @@ async def test_set_status_success_issue_found_on_gh(action, monkeypatch):
137
145
"pull_request" : {
138
146
"statuses_url" : "https://api.github.com/blah/blah/git-sha" ,
139
147
"title" : "gh-12345: an issue!" ,
148
+ "url" : "url" ,
140
149
},
141
150
}
142
151
event = sansio .Event (data , event = "pull_request" , delivery_id = "12345" )
@@ -161,6 +170,7 @@ async def test_set_status_success_issue_found_on_gh_ignore_case(action, monkeypa
161
170
"pull_request" : {
162
171
"statuses_url" : "https://api.github.com/blah/blah/git-sha" ,
163
172
"title" : "GH-12345: an issue!" ,
173
+ "url" : "url" ,
164
174
},
165
175
}
166
176
event = sansio .Event (data , event = "pull_request" , delivery_id = "12345" )
@@ -186,6 +196,7 @@ async def test_set_status_success_via_skip_issue_label(action, monkeypatch):
186
196
"statuses_url" : "https://api.github.com/blah/blah/git-sha" ,
187
197
"title" : "No issue in title" ,
188
198
"issue_url" : "issue URL" ,
199
+ "url" : "url" ,
189
200
},
190
201
}
191
202
issue_data = {
@@ -211,6 +222,7 @@ async def test_edit_title(monkeypatch):
211
222
"pull_request" : {
212
223
"statuses_url" : "https://api.github.com/blah/blah/git-sha" ,
213
224
"title" : "gh-1234: an issue!" ,
225
+ "url" : "url" ,
214
226
},
215
227
"action" : "edited" ,
216
228
"changes" : {"title" : "thingy" },
@@ -251,6 +263,7 @@ async def test_edit_other_than_title(monkeypatch):
251
263
"pull_request" : {
252
264
"statuses_url" : "https://api.github.com/blah/blah/git-sha" ,
253
265
"title" : "bpo-1234: an issue!" ,
266
+ "url" : "url" ,
254
267
},
255
268
"action" : "edited" ,
256
269
"changes" : {"stuff" : "thingy" },
@@ -270,6 +283,7 @@ async def test_new_label_skip_issue_no_issue():
270
283
"pull_request" : {
271
284
"statuses_url" : "https://api.github.com/blah/blah/git-sha" ,
272
285
"title" : "An easy fix" ,
286
+ "url" : "url" ,
273
287
},
274
288
}
275
289
event = sansio .Event (data , event = "pull_request" , delivery_id = "12345" )
@@ -287,6 +301,7 @@ async def test_new_label_skip_issue_with_issue_number():
287
301
"pull_request" : {
288
302
"statuses_url" : "https://api.github.com/blah/blah/git-sha" ,
289
303
"title" : "Revert gh-1234: revert an easy fix" ,
304
+ "url" : "url" ,
290
305
},
291
306
}
292
307
event = sansio .Event (data , event = "pull_request" , delivery_id = "12345" )
@@ -308,6 +323,7 @@ async def test_new_label_skip_issue_with_issue_number_ignore_case():
308
323
"pull_request" : {
309
324
"statuses_url" : "https://api.github.com/blah/blah/git-sha" ,
310
325
"title" : "Revert Gh-1234: revert an easy fix" ,
326
+ "url" : "url" ,
311
327
},
312
328
}
313
329
event = sansio .Event (data , event = "pull_request" , delivery_id = "12345" )
@@ -327,6 +343,7 @@ async def test_new_label_not_skip_issue():
327
343
"label" : {"name" : "non-trivial" },
328
344
"pull_request" : {
329
345
"statuses_url" : "https://api.github.com/blah/blah/git-sha" ,
346
+ "url" : "url" ,
330
347
},
331
348
}
332
349
event = sansio .Event (data , event = "pull_request" , delivery_id = "12345" )
@@ -347,6 +364,7 @@ async def test_removed_label_from_label_deletion(monkeypatch):
347
364
"pull_request" : {
348
365
"statuses_url" : "https://api.github.com/blah/blah/git-sha" ,
349
366
"title" : "gh-1234: an issue!" ,
367
+ "url" : "url" ,
350
368
},
351
369
}
352
370
event = sansio .Event (data , event = "pull_request" , delivery_id = "12345" )
@@ -366,6 +384,7 @@ async def test_removed_label_skip_issue(monkeypatch):
366
384
"pull_request" : {
367
385
"statuses_url" : "https://api.github.com/blah/blah/git-sha" ,
368
386
"title" : "gh-1234: an issue!" ,
387
+ "url" : "url" ,
369
388
},
370
389
}
371
390
event = sansio .Event (data , event = "pull_request" , delivery_id = "12345" )
@@ -389,6 +408,7 @@ async def test_removed_label_non_skip_issue(monkeypatch):
389
408
"label" : {"name" : "non-trivial" },
390
409
"pull_request" : {
391
410
"statuses_url" : "https://api.github.com/blah/blah/git-sha" ,
411
+ "url" : "url" ,
392
412
},
393
413
}
394
414
event = sansio .Event (data , event = "pull_request" , delivery_id = "12345" )
@@ -422,7 +442,7 @@ async def test_validate_issue_number_is_pr_on_github():
422
442
423
443
gh = FakeGH (getitem = {
424
444
"number" : 123 ,
425
- "pull_request" : {"html_url" : "https://github.com/python/cpython/pull/123" }
445
+ "pull_request" : {"html_url" : "https://github.com/python/cpython/pull/123" , "url" : "url" , }
426
446
})
427
447
async with aiohttp .ClientSession () as session :
428
448
response = await gh_issue ._validate_issue_number (gh , 123 , session = session )
0 commit comments