@@ -102,9 +102,11 @@ async def test_missing_backport_label():
102
102
event = sansio .Event (data , event = 'pull_request' ,
103
103
delivery_id = '1' )
104
104
getitem = {
105
- 'https://api.github.com/issue/1234' :
106
- {'labels' : [{'name' : 'CLA signed' }]},
107
- 'https://api.github.com/issue/2248' : {},
105
+ "https://api.github.com/issue/1234" : {
106
+ "labels" : [{"name" : "CLA signed" }],
107
+ "comments_url" : "https://api.github.com/issue/1234/comments" ,
108
+ },
109
+ "https://api.github.com/issue/2248" : {},
108
110
}
109
111
gh = FakeGH (getitem = getitem )
110
112
await backport .router .dispatch (event , gh )
@@ -154,6 +156,46 @@ async def test_backport_label_removal_success(pr_prefix):
154
156
assert expected_post is not None
155
157
156
158
159
+ async def test_backport_link_comment_without_label (pr_prefix ):
160
+ event_data = {
161
+ "action" : "opened" ,
162
+ "number" : 2248 ,
163
+ "pull_request" : {
164
+ "title" : f"[3.6] Backport this ({ pr_prefix } -1234)" ,
165
+ "body" : "" ,
166
+ "issue_url" : "https://api.github.com/issue/2248" ,
167
+ "base" : {
168
+ "ref" : "3.6" ,
169
+ },
170
+ "statuses_url" : "https://api.github.com/repos/python/cpython/statuses/somehash" ,
171
+ },
172
+ "repository" : {
173
+ "issues_url" : "https://api.github.com/issue{/number}" ,
174
+ },
175
+ }
176
+ event = sansio .Event (event_data , event = "pull_request" , delivery_id = "1" )
177
+ getitem_data = {
178
+ "https://api.github.com/issue/1234" : {
179
+ "labels" : [],
180
+ "comments_url" : "https://api.github.com/issue/1234/comments" ,
181
+ },
182
+ "https://api.github.com/issue/2248" : {},
183
+ }
184
+ gh = FakeGH (getitem = getitem_data )
185
+ await backport .router .dispatch (event , gh )
186
+ issue_data = getitem_data ["https://api.github.com/issue/1234" ]
187
+ assert gh .delete_url is None
188
+ assert len (gh .post_ ) > 0
189
+ expected_post = None
190
+ for post in gh .post_ :
191
+ if post [0 ] == issue_data ["comments_url" ]:
192
+ expected_post = post
193
+ message = post [1 ]["body" ]
194
+ assert message == backport .MESSAGE_TEMPLATE .format (branch = "3.6" , pr = "2248" )
195
+
196
+ assert expected_post is not None
197
+
198
+
157
199
async def test_backport_label_removal_with_leading_space_in_title (pr_prefix ):
158
200
event_data = {
159
201
'action' : 'opened' ,
0 commit comments