Skip to content

Commit

Permalink
fix: don't warn re: version from extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
gadomski committed Jun 7, 2023
1 parent a1a63e8 commit 5627541
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/stac_api_validator/validations.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def validate_core_landing_page_body(
x
for x in conforms_to
if re.match(
r"https://api\.stacspec\.org/v1\.0\.0.*/(core|item-search|ogcapi-features|collections)",
r"^https://api\.stacspec\.org/v1\.0\.0.*/(core|item-search|ogcapi-features|collections)$",
x,
)
and not x.startswith(LATEST_STAC_API_FOUNDATION_VERSION)
Expand Down
66 changes: 61 additions & 5 deletions tests/test_landing_page.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from typing import Any
from typing import Dict
import copy
from typing import Any, Dict

from stac_api_validator.validations import Errors
from stac_api_validator.validations import Warnings
from stac_api_validator.validations import validate_core_landing_page_body
import pytest
from stac_api_validator.validations import (
Errors,
Warnings,
validate_core_landing_page_body,
)


def test_landing_page_1() -> None:
Expand Down Expand Up @@ -151,3 +154,56 @@ def test_landing_page_1() -> None:
assert "CORE-8" not in errors

# todo: item-search


@pytest.fixture
def perfect_core_landing_page() -> Dict[str, Any]:
return copy.deepcopy(
{
"conformsTo": [
"https://api.stacspec.org/v1.0.0/core",
"https://api.stacspec.org/v1.0.0/collections",
"https://api.stacspec.org/v1.0.0/ogcapi-features",
],
"links": [
{"rel": "data", "href": "http://stac-api-validator.test/collections"}
],
}
)


def test_perfect_core_landing_page(perfect_core_landing_page: Dict[str, Any]) -> None:
errors = Errors()
warnings = Warnings()
validate_core_landing_page_body(
body=perfect_core_landing_page,
headers={"content-type": "application/json"},
errors=errors,
warnings=warnings,
conformance_classes=[],
collection=None,
geometry=None,
)
assert not errors
assert not warnings


def test_perfect_core_landing_page_with_extension(
perfect_core_landing_page: Dict[str, Any]
) -> None:
errors = Errors()
warnings = Warnings()
perfect_core_landing_page["conformsTo"].append(
"https://api.stacspec.org/v1.0.0-rc.3/ogcapi-features#fields",
)
validate_core_landing_page_body(
body=perfect_core_landing_page,
headers={"content-type": "application/json"},
errors=errors,
warnings=warnings,
conformance_classes=[],
collection=None,
geometry=None,
)
assert not errors
assert not warnings

0 comments on commit 5627541

Please sign in to comment.