diff --git a/monkey/tests/unit_tests/monkey_island/cc/services/test_version_update.py b/monkey/tests/unit_tests/monkey_island/cc/services/test_version_update.py index 7b0067c0b..4824ddfed 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/services/test_version_update.py +++ b/monkey/tests/unit_tests/monkey_island/cc/services/test_version_update.py @@ -6,46 +6,50 @@ from monkey_island.cc.services.version_update import VersionUpdateService @pytest.fixture -def deployment_info_file_path(data_for_tests_dir): - return os.path.join(data_for_tests_dir, "deployment.json") +def deployment_info_file_path(monkeypatch, data_for_tests_dir): + path = os.path.join(data_for_tests_dir, "deployment.json") + monkeypatch.setattr(os.path, "join", lambda *args: path) + return path @pytest.fixture -def ghost_file(): - return "ghost_file" +def ghost_file(monkeypatch): + path = "ghost_file" + monkeypatch.setattr(os.path, "join", lambda *args: path) + return path @pytest.fixture -def key_error_deployment_info_file_path(data_for_tests_dir): - return os.path.join(data_for_tests_dir, "deployment_key_error.json") +def key_error_deployment_info_file_path(monkeypatch, data_for_tests_dir): + path = os.path.join(data_for_tests_dir, "deployment_key_error.json") + monkeypatch.setattr(os.path, "join", lambda *args: path) + return path @pytest.fixture -def flawed_deployment_info_file_path(data_for_tests_dir): - return os.path.join(data_for_tests_dir, "deployment_flawed") +def flawed_deployment_info_file_path(monkeypatch, data_for_tests_dir): + path = os.path.join(data_for_tests_dir, "deployment_flawed") + monkeypatch.setattr(os.path, "join", lambda *args: path) + return path -def test_get_deployment_field_from_file(deployment_info_file_path, monkeypatch): - monkeypatch.setattr(os.path, "join", lambda *args: deployment_info_file_path) +def test_get_deployment_field_from_file(deployment_info_file_path): deployment = VersionUpdateService().get_deployment_from_file(deployment_info_file_path) assert deployment == "develop" -def test_get_deployment_field_from_nonexistent_file(ghost_file, monkeypatch): - monkeypatch.setattr(os.path, "join", lambda *args: ghost_file) +def test_get_deployment_field_from_nonexistent_file(ghost_file): deployment = VersionUpdateService().get_deployment_from_file(ghost_file) assert deployment == "unknown" -def test_get_deployment_field_key_error(key_error_deployment_info_file_path, monkeypatch): - monkeypatch.setattr(os.path, "join", lambda *args: key_error_deployment_info_file_path) +def test_get_deployment_field_key_error(key_error_deployment_info_file_path): deployment = VersionUpdateService().get_deployment_from_file( key_error_deployment_info_file_path ) assert deployment == "unknown" -def test_get_deployment_field_from_flawed_json_file(flawed_deployment_info_file_path, monkeypatch): - monkeypatch.setattr(os.path, "join", lambda *args: flawed_deployment_info_file_path) +def test_get_deployment_field_from_flawed_json_file(flawed_deployment_info_file_path): deployment = VersionUpdateService().get_deployment_from_file(flawed_deployment_info_file_path) assert deployment == "unknown"