|
| 1 | +import copy |
1 | 2 | from typing import Any
|
2 | 3 | from typing import Dict
|
3 | 4 |
|
| 5 | +import pytest |
| 6 | + |
4 | 7 | from stac_api_validator.validations import Errors
|
5 | 8 | from stac_api_validator.validations import Warnings
|
6 | 9 | from stac_api_validator.validations import validate_core_landing_page_body
|
@@ -151,3 +154,56 @@ def test_landing_page_1() -> None:
|
151 | 154 | assert "CORE-8" not in errors
|
152 | 155 |
|
153 | 156 | # todo: item-search
|
| 157 | + |
| 158 | + |
| 159 | +@pytest.fixture |
| 160 | +def perfect_core_landing_page() -> Dict[str, Any]: |
| 161 | + return copy.deepcopy( |
| 162 | + { |
| 163 | + "conformsTo": [ |
| 164 | + "https://api.stacspec.org/v1.0.0/core", |
| 165 | + "https://api.stacspec.org/v1.0.0/collections", |
| 166 | + "https://api.stacspec.org/v1.0.0/ogcapi-features", |
| 167 | + ], |
| 168 | + "links": [ |
| 169 | + {"rel": "data", "href": "http://stac-api-validator.test/collections"} |
| 170 | + ], |
| 171 | + } |
| 172 | + ) |
| 173 | + |
| 174 | + |
| 175 | +def test_perfect_core_landing_page(perfect_core_landing_page: Dict[str, Any]) -> None: |
| 176 | + errors = Errors() |
| 177 | + warnings = Warnings() |
| 178 | + validate_core_landing_page_body( |
| 179 | + body=perfect_core_landing_page, |
| 180 | + headers={"content-type": "application/json"}, |
| 181 | + errors=errors, |
| 182 | + warnings=warnings, |
| 183 | + conformance_classes=[], |
| 184 | + collection=None, |
| 185 | + geometry=None, |
| 186 | + ) |
| 187 | + assert not errors |
| 188 | + assert not warnings |
| 189 | + |
| 190 | + |
| 191 | +def test_perfect_core_landing_page_with_extension( |
| 192 | + perfect_core_landing_page: Dict[str, Any] |
| 193 | +) -> None: |
| 194 | + errors = Errors() |
| 195 | + warnings = Warnings() |
| 196 | + perfect_core_landing_page["conformsTo"].append( |
| 197 | + "https://api.stacspec.org/v1.0.0-rc.3/ogcapi-features#fields", |
| 198 | + ) |
| 199 | + validate_core_landing_page_body( |
| 200 | + body=perfect_core_landing_page, |
| 201 | + headers={"content-type": "application/json"}, |
| 202 | + errors=errors, |
| 203 | + warnings=warnings, |
| 204 | + conformance_classes=[], |
| 205 | + collection=None, |
| 206 | + geometry=None, |
| 207 | + ) |
| 208 | + assert not errors |
| 209 | + assert not warnings |
0 commit comments