diff --git a/tests/__init__.py b/tests/__init__.py index 451425937..2f092beff 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -48,6 +48,9 @@ SHP_NAME = "test.shp.zip" SHP_PATH = os.path.join(os.path.dirname(__file__), "fixtures", SHP_NAME) +GPKG_NAME = "test.gpkg.zip" +GPKG_PATH = os.path.join(os.path.dirname(__file__), "fixtures", GPKG_NAME) + BUCKET = "test-bucket" PORT = 9000 diff --git a/tests/fixtures/test.gpkg.zip b/tests/fixtures/test.gpkg.zip new file mode 100644 index 000000000..10fbec156 Binary files /dev/null and b/tests/fixtures/test.gpkg.zip differ diff --git a/tests/routes/datasets/test_versions.py b/tests/routes/datasets/test_versions.py index 492903d75..8ef6b4881 100644 --- a/tests/routes/datasets/test_versions.py +++ b/tests/routes/datasets/test_versions.py @@ -7,7 +7,7 @@ from app.settings.globals import S3_ENTRYPOINT_URL from app.utils.aws import get_s3_client -from tests import BUCKET, DATA_LAKE_BUCKET, SHP_NAME +from tests import BUCKET, DATA_LAKE_BUCKET, SHP_NAME, GPKG_NAME from tests.conftest import FAKE_INT_DATA_PARAMS from tests.tasks import MockCloudfrontClient from tests.utils import ( @@ -314,7 +314,8 @@ async def test_invalid_source_uri(async_client: AsyncClient): ) # Create a version with a valid source_uri so we have something to append to - version_payload["creation_options"]["source_uri"] = [f"s3://{BUCKET}/{SHP_NAME}"] + version_payload["creation_options"]["source_uri"] = [f"s3://{BUCKET}/{GPKG_NAME}"] + version_payload["creation_options"]["layers"] = ["layer1"] await create_default_asset( dataset, version, @@ -348,6 +349,19 @@ async def test_invalid_source_uri(async_client: AsyncClient): == f"Version with name {dataset}.{bad_version} does not exist" ) + # Test appending a layer to a version + response = await async_client.post( + f"/dataset/{dataset}/{version}/append", json={"source_uri": f"s3://{BUCKET}/{GPKG_NAME}", "layers": ["layer2"]} + ) + assert response.status_code == 200 + + # Test appending to a version with missing layers + response = await async_client.post( + f"/dataset/{dataset}/{version}/append", json={"source_uri": f"s3://{BUCKET}/{GPKG_NAME}", "layers": ["layer3"]} + ) + assert response.status_code == 400 + assert response.json()["status"] == "failed" + @pytest.mark.asyncio async def test_put_latest(async_client: AsyncClient):