Skip to content

Commit

Permalink
Merge pull request #44 from stac-extensions/fix-dlm-mlm-prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
fmigneault authored Nov 2, 2024
2 parents 443d32b + b750dec commit a93bbec
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- n/a

### Fixed
- n/a
- Fix check of disallowed unknown/undefined `mlm:`-prefixed fields
(fixes [#41](https://github.com/stac-extensions/mlm/issues/41)).

## [v1.3.0](https://github.com/stac-extensions/mlm/tree/v1.3.0)

Expand Down
2 changes: 1 addition & 1 deletion json-schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@
},
"$comment": "Allow properties not defined by MLM prefix to allow combination with other extensions.",
"patternProperties": {
"^(?!dlm:)": {}
"^(?!mlm:)": {}
},
"additionalProperties": false
},
Expand Down
23 changes: 23 additions & 0 deletions tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,29 @@ def test_mlm_schema(
assert SCHEMA_URI in validated


@pytest.mark.parametrize(
"mlm_example",
["item_raster_bands.json"],
indirect=True,
)
def test_mlm_no_undefined_prefixed_field(
mlm_validator: STACValidator,
mlm_example: Dict[str, JSON],
) -> None:
mlm_data = copy.deepcopy(mlm_example)
mlm_item = pystac.Item.from_dict(mlm_data)
pystac.validation.validate(mlm_item, validator=mlm_validator) # ensure original is valid

mlm_data["properties"]["mlm:unknown"] = "random" # type: ignore
with pytest.raises(pystac.errors.STACValidationError) as exc:
mlm_item = pystac.Item.from_dict(mlm_data)
pystac.validation.validate(mlm_item, validator=mlm_validator)
assert all(
field in str(exc.value.source)
for field in ["mlm:unknown", "^(?!mlm:)"]
)


@pytest.mark.parametrize(
"mlm_example",
["item_raster_bands.json"],
Expand Down

0 comments on commit a93bbec

Please sign in to comment.