Skip to content

Commit

Permalink
GTC-2618 Add layer append tests
Browse files Browse the repository at this point in the history
  • Loading branch information
manukala6 committed Jan 8, 2024
1 parent ce54fc1 commit 2d9ce99
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Binary file added tests/fixtures/test.gpkg.zip
Binary file not shown.
18 changes: 16 additions & 2 deletions tests/routes/datasets/test_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 2d9ce99

Please sign in to comment.