Skip to content

Commit

Permalink
test: use relative test_data_path over abs paths
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Oct 12, 2023
1 parent 629d9e1 commit c81b286
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/backend/tests/test_data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@
#

"""Test data for debugging and test cases."""

import os

test_data_path = os.path.dirname(os.path.abspath(__file__))
5 changes: 3 additions & 2 deletions src/backend/tests/test_projects_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c81b286

Please sign in to comment.