Skip to content

Commit

Permalink
test: add additional entities tests for failures
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Apr 19, 2024
1 parent f6d4a4e commit 858d68b
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion tests/test_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

from datetime import datetime, timezone

import pytest


async def test_entity_modify(odk_entity_cleanup):
"""Test modifying an entity."""
Expand All @@ -36,6 +38,29 @@ async def test_entity_modify(odk_entity_cleanup):
assert new_data.get("project_id") == "100"


async def test_create_invalid_entities(odk_entity_cleanup):
"""Test uploading invalid data to an entity (HTTP 400)."""
odk_id, dataset_name, entity_uuid, entity = odk_entity_cleanup
async with entity:
# NOTE entity must have a geometry data field
with pytest.raises(ValueError):
await entity.createEntity(odk_id, dataset_name, label="test", data={"status": 0})

# NOTE data fields cannot be integer, this should 400 response
invalid_data_type = await entity.createEntity(odk_id, dataset_name, label="test", data={"geometry": "", "status": 0})
assert invalid_data_type == {}

bulk_entities_one_invaid = await entity.createEntities(
odk_id,
dataset_name,
{
"test entity 2": {"osm_id": 55, "geometry": "test"},
"test entity 3": {"osm_id": "66", "geometry": "test"},
},
)
assert len(bulk_entities_one_invaid) == 1


async def test_bulk_create_entity_count(odk_entity_cleanup):
"""Test bulk creation of Entities."""
odk_id, dataset_name, entity_uuid, entity = odk_entity_cleanup
Expand All @@ -52,7 +77,8 @@ async def test_bulk_create_entity_count(odk_entity_cleanup):
entity_count = await entity.getEntityCount(odk_id, dataset_name)

assert created_entities[0].get("currentVersion").get("data").get("geometry") == "test"
assert entity_count == 4
# NOTE this may be cumulative from the session... either 4 or 5
assert entity_count >= 4


async def test_get_entity_data(odk_entity_cleanup):
Expand Down

0 comments on commit 858d68b

Please sign in to comment.