@@ -212,123 +212,27 @@ def test_prepare_accepted_issue(mock_priority):
212
212
213
213
214
214
@patch ('webcompat.webhooks.model.make_request' )
215
- def test_process_issue_action_right_repo (mock_mr ):
216
- """Test that repository_url matches the CONFIG for public repo."""
217
- mock_mr .return_value .status_code == 200
218
- json_event , signature = event_data ('new_event_valid.json' )
219
- payload = json .loads (json_event )
220
- issue = WebHookIssue .from_dict (payload )
221
- with webcompat .app .test_request_context ():
222
- rv = issue .process_issue_action ()
223
- assert rv == gracias
224
-
225
-
226
- def test_process_issue_action_wrong_repo ():
227
- """Test when repository_url differs from the CONFIG for public repo."""
228
- json_event , signature = event_data ('wrong_repo.json' )
229
- payload = json .loads (json_event )
230
- issue = WebHookIssue .from_dict (payload )
231
- with webcompat .app .test_request_context ():
232
- rv = issue .process_issue_action ()
233
- assert rv == wrong_repo
234
-
235
-
236
- def test_process_issue_action_wrong_repo ():
237
- """Test for issues in the wrong repo."""
238
- json_event , signature = event_data (
239
- 'private_milestone_accepted_wrong_repo.json' )
240
- payload = json .loads (json_event )
241
- issue = WebHookIssue .from_dict (payload )
242
- with webcompat .app .test_request_context ():
243
- rv = issue .process_issue_action ()
244
- assert rv == wrong_repo
245
-
246
-
247
- @patch ('webcompat.webhooks.model.make_request' )
248
- def test_process_issue_action_acceptable_issue (mock_mr ):
249
- """Test for acceptable issues from private repo."""
250
- mock_mr .return_value .status_code == 200
251
- json_event , signature = event_data ('private_milestone_accepted.json' )
252
- payload = json .loads (json_event )
253
- issue = WebHookIssue .from_dict (payload )
254
- with webcompat .app .test_request_context ():
255
- rv = issue .process_issue_action ()
256
- assert rv == accepted
257
-
258
-
259
- @patch ('webcompat.webhooks.model.make_request' )
260
- def test_process_issue_action_private_issue_moderated_ok (mock_mr ):
261
- """Test for private issue successfully moderated."""
262
- mock_mr .return_value .status_code == 200
263
- json_event , signature = event_data ('private_milestone_accepted.json' )
264
- payload = json .loads (json_event )
265
- issue = WebHookIssue .from_dict (payload )
266
- with webcompat .app .test_request_context ():
267
- rv = issue .process_issue_action ()
268
- assert rv == accepted
269
-
270
-
271
- @patch ('webcompat.webhooks.model.make_request' )
272
- def test_process_issue_action_reject_issue (mock_mr ):
273
- """Test for rejected issues from private repo."""
274
- mock_mr .return_value .status_code == 200
275
- json_event , signature = event_data ('private_milestone_closed.json' )
276
- payload = json .loads (json_event )
277
- issue = WebHookIssue .from_dict (payload )
278
- with webcompat .app .test_request_context ():
279
- rv = issue .process_issue_action ()
280
- assert rv == rejected
281
-
282
-
283
- @patch ('webcompat.webhooks.model.make_request' )
284
- def test_process_issue_action_close_incomplete (mock_mr ):
285
- """Test for rejected issues from private repo."""
286
- mock_mr .return_value .status_code == 200
287
- json_event , signature = event_data (
288
- 'private_milestone_accepted_incomplete.json' )
289
- payload = json .loads (json_event )
290
- issue = WebHookIssue .from_dict (payload )
291
- with webcompat .app .test_request_context ():
292
- rv = issue .process_issue_action ()
293
- assert rv == incomplete
294
-
295
-
296
- @patch ('webcompat.webhooks.model.make_request' )
297
- def test_process_issue_action_close_incomplete (mock_mr ):
298
- """Test for rejected issues from private repo."""
299
- mock_mr .return_value .status_code == 200
300
- json_event , signature = event_data (
301
- 'private_milestone_accepted_invalid.json' )
302
- payload = json .loads (json_event )
303
- issue = WebHookIssue .from_dict (payload )
304
- with webcompat .app .test_request_context ():
305
- rv = issue .process_issue_action ()
306
- assert rv == invalid
307
-
308
-
309
- @patch ('webcompat.webhooks.model.make_request' )
310
- def test_process_issue_action_acceptable_issue_closed (mock_mr ):
311
- """Test for accepted issues being closed."""
312
- mock_mr .return_value .status_code == 200
313
- json_event , signature = event_data (
314
- 'private_milestone_accepted_closed.json' )
315
- payload = json .loads (json_event )
316
- issue = WebHookIssue .from_dict (payload )
317
- with webcompat .app .test_request_context ():
318
- rv = issue .process_issue_action ()
319
- assert rv == boring
320
-
321
-
322
- @patch ('webcompat.webhooks.model.make_request' )
323
- def test_process_issue_action_comment_public_uri (mock_mr ):
324
- """Test we are getting the right message on public uri comment."""
215
+ def test_process_issue_action_scenarios (mock_mr ):
216
+ """Test we are getting the right response for each scenario."""
217
+ test_data = [
218
+ ('new_event_valid.json' , gracias ),
219
+ ('wrong_repo.json' , wrong_repo ),
220
+ ('private_milestone_accepted_wrong_repo.json' , wrong_repo ),
221
+ ('private_milestone_accepted.json' , accepted ),
222
+ ('private_milestone_closed.json' , rejected ),
223
+ ('private_milestone_accepted_incomplete.json' , incomplete ),
224
+ ('private_milestone_accepted_invalid.json' , invalid ),
225
+ ('private_milestone_accepted_closed.json' , boring ),
226
+ ('private_issue_opened.json' , comment_added )
227
+ ]
325
228
mock_mr .return_value .status_code == 200
326
- json_event , signature = event_data ('private_issue_opened.json' )
327
- payload = json .loads (json_event )
328
- issue = WebHookIssue .from_dict (payload )
329
- with webcompat .app .test_request_context ():
330
- rv = issue .process_issue_action ()
331
- assert rv == comment_added
229
+ for issue_event , expected_rv in test_data :
230
+ json_event , signature = event_data (issue_event )
231
+ payload = json .loads (json_event )
232
+ issue = WebHookIssue .from_dict (payload )
233
+ with webcompat .app .test_request_context ():
234
+ rv = issue .process_issue_action ()
235
+ assert rv == expected_rv
332
236
333
237
334
238
@patch ('webcompat.webhooks.model.make_request' )
0 commit comments