Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhealy1 committed Oct 8, 2024
1 parent 42709e1 commit 1080c92
Show file tree
Hide file tree
Showing 3 changed files with 206 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,37 @@ def test_core_item_local_v100():
"validation_method": "core",
}
]

def test_core_collection_local_v110():
stac_file = "tests/test_data/v110/collection.json"
stac = stac_validator.StacValidate(stac_file, core=True)
stac.run()
assert stac.message == [
{
"version": "1.1.0",
"path": "tests/test_data/v110/collection.json",
"schema": [
"https://schemas.stacspec.org/v1.1.0/collection-spec/json-schema/collection.json"
],
"valid_stac": True,
"asset_type": "COLLECTION",
"validation_method": "core",
}
]

def test_core_item_local_v110():
stac_file = "tests/test_data/v110/simple-item.json"
stac = stac_validator.StacValidate(stac_file, core=True)
stac.run()
assert stac.message == [
{
"version": "1.1.0",
"path": "tests/test_data/v110/simple-item.json",
"schema": [
"https://schemas.stacspec.org/v1.1.0/item-spec/json-schema/item.json"
],
"valid_stac": True,
"asset_type": "ITEM",
"validation_method": "core",
}
]
112 changes: 112 additions & 0 deletions tests/test_data/v110/collection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
"id": "simple-collection",
"type": "Collection",
"stac_extensions": [
"https://stac-extensions.github.io/eo/v2.0.0/schema.json",
"https://stac-extensions.github.io/projection/v2.0.0/schema.json",
"https://stac-extensions.github.io/view/v1.0.0/schema.json"
],
"stac_version": "1.1.0",
"description": "A simple collection demonstrating core catalog fields with links to a couple of items",
"title": "Simple Example Collection",
"keywords": ["simple", "example", "collection"],
"providers": [
{
"name": "Remote Data, Inc",
"description": "Producers of awesome spatiotemporal assets",
"roles": ["producer", "processor"],
"url": "http://remotedata.io"
}
],
"extent": {
"spatial": {
"bbox": [
[
172.91173669923782, 1.3438851951615003, 172.95469614953714,
1.3690476620161975
]
]
},
"temporal": {
"interval": [["2020-12-11T22:38:32.125Z", "2020-12-14T18:02:31.437Z"]]
}
},
"license": "CC-BY-4.0",
"summaries": {
"platform": ["cool_sat1", "cool_sat2"],
"constellation": ["ion"],
"instruments": ["cool_sensor_v1", "cool_sensor_v2"],
"gsd": {
"minimum": 0.512,
"maximum": 0.66
},
"eo:cloud_cover": {
"minimum": 1.2,
"maximum": 1.2
},
"proj:cpde": ["EPSG:32659"],
"view:sun_elevation": {
"minimum": 54.9,
"maximum": 54.9
},
"view:off_nadir": {
"minimum": 3.8,
"maximum": 3.8
},
"view:sun_azimuth": {
"minimum": 135.7,
"maximum": 135.7
},
"statistics": {
"type": "object",
"properties": {
"vegetation": {
"description": "Percentage of pixels that are detected as vegetation, e.g. forests, grasslands, etc.",
"minimum": 0,
"maximum": 100
},
"water": {
"description": "Percentage of pixels that are detected as water, e.g. rivers, oceans and ponds.",
"minimum": 0,
"maximum": 100
},
"urban": {
"description": "Percentage of pixels that detected as urban, e.g. roads and buildings.",
"minimum": 0,
"maximum": 100
}
}
}
},
"links": [
{
"rel": "root",
"href": "./collection.json",
"type": "application/json",
"title": "Simple Example Collection"
},
{
"rel": "item",
"href": "./simple-item.json",
"type": "application/geo+json",
"title": "Simple Item"
},
{
"rel": "item",
"href": "./core-item.json",
"type": "application/geo+json",
"title": "Core Item"
},
{
"rel": "item",
"href": "./extended-item.json",
"type": "application/geo+json",
"title": "Extended Item"
},
{
"rel": "self",
"href": "https://raw.githubusercontent.com/radiantearth/stac-spec/v1.1.0/examples/collection.json",
"type": "application/json"
}
]
}
60 changes: 60 additions & 0 deletions tests/test_data/v110/simple-item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"stac_version": "1.1.0",
"stac_extensions": [],
"type": "Feature",
"id": "20201211_223832_CS2",
"bbox": [
172.91173669923782, 1.3438851951615003, 172.95469614953714,
1.3690476620161975
],
"geometry": {
"type": "Polygon",
"coordinates": [
[
[172.91173669923782, 1.3438851951615003],
[172.95469614953714, 1.3438851951615003],
[172.95469614953714, 1.3690476620161975],
[172.91173669923782, 1.3690476620161975],
[172.91173669923782, 1.3438851951615003]
]
]
},
"properties": {
"datetime": "2020-12-11T22:38:32.125000Z"
},
"collection": "simple-collection",
"links": [
{
"rel": "collection",
"href": "./collection.json",
"type": "application/json",
"title": "Simple Example Collection"
},
{
"rel": "root",
"href": "./collection.json",
"type": "application/json",
"title": "Simple Example Collection"
},
{
"rel": "parent",
"href": "./collection.json",
"type": "application/json",
"title": "Simple Example Collection"
}
],
"assets": {
"visual": {
"href": "https://storage.googleapis.com/open-cogs/stac-examples/20201211_223832_CS2.tif",
"type": "image/tiff; application=geotiff; profile=cloud-optimized",
"title": "3-Band Visual",
"roles": ["visual"]
},
"thumbnail": {
"href": "https://storage.googleapis.com/open-cogs/stac-examples/20201211_223832_CS2.jpg",
"title": "Thumbnail",
"type": "image/jpeg",
"roles": ["thumbnail"]
}
}
}

0 comments on commit 1080c92

Please sign in to comment.