From c81b2860b0c001ac1c6d8fe2ee713058c3c8f319 Mon Sep 17 00:00:00 2001 From: spwoodcock Date: Fri, 13 Oct 2023 00:36:23 +0100 Subject: [PATCH] test: use relative test_data_path over abs paths --- src/backend/tests/test_data/__init__.py | 4 ++++ src/backend/tests/test_projects_routes.py | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/backend/tests/test_data/__init__.py b/src/backend/tests/test_data/__init__.py index 18b0dae382..ad504ea69a 100644 --- a/src/backend/tests/test_data/__init__.py +++ b/src/backend/tests/test_data/__init__.py @@ -17,3 +17,7 @@ # """Test data for debugging and test cases.""" + +import os + +test_data_path = os.path.dirname(os.path.abspath(__file__)) diff --git a/src/backend/tests/test_projects_routes.py b/src/backend/tests/test_projects_routes.py index 6fe293b149..f13df52130 100644 --- a/src/backend/tests/test_projects_routes.py +++ b/src/backend/tests/test_projects_routes.py @@ -16,6 +16,7 @@ from app.projects.project_schemas import BETAProjectUpload, ODKCentral, ProjectInfo from app.tasks import tasks_crud from app.users.user_schemas import User +from tests.test_data import test_data_path load_dotenv() @@ -131,11 +132,11 @@ def test_create_project_with_project_info(db, organization, user): def test_generate_appuser_files(db, get_ids): - custom_form = "/opt/tests/test_data/buildings.xls" + custom_form = f"{test_data_path}/buildings.xls" with open(custom_form, "rb") as file: contents = file.read() - data_extracts = "/opt/tests/test_data/building_footprint.zip" + data_extracts = f"{test_data_path}/building_footprint.zip" with zipfile.ZipFile(data_extracts, "r") as zip_archive: extract_contents = zip_archive.read("building_foot_jnk.geojson") json.loads(extract_contents)