diff options
author | Frederick Muriuki Muriithi | 2025-04-11 14:53:20 -0500 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2025-04-11 14:53:20 -0500 |
commit | 8f82f83dd851e9e1dca5db77a3eafdc76a9fca94 (patch) | |
tree | 4aa0eff0466b65a223cfedc5be6e9162f2e918f2 /tests | |
parent | 774a0af9db439f50421a47249c57e5a0a6932301 (diff) | |
download | gn-uploader-8f82f83dd851e9e1dca5db77a3eafdc76a9fca94.tar.gz |
Setup client for use with tests.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/conftest.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index 9012221..a716c52 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,6 +2,8 @@ import io import os import uuid +import shutil +from pathlib import Path from hashlib import sha256 import redis @@ -46,17 +48,20 @@ def cleanup_redis(redisuri: str, prefix: str): @pytest.fixture(scope="module") def client(): "Fixture for test client" - app = create_app() test_prefix = sha256(f"test:{uuid.uuid4()}".encode("utf8")).hexdigest() - app.config.update({ + tests_work_dir = Path("/tmp/{test_prefix}") + tests_work_dir.mkdir(exist_ok=True) + app = create_app({ "TESTING": True, "GNQC_REDIS_PREFIX": f"{test_prefix}:GNQC", - "JOBS_TTL_SECONDS": 2 * 60 * 60# 2 hours + "JOBS_TTL_SECONDS": 2 * 60 * 60,# 2 hours + "ASYNCHRONOUS_JOBS_SQLITE_DB": f"{tests_work_dir}/jobs.db" }) with app.app_context(): yield app.test_client() cleanup_redis(app.config["REDIS_URL"], test_prefix) + shutil.rmtree(tests_work_dir, ignore_errors=True) @pytest.fixture(scope="module") def db_url(client):#pylint: disable=[redefined-outer-name] |