Skip to content

Commit

Permalink
[#38] updating tests to check for field None value
Browse files Browse the repository at this point in the history
  • Loading branch information
pkdash committed Sep 26, 2023
1 parent c68dd11 commit f993e4b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/test_core_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,13 +505,18 @@ async def test_core_schema_spatial_coverage_value_type(core_data, core_model, da
assert core_model_instance.spatialCoverage.type == "Place"
if "name" in data_format:
assert core_model_instance.spatialCoverage.name == data_format["name"]
else:
assert core_model_instance.spatialCoverage.name is None
if "geo" in data_format:
if data_format["geo"]["@type"] == "GeoCoordinates":
assert core_model_instance.spatialCoverage.geo.latitude == data_format["geo"]["latitude"]
assert core_model_instance.spatialCoverage.geo.longitude == data_format["geo"]["longitude"]
elif data_format["geo"]["@type"] == "GeoShape":
assert core_model_instance.spatialCoverage.geo.box == data_format["geo"]["box"]

else:
assert core_model_instance.spatialCoverage.geo is None


@pytest.mark.parametrize('include_creative_works', [True, False])
@pytest.mark.asyncio
Expand Down Expand Up @@ -649,8 +654,13 @@ async def test_core_schema_license_optional_attributes(core_data, core_model, da
assert core_model_instance.license.name == data_format["name"]
if "url" in data_format:
assert core_model_instance.license.url == data_format["url"]
else:
assert core_model_instance.license.url is None

if "description" in data_format:
assert core_model_instance.license.description == data_format["description"]
else:
assert core_model_instance.license.description is None


@pytest.mark.parametrize('is_multiple', [True, False, None])
Expand Down Expand Up @@ -865,8 +875,13 @@ async def test_core_schema_is_part_of_optional_attributes(core_data, core_model,
assert core_model_instance.isPartOf[0].name == data_format["name"]
if "description" in data_format:
assert core_model_instance.isPartOf[0].description == data_format["description"]
else:
assert core_model_instance.isPartOf[0].description is None

if "url" in data_format:
assert core_model_instance.isPartOf[0].url == data_format["url"]
else:
assert core_model_instance.isPartOf[0].url is None


@pytest.mark.parametrize('dt_type', ["datetime", None])
Expand Down
2 changes: 2 additions & 0 deletions tests/test_dataset_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ async def test_get_datasets_exclude_none(client_test, dataset_data):
"""Testing exclude none is applied to dataset response model"""

dataset_data["version"] = None
dataset_data["spatialCoverage"]["name"] = None
# add a dataset record to the db
dataset_response = await client_test.post("api/catalog/dataset", json=dataset_data)
assert dataset_response.status_code == 201
Expand All @@ -153,6 +154,7 @@ async def test_get_datasets_exclude_none(client_test, dataset_data):
assert dataset_response.status_code == 200
dataset_response_data = dataset_response.json()
assert "version" not in dataset_response_data[0]
assert "name" not in dataset_response_data[0]["spatialCoverage"]


@pytest.mark.parametrize("multiple", [True, False])
Expand Down

0 comments on commit f993e4b

Please sign in to comment.