Skip to content

Commit

Permalink
Only load test data once
Browse files Browse the repository at this point in the history
  • Loading branch information
robbibt committed Oct 9, 2024
1 parent 7afa8d3 commit 614159b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ test-model: ## Test model module with pytest
@echo "🚀 Testing model module: Running pytest"
@tar --skip-old-files -xzf ./tests/data/tide_models.tar.gz -C ./tests/data
@export EO_TIDES_TIDE_MODELS=./tests/data/tide_models && \
uv run python -m pytest tests/test_model.py
uv run python -m pytest tests/test_model.py --verbose

.PHONY: test-eo
test-eo: ## Test eo module with pytest
@echo "🚀 Testing eo module: Running pytest"
@tar --skip-old-files -xzf ./tests/data/tide_models.tar.gz -C ./tests/data
@export EO_TIDES_TIDE_MODELS=./tests/data/tide_models && \
uv run python -m pytest tests/test_eo.py
uv run python -m pytest tests/test_eo.py --verbose

.PHONY: test-notebooks
test-notebooks: ## Test notebooks with pytest
Expand Down
14 changes: 13 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
This module contains shared fixtures for eo_tides tests.
"""

from copy import deepcopy

import odc.stac
import pandas as pd
import pystac_client
Expand Down Expand Up @@ -47,8 +49,9 @@ def measured_tides_ds():
("EPSG:4326", 0.00025), # WGS84, 0.0025 degree pixels
],
ids=["satellite_ds_epsg3577", "satellite_ds_epsg4326"],
scope="session", # only load data once, but copy for each test
)
def satellite_ds(request):
def satellite_ds_load(request):
"""
Load a sample timeseries of Landsat 8 data using odc-stac
"""
Expand Down Expand Up @@ -85,3 +88,12 @@ def satellite_ds(request):
)

return ds


@pytest.fixture
def satellite_ds(satellite_ds_load):
"""
Make a copy of the previously loaded satellite data for
each test to ensure each test is independent
"""
return deepcopy(satellite_ds_load)

0 comments on commit 614159b

Please sign in to comment.