diff --git a/tests/conftest.py b/tests/conftest.py index 449572aa624911afed207f3f2277aa548c1ccff8..83a55661a3ed8d60eef3890cb38698063f3a1525 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -91,14 +91,6 @@ def setup_api(responses, monkeypatch, cache_yaml): monkeypatch.setenv("ARKINDEX_API_TOKEN", "unittest1234") -@pytest.fixture(autouse=True) -def temp_working_directory(monkeypatch, tmp_path): - def _getcwd(): - return str(tmp_path) - - monkeypatch.setattr(os, "getcwd", _getcwd) - - @pytest.fixture(autouse=True) def give_worker_version_id_env_variable(monkeypatch): monkeypatch.setenv("WORKER_VERSION_ID", "12341234-1234-1234-1234-123412341234") @@ -183,9 +175,11 @@ def mock_base_worker_with_cache(mocker, monkeypatch, mock_worker_version_api): @pytest.fixture -def mock_elements_worker_with_cache(monkeypatch, mock_worker_version_api): +def mock_elements_worker_with_cache(monkeypatch, mock_worker_version_api, tmp_path): """Build and configure an ElementsWorker using SQLite cache with fixed CLI parameters to avoid issues with pytest""" - monkeypatch.setattr(sys, "argv", ["worker"]) + cache_path = tmp_path / "db.sqlite" + cache_path.touch() + monkeypatch.setattr(sys, "argv", ["worker", "-d", str(cache_path)]) monkeypatch.setenv("ARKINDEX_CORPUS_ID", "11111111-1111-1111-1111-111111111111") worker = ElementsWorker(support_cache=True) diff --git a/tests/test_base_worker.py b/tests/test_base_worker.py index acd5c5576f9c807208ee00dce496d971178acb48..444d5131b80b925d4a98acd27dd123ad011e6583 100644 --- a/tests/test_base_worker.py +++ b/tests/test_base_worker.py @@ -33,7 +33,7 @@ def test_init_with_local_cache(monkeypatch): assert worker.work_dir == os.path.expanduser("~/.local/share/arkindex") assert worker.worker_version_id == "12341234-1234-1234-1234-123412341234" - assert worker.use_cache is True + assert worker.support_cache is True def test_init_var_ponos_data_given(monkeypatch): diff --git a/tests/test_elements_worker/test_elements.py b/tests/test_elements_worker/test_elements.py index 018bd9cbde155445c240c6fbef30b846eff56c7f..744009fbf99b432ce99840f9d6ca44c66a0f5cf4 100644 --- a/tests/test_elements_worker/test_elements.py +++ b/tests/test_elements_worker/test_elements.py @@ -145,7 +145,7 @@ def test_database_arg(mocker, mock_elements_worker, tmp_path): ), ) - worker = ElementsWorker() + worker = ElementsWorker(support_cache=True) worker.configure() assert worker.use_cache is True