Skip to content

Commit 58f1e1e

Browse files
committed
fix: don't warn re: version from extensions
1 parent a1a63e8 commit 58f1e1e

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

src/stac_api_validator/validations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ def validate_core_landing_page_body(
447447
x
448448
for x in conforms_to
449449
if re.match(
450-
r"https://api\.stacspec\.org/v1\.0\.0.*/(core|item-search|ogcapi-features|collections)",
450+
r"^https://api\.stacspec\.org/v1\.0\.0.*/(core|item-search|ogcapi-features|collections)$",
451451
x,
452452
)
453453
and not x.startswith(LATEST_STAC_API_FOUNDATION_VERSION)

tests/test_landing_page.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import copy
12
from typing import Any
23
from typing import Dict
34

5+
import pytest
6+
47
from stac_api_validator.validations import Errors
58
from stac_api_validator.validations import Warnings
69
from stac_api_validator.validations import validate_core_landing_page_body
@@ -151,3 +154,56 @@ def test_landing_page_1() -> None:
151154
assert "CORE-8" not in errors
152155

153156
# 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

Comments
 (0)