Skip to content
Snippets Groups Projects
Commit 3b70083a authored by Eva Bardou's avatar Eva Bardou
Browse files

Fix tests

parent 7559cda0
No related branches found
No related tags found
1 merge request!101Refactoring use_cache attribute on Worker classes
Pipeline #78506 passed
......@@ -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)
......
......@@ -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):
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment