Skip to content

Commit

Permalink
Merge branch 'norm-type' of github.com:stac-extensions/mlm into norm-…
Browse files Browse the repository at this point in the history
…type
  • Loading branch information
fmigneault committed Nov 5, 2024
2 parents 0cc32e9 + 1bbb828 commit 970f610
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
Otherwise, the amount of `value_scaling` objects should match the number of bands or channels involved in the input.

### 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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ unavailable from [Band Statistics][stac-1.1-stats], such as `value`-specific sca

| Field Name | Type | Description |
|------------|--------|----------------------------------------------------------------------------------------------------------------------------------------|
| name | string | **REQUIRED** Name of the band referring to an extended band definition (see [Bands](#bands-and-statistics). |
| name | string | **REQUIRED** Name of the band referring to an extended band definition (see [Bands](#bands-and-statistics) details). |
| format | string | The type of expression that is specified in the `expression` property. |
| expression | \* | An expression compliant with the `format` specified. The expression can be applied to any data type and depends on the `format` given. |

Expand Down
2 changes: 1 addition & 1 deletion best-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ A potential representation of a STAC Asset could be as follows:
Furthermore, the STAC Item representing the derived product could also include
a [Link Object](https://github.com/radiantearth/stac-spec/tree/master/item-spec/item-spec.md#link-object)
referring back to the MLM definition using `rel: derived_from`, as described in
[MLM Relation Types](README.md#relation-types). Such a link would like something like the following:
[MLM Relation Types](README.md#relation-types). Such a link would look something like the following:

```json
{
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 970f610

Please sign in to comment.