@@ -85,7 +85,7 @@ async def test_docs_no_news():
85
85
assert gh .getitem_url == 'https://api.github.com/repos/cpython/python/issue/1234'
86
86
assert len (gh .post_url ) == 1
87
87
assert gh .post_url [0 ] == 'https://api.github.com/some/label'
88
- assert gh .post_data [0 ] == [Labels .docs .value ]
88
+ assert gh .post_data [0 ] == [Labels .docs .value , Labels . skip_news . value ]
89
89
90
90
91
91
async def test_docs_and_news ():
@@ -154,7 +154,7 @@ async def test_docs_and_tests():
154
154
155
155
async def test_leave_existing_type_labels ():
156
156
filenames = {'/path/to/docs.rst' , 'test_docs2.py' }
157
- issue = {'labels' : [{'name' : 'skip news' }, {'name' : 'type-documentation ' }],
157
+ issue = {'labels' : [{'name' : 'skip news' }, {'name' : 'docs ' }],
158
158
'labels_url' : 'https://api.github.com/some/label' }
159
159
gh = FakeGH (getiter = filenames , getitem = issue )
160
160
event_data = {
@@ -168,7 +168,29 @@ async def test_leave_existing_type_labels():
168
168
}
169
169
await prtype .classify_by_filepaths (gh , event_data ['pull_request' ], filenames )
170
170
assert gh .getitem_url == 'https://api.github.com/repos/cpython/python/issue/1234'
171
- # Only creates type-tests label.
171
+ assert len (gh .post_url ) == 1
172
+ assert gh .post_url [0 ] == "https://api.github.com/some/label"
173
+ # This should only add the tests label as the docs label is already applied
174
+ assert gh .post_data [0 ] == [Labels .tests .value ]
175
+
176
+
177
+ async def test_do_not_post_if_nothing_to_apply ():
178
+ filenames = {'/path/to/docs.rst' }
179
+ issue = {'labels' : [{'name' : 'skip news' }, {'name' : 'docs' }],
180
+ 'labels_url' : 'https://api.github.com/some/label' }
181
+ gh = FakeGH (getiter = filenames , getitem = issue )
182
+ event_data = {
183
+ 'action' : 'opened' ,
184
+ 'number' : 1234 ,
185
+ 'pull_request' : {
186
+ 'url' : 'https://api.github.com/repos/cpython/python/pulls/1234' ,
187
+ 'statuses_url' : 'https://api.github.com/some/status' ,
188
+ 'issue_url' : 'https://api.github.com/repos/cpython/python/issue/1234' ,
189
+ },
190
+ }
191
+ await prtype .classify_by_filepaths (gh , event_data ['pull_request' ], filenames )
192
+ assert gh .getitem_url == 'https://api.github.com/repos/cpython/python/issue/1234'
193
+ # This should not post anything as docs is already applied
172
194
assert len (gh .post_url ) == 0
173
195
174
196
0 commit comments