@@ -78,7 +78,6 @@ def test_validate_inputs_invalid(monkeypatch, caplog, env_name, env_value, error
78
78
"INPUT_LOCATION" : "body" ,
79
79
"INPUT_TITLE" : "[Rr]elease [Nn]otes:" ,
80
80
"INPUT_SKIP_LABELS" : "" ,
81
- "INPUT_FAILS_ON_ERROR" : "true" ,
82
81
}
83
82
84
83
# Update or remove the environment variable for the tested scenario
@@ -136,14 +135,10 @@ def test_run_successful(mocker):
136
135
"labels" : [{"name" : "bug" }, {"name" : "enhancement" }]
137
136
}
138
137
139
- # Mock the output writing method
140
- mock_output = mocker .patch ("release_notes_presence_check.release_notes_presence_check_action.ReleaseNotesPresenceCheckAction.write_output" )
141
-
142
138
# Run the action
143
139
action = ReleaseNotesPresenceCheckAction ()
144
140
action .run ()
145
141
146
- mock_output .assert_called_once_with ("true" )
147
142
mock_exit .assert_called_once_with (0 )
148
143
149
144
@@ -174,9 +169,6 @@ def test_run_skip_by_label(mocker):
174
169
"labels" : [{"name" : "bug" }, {"name" : "enhancement" }, {"name" : "skip-release-notes-check" }]
175
170
}
176
171
177
- # Mock the output writing method
178
- mock_output = mocker .patch ("release_notes_presence_check.release_notes_presence_check_action.ReleaseNotesPresenceCheckAction.write_output" )
179
-
180
172
# Run the action
181
173
with pytest .raises (SystemExit ) as exit_info :
182
174
action = ReleaseNotesPresenceCheckAction ()
@@ -185,8 +177,6 @@ def test_run_skip_by_label(mocker):
185
177
assert SystemExit == exit_info .type
186
178
assert 0 == exit_info .value .code
187
179
188
- mock_output .assert_called_once_with ("true" )
189
-
190
180
191
181
def test_run_fail_no_body (mocker ):
192
182
# Set environment variables
@@ -214,9 +204,6 @@ def test_run_fail_no_body(mocker):
214
204
"labels" : [{"name" : "bug" }, {"name" : "enhancement" }]
215
205
}
216
206
217
- # Mock the output writing method
218
- mock_output = mocker .patch ("release_notes_presence_check.release_notes_presence_check_action.ReleaseNotesPresenceCheckAction.write_output" )
219
-
220
207
# Run the action
221
208
with pytest .raises (SystemExit ) as exit_info :
222
209
action = ReleaseNotesPresenceCheckAction ()
@@ -225,8 +212,6 @@ def test_run_fail_no_body(mocker):
225
212
assert SystemExit == exit_info .type
226
213
assert 1 == exit_info .value .code
227
214
228
- mock_output .assert_called_once_with ("false" )
229
-
230
215
def test_run_fail_empty_body (mocker ):
231
216
# Set environment variables
232
217
env_vars = {
@@ -254,9 +239,6 @@ def test_run_fail_empty_body(mocker):
254
239
"labels" : [{"name" : "bug" }, {"name" : "enhancement" }]
255
240
}
256
241
257
- # Mock the output writing method
258
- mock_output = mocker .patch ("release_notes_presence_check.release_notes_presence_check_action.ReleaseNotesPresenceCheckAction.write_output" )
259
-
260
242
# Run the action
261
243
with pytest .raises (SystemExit ) as exit_info :
262
244
action = ReleaseNotesPresenceCheckAction ()
@@ -265,8 +247,6 @@ def test_run_fail_empty_body(mocker):
265
247
assert SystemExit == exit_info .type
266
248
assert 1 == exit_info .value .code
267
249
268
- mock_output .assert_called_once_with ("false" )
269
-
270
250
def test_run_fail_title_not_found (mocker ):
271
251
# Set environment variables
272
252
env_vars = {
@@ -294,9 +274,6 @@ def test_run_fail_title_not_found(mocker):
294
274
"labels" : [{"name" : "bug" }, {"name" : "enhancement" }]
295
275
}
296
276
297
- # Mock the output writing method
298
- mock_output = mocker .patch ("release_notes_presence_check.release_notes_presence_check_action.ReleaseNotesPresenceCheckAction.write_output" )
299
-
300
277
# Run the action
301
278
with pytest .raises (SystemExit ) as exit_info :
302
279
action = ReleaseNotesPresenceCheckAction ()
@@ -305,8 +282,6 @@ def test_run_fail_title_not_found(mocker):
305
282
assert SystemExit == exit_info .type
306
283
assert 1 == exit_info .value .code
307
284
308
- mock_output .assert_called_once_with ("false" )
309
-
310
285
def test_run_fail_release_notes_lines_not_found (mocker ):
311
286
# Set environment variables
312
287
env_vars = {
@@ -334,9 +309,6 @@ def test_run_fail_release_notes_lines_not_found(mocker):
334
309
"labels" : [{"name" : "bug" }, {"name" : "enhancement" }]
335
310
}
336
311
337
- # Mock the output writing method
338
- mock_output = mocker .patch ("release_notes_presence_check.release_notes_presence_check_action.ReleaseNotesPresenceCheckAction.write_output" )
339
-
340
312
# Run the action
341
313
with pytest .raises (SystemExit ) as exit_info :
342
314
action = ReleaseNotesPresenceCheckAction ()
@@ -345,8 +317,6 @@ def test_run_fail_release_notes_lines_not_found(mocker):
345
317
assert SystemExit == exit_info .type
346
318
assert 1 == exit_info .value .code
347
319
348
- mock_output .assert_called_once_with ("false" )
349
-
350
320
def test_run_fail_no_lines_after_title (mocker ):
351
321
# Set environment variables
352
322
env_vars = {
@@ -374,45 +344,10 @@ def test_run_fail_no_lines_after_title(mocker):
374
344
"labels" : [{"name" : "bug" }, {"name" : "enhancement" }]
375
345
}
376
346
377
- # Mock the output writing method
378
- mock_output = mocker .patch ("release_notes_presence_check.release_notes_presence_check_action.ReleaseNotesPresenceCheckAction.write_output" )
379
-
380
347
# Run the action
381
348
with pytest .raises (SystemExit ) as exit_info :
382
349
action = ReleaseNotesPresenceCheckAction ()
383
350
action .run ()
384
351
385
352
assert SystemExit == exit_info .type
386
353
assert 1 == exit_info .value .code
387
-
388
- mock_output .assert_called_once_with ("false" )
389
-
390
- # handle_failure
391
-
392
- def test_handle_failure_fails_on_error_false (mocker ):
393
- # Set environment variables with 'INPUT_FAILS_ON_ERROR' set to 'false'
394
- env_vars = {
395
- "INPUT_GITHUB_TOKEN" : "fake_token" ,
396
- "INPUT_PR_NUMBER" : "109" ,
397
- "INPUT_GITHUB_REPOSITORY" : "owner/repo" ,
398
- "INPUT_LOCATION" : "body" ,
399
- "INPUT_TITLE" : "[Rr]elease [Nn]otes:" ,
400
- "INPUT_SKIP_LABELS" : "" ,
401
- "INPUT_FAILS_ON_ERROR" : "false" , # Set to 'false' to test else branch
402
- }
403
- mocker .patch .dict (os .environ , env_vars )
404
-
405
- # Mock sys.exit to raise SystemExit exception
406
- def mock_exit (code ):
407
- raise SystemExit (code )
408
- mocker .patch ("sys.exit" , mock_exit )
409
-
410
- # Instantiate the action
411
- action = ReleaseNotesPresenceCheckAction ()
412
-
413
- # Call handle_failure and expect SystemExit
414
- with pytest .raises (SystemExit ) as e :
415
- action .handle_failure ()
416
-
417
- # Assert that sys.exit was called with exit code 0
418
- assert e .value .code == 0
0 commit comments