Skip to content

Commit 54b8e30

Browse files
committed
fix: remove unnecessary unit test patches
Removes patches to os.join side_effects
1 parent 1574c53 commit 54b8e30

File tree

1 file changed

+2
-28
lines changed

1 file changed

+2
-28
lines changed

backend/kernelCI_app/tests/unitTests/commands/monitorSubmissions/file_utils_test.py

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -238,52 +238,26 @@ def test_verify_dir_not_writable(self, mock_access, mock_isdir, mock_exists):
238238

239239
class TestVerifySpoolDirs:
240240
@patch("kernelCI_app.management.commands.helpers.file_utils.verify_dir")
241-
@patch("os.path.join")
242-
def test_verify_spool_dirs_success(self, mock_join, mock_verify_dir):
241+
def test_verify_spool_dirs_success(self, mock_verify_dir):
243242
"""Test verify_spool_dirs with successful directory verification."""
244243
joined_fail_dir = "/".join([SPOOL_DIR_TESTING, FAIL_SPOOL_SUBDIR])
245244
joined_archive_dir = "/".join([SPOOL_DIR_TESTING, ARCHIVE_SPOOL_SUBDIR])
246-
mock_join.side_effect = [joined_fail_dir, joined_archive_dir]
247245

248246
verify_spool_dirs(SPOOL_DIR_TESTING)
249247

250-
assert mock_join.call_count == 2
251-
mock_join.assert_any_call(SPOOL_DIR_TESTING, FAIL_SPOOL_SUBDIR)
252-
mock_join.assert_any_call(SPOOL_DIR_TESTING, ARCHIVE_SPOOL_SUBDIR)
253-
254248
assert mock_verify_dir.call_count == 3
255249
mock_verify_dir.assert_any_call(SPOOL_DIR_TESTING)
256250
mock_verify_dir.assert_any_call(joined_fail_dir)
257251
mock_verify_dir.assert_any_call(joined_archive_dir)
258252

259253
@patch("kernelCI_app.management.commands.helpers.file_utils.verify_dir")
260-
@patch("os.path.join")
261-
def test_verify_spool_dirs_join_failure(self, mock_join, mock_verify_dir):
262-
"""Test verify_spool_dirs when os.path.join fails."""
263-
mock_join.side_effect = TypeError("Really any Exception, this is an example")
264-
265-
with pytest.raises(TypeError):
266-
verify_spool_dirs(SPOOL_DIR_TESTING)
267-
268-
mock_join.assert_called_once_with(SPOOL_DIR_TESTING, FAIL_SPOOL_SUBDIR)
269-
mock_verify_dir.assert_not_called()
270-
271-
@patch("kernelCI_app.management.commands.helpers.file_utils.verify_dir")
272-
@patch("os.path.join")
273-
def test_verify_spool_dirs_verify_spool_dir_fails(self, mock_join, mock_verify_dir):
254+
def test_verify_spool_dirs_verify_spool_dir_fails(self, mock_verify_dir):
274255
"""Test verify_spool_dirs when spool directory verification fails."""
275-
joined_fail_dir = "/".join([SPOOL_DIR_TESTING, FAIL_SPOOL_SUBDIR])
276-
joined_archive_dir = "/".join([SPOOL_DIR_TESTING, ARCHIVE_SPOOL_SUBDIR])
277-
mock_join.side_effect = [joined_fail_dir, joined_archive_dir]
278256

279257
# Meant to represent any kind of failure in verify_dir
280258
mock_verify_dir.side_effect = Exception("Spool directory verification failed")
281259

282260
with pytest.raises(Exception, match="Spool directory verification failed"):
283261
verify_spool_dirs(SPOOL_DIR_TESTING)
284262

285-
assert mock_join.call_count == 2
286-
mock_join.assert_any_call(SPOOL_DIR_TESTING, FAIL_SPOOL_SUBDIR)
287-
mock_join.assert_any_call(SPOOL_DIR_TESTING, ARCHIVE_SPOOL_SUBDIR)
288-
289263
mock_verify_dir.assert_called_once_with(SPOOL_DIR_TESTING)

0 commit comments

Comments
 (0)