Skip to content

Commit

Permalink
KDP-1528: Add landing page model test
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulVanSchayck committed Oct 9, 2023
1 parent 269ca0e commit 585bee9
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
File renamed without changes.
47 changes: 47 additions & 0 deletions tests/test_data/landing-page.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"links": [
{
"href": "https://api.dataplatform.knmi.nl/edr/",
"rel": "self",
"title": "Landing Page in JSON"
},
{
"href": "https://api.dataplatform.knmi.nl/edr/docs",
"rel": "service-desc",
"title": "API description in HTML"
},
{
"href": "https://api.dataplatform.knmi.nl/edr/openapi.json",
"rel": "service-desc",
"title": "API description in JSON"
},
{
"href": "https://api.dataplatform.knmi.nl/edr/conformance",
"rel": "data",
"title": "Conformance Declaration in JSON"
},
{
"href": "https://api.dataplatform.knmi.nl/edr/collections",
"rel": "data",
"title": "Collections metadata in JSON"
}
],
"title": "Observations API EDR",
"description": "The observation api in EDR format from the KNMI",
"keywords": [
"Weather",
"Temperature",
"Wind",
"Humidity",
"Pressure",
"Clouds",
"Radiation"
],
"provider": {
"name": "KNMI - Koninklijk Nederlands Meteorologisch Instituut",
"url": "dataplatform.knmi.nl"
},
"contact": {
"email": "[email protected]"
}
}
4 changes: 3 additions & 1 deletion tests/test_edr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from pathlib import Path

import pytest
from edr_pydantic.capabilities import LandingPageModel
from edr_pydantic.collections import Collections
from edr_pydantic.collections import Instance
from edr_pydantic.unit import Unit
Expand All @@ -11,6 +12,7 @@
("knmi-example-collections.json", Collections),
("doc-example-collections.json", Collections),
("simple-instance.json", Instance),
("landing-page.json", LandingPageModel),
]


Expand All @@ -33,7 +35,7 @@ def test_happy_cases(file_name, object_type):
assert object_type.model_validate_json(json_string).model_dump_json(exclude_none=True) == json_string


error_cases = [("unit-label-or-symbol.json", Unit, r"Either 'label' or 'symbol' should be set")]
error_cases = [("label-or-symbol-unit.json", Unit, r"Either 'label' or 'symbol' should be set")]


@pytest.mark.parametrize("file_name, object_type, error_message", error_cases)
Expand Down

0 comments on commit 585bee9

Please sign in to comment.