From e125f3a4b18f28e20bc292cd53779fea20decaec Mon Sep 17 00:00:00 2001 From: Houkime <> Date: Wed, 28 Dec 2022 12:44:51 +0000 Subject: [PATCH] test(tokens-repo): remove test tokens.json files except for one which will temporarily remain gitkeeps are to prevent shared_datadir from erroring out in a freshly cloned repo. for now huey database and jobs fixtures use shared_datadir --- tests/conftest.py | 15 +++++++++++---- tests/test_graphql/data/gitkeep | 0 tests/test_graphql/data/tokens.json | 14 -------------- tests/test_rest_endpoints/data/tokens.json | 14 -------------- .../test_rest_endpoints/services/data/tokens.json | 9 --------- tests/test_rest_endpoints/services/gitkeep | 0 6 files changed, 11 insertions(+), 41 deletions(-) create mode 100644 tests/test_graphql/data/gitkeep delete mode 100644 tests/test_graphql/data/tokens.json delete mode 100644 tests/test_rest_endpoints/data/tokens.json delete mode 100644 tests/test_rest_endpoints/services/data/tokens.json create mode 100644 tests/test_rest_endpoints/services/gitkeep diff --git a/tests/conftest.py b/tests/conftest.py index ea7a66a..4b65d20 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,18 +4,25 @@ import os import pytest from fastapi.testclient import TestClient +from shutil import copy +import os.path as path def pytest_generate_tests(metafunc): os.environ["TEST_MODE"] = "true" +def global_data_dir(): + return path.join(path.dirname(__file__), "data") + + @pytest.fixture -def tokens_file(mocker, shared_datadir): +def tokens_file(mocker, tmpdir): """Mock tokens file.""" - mock = mocker.patch( - "selfprivacy_api.utils.TOKENS_FILE", shared_datadir / "tokens.json" - ) + tmp_file = tmpdir / "tokens.json" + source_file = path.join(global_data_dir(), "tokens.json") + copy(source_file, tmp_file) + mock = mocker.patch("selfprivacy_api.utils.TOKENS_FILE", tmp_file) return mock diff --git a/tests/test_graphql/data/gitkeep b/tests/test_graphql/data/gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_graphql/data/tokens.json b/tests/test_graphql/data/tokens.json deleted file mode 100644 index 9be9d02..0000000 --- a/tests/test_graphql/data/tokens.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "tokens": [ - { - "token": "TEST_TOKEN", - "name": "test_token", - "date": "2022-01-14 08:31:10.789314" - }, - { - "token": "TEST_TOKEN2", - "name": "test_token2", - "date": "2022-01-14 08:31:10.789314" - } - ] -} \ No newline at end of file diff --git a/tests/test_rest_endpoints/data/tokens.json b/tests/test_rest_endpoints/data/tokens.json deleted file mode 100644 index 9be9d02..0000000 --- a/tests/test_rest_endpoints/data/tokens.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "tokens": [ - { - "token": "TEST_TOKEN", - "name": "test_token", - "date": "2022-01-14 08:31:10.789314" - }, - { - "token": "TEST_TOKEN2", - "name": "test_token2", - "date": "2022-01-14 08:31:10.789314" - } - ] -} \ No newline at end of file diff --git a/tests/test_rest_endpoints/services/data/tokens.json b/tests/test_rest_endpoints/services/data/tokens.json deleted file mode 100644 index 9d35420..0000000 --- a/tests/test_rest_endpoints/services/data/tokens.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "tokens": [ - { - "token": "TEST_TOKEN", - "name": "Test Token", - "date": "2022-01-14 08:31:10.789314" - } - ] -} \ No newline at end of file diff --git a/tests/test_rest_endpoints/services/gitkeep b/tests/test_rest_endpoints/services/gitkeep new file mode 100644 index 0000000..e69de29