@@ -384,9 +384,8 @@ async def test_set_pull_request_body_already_hyperlinked_bpo(action):
384
384
"statuses_url" : "https://api.github.com/blah/blah/git-sha" ,
385
385
"issue_url" : "https://api.github.com/repos/blah/blah/issues/comments/123456" ,
386
386
"body" : ("bpo-123"
387
- "[bpo-123](https://bugs.python.org/issue123)"
388
- "<a href='https://bugs.python.org/issue123'>bpo-123</a>"
389
- )
387
+ "[bpo-123](https://bugs.python.org/issue123)"
388
+ "<a href='https://bugs.python.org/issue123'>bpo-123</a>" )
390
389
},
391
390
"changes" : {"stuff" : "thingy" }
392
391
}
@@ -407,9 +406,8 @@ async def test_set_comment_body_already_hyperlinked_bpo(action):
407
406
"comment" : {
408
407
"url" : "https://api.github.com/repos/blah/blah/issues/comments/123456" ,
409
408
"body" : ("bpo-123"
410
- "[bpo-123](https://bugs.python.org/issue123)"
411
- "<a href='https://bugs.python.org/issue123'>bpo-123</a>"
412
- )
409
+ "[bpo-123](https://bugs.python.org/issue123)"
410
+ "<a href='https://bugs.python.org/issue123'>bpo-123</a>" )
413
411
}
414
412
}
415
413
@@ -419,3 +417,48 @@ async def test_set_comment_body_already_hyperlinked_bpo(action):
419
417
body_data = gh .patch_data
420
418
assert body_data ["body" ].count ("[bpo-123](https://bugs.python.org/issue123)" ) == 2
421
419
assert "123456" in gh .patch_url
420
+
421
+
422
+ @pytest .mark .asyncio
423
+ @pytest .mark .parametrize ("action" , ["created" , "edited" ])
424
+ async def test_untouched_bpo_text_within_codeblocks (action ):
425
+ data = {
426
+ "action" : action ,
427
+ "comment" : {
428
+ "url" : "https://api.github.com/repos/blah/blah/issues/comments/123456" ,
429
+ "body" : ("bpo-123"
430
+ "`bpo-123`"
431
+ "[bpo-123](https://bugs.python.org/issue123)"
432
+ "<a href='https://bugs.python.org/issue123'>bpo-123</a>" )
433
+ }
434
+ }
435
+
436
+ event = sansio .Event (data , event = "pull_request" , delivery_id = "123123" )
437
+ gh = FakeGH ()
438
+ await bpo .router .dispatch (event , gh )
439
+ body_data = gh .patch_data
440
+ print (body_data ["body" ])
441
+ assert 1 == 2
442
+ assert body_data ["body" ].count ("[bpo-123](https://bugs.python.org/issue123)" ) == 3
443
+ assert "123456" in gh .patch_url
444
+
445
+
446
+ @pytest .mark .asyncio
447
+ @pytest .mark .parametrize ("action" , ["created" , "edited" ])
448
+ async def test_untouched_bpo_text_within_comment (action ):
449
+ data = {
450
+ "action" : action ,
451
+ "comment" : {
452
+ "url" : "https://api.github.com/repos/blah/blah/issues/comments/123456" ,
453
+ "body" : ("bpo-123"
454
+ "[bpo-123](https://bugs.python.org/issue123)"
455
+ "<a href='https://bugs.python.org/issue123'>bpo-123</a>" )
456
+ }
457
+ }
458
+
459
+ event = sansio .Event (data , event = "pull_request" , delivery_id = "123123" )
460
+ gh = FakeGH ()
461
+ await bpo .router .dispatch (event , gh )
462
+ body_data = gh .patch_data
463
+ assert body_data ["body" ].count ("[bpo-123](https://bugs.python.org/issue123)" ) == 2
464
+ assert "123456" in gh .patch_url
0 commit comments