def test_normalize_collection_metadata_no_id(self, caplog): with pytest.raises(KeyError): _normalize_collection_metadata( {"foo": "bar"}, api_version=ComparableVersion("1.0.0")) errors = [ r.getMessage() for r in caplog.records if r.levelno == logging.ERROR ] assert any("should have 'id' field" in m for m in errors)
def test_normalize_collection_metadata_minimal_100(self, caplog): assert _normalize_collection_metadata( {"id": "foobar"}, api_version=ComparableVersion("1.0.0")) == { 'id': 'foobar', 'stac_version': '0.9.0', 'description': 'foobar', 'extent': { 'spatial': [0, 0, 0, 0], 'temporal': [None, None] }, 'license': 'proprietary', 'links': [], } warnings = set(r.getMessage() for r in caplog.records if r.levelno == logging.WARN) assert warnings == { "Collection 'foobar' metadata does not have field 'extent'." }
def test_normalize_collection_metadata_dimensions_and_bands_100( self, caplog): metadata = { "id": "foobar", "properties": { "cube:dimensions": { "x": { "type": "spatial" }, "b": { "type": "bands", "values": ["B02", "B03"] } }, "eo:bands": [{ "name": "B02" }, { "name": "B03" }] } } res = _normalize_collection_metadata( metadata, api_version=ComparableVersion("1.0.0"), full=True) assert res["cube:dimensions"] == { "x": { "type": "spatial" }, "b": { "type": "bands", "values": ["B02", "B03"] } } assert res["summaries"]["eo:bands"] == [{ "name": "B02" }, { "name": "B03" }]