Skip to content

Commit 1080c92

Browse files
committed
add tests
1 parent 42709e1 commit 1080c92

File tree

3 files changed

+206
-0
lines changed

3 files changed

+206
-0
lines changed

tests/test_core.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,37 @@ def test_core_item_local_v100():
174174
"validation_method": "core",
175175
}
176176
]
177+
178+
def test_core_collection_local_v110():
179+
stac_file = "tests/test_data/v110/collection.json"
180+
stac = stac_validator.StacValidate(stac_file, core=True)
181+
stac.run()
182+
assert stac.message == [
183+
{
184+
"version": "1.1.0",
185+
"path": "tests/test_data/v110/collection.json",
186+
"schema": [
187+
"https://schemas.stacspec.org/v1.1.0/collection-spec/json-schema/collection.json"
188+
],
189+
"valid_stac": True,
190+
"asset_type": "COLLECTION",
191+
"validation_method": "core",
192+
}
193+
]
194+
195+
def test_core_item_local_v110():
196+
stac_file = "tests/test_data/v110/simple-item.json"
197+
stac = stac_validator.StacValidate(stac_file, core=True)
198+
stac.run()
199+
assert stac.message == [
200+
{
201+
"version": "1.1.0",
202+
"path": "tests/test_data/v110/simple-item.json",
203+
"schema": [
204+
"https://schemas.stacspec.org/v1.1.0/item-spec/json-schema/item.json"
205+
],
206+
"valid_stac": True,
207+
"asset_type": "ITEM",
208+
"validation_method": "core",
209+
}
210+
]

tests/test_data/v110/collection.json

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
{
2+
"id": "simple-collection",
3+
"type": "Collection",
4+
"stac_extensions": [
5+
"https://stac-extensions.github.io/eo/v2.0.0/schema.json",
6+
"https://stac-extensions.github.io/projection/v2.0.0/schema.json",
7+
"https://stac-extensions.github.io/view/v1.0.0/schema.json"
8+
],
9+
"stac_version": "1.1.0",
10+
"description": "A simple collection demonstrating core catalog fields with links to a couple of items",
11+
"title": "Simple Example Collection",
12+
"keywords": ["simple", "example", "collection"],
13+
"providers": [
14+
{
15+
"name": "Remote Data, Inc",
16+
"description": "Producers of awesome spatiotemporal assets",
17+
"roles": ["producer", "processor"],
18+
"url": "http://remotedata.io"
19+
}
20+
],
21+
"extent": {
22+
"spatial": {
23+
"bbox": [
24+
[
25+
172.91173669923782, 1.3438851951615003, 172.95469614953714,
26+
1.3690476620161975
27+
]
28+
]
29+
},
30+
"temporal": {
31+
"interval": [["2020-12-11T22:38:32.125Z", "2020-12-14T18:02:31.437Z"]]
32+
}
33+
},
34+
"license": "CC-BY-4.0",
35+
"summaries": {
36+
"platform": ["cool_sat1", "cool_sat2"],
37+
"constellation": ["ion"],
38+
"instruments": ["cool_sensor_v1", "cool_sensor_v2"],
39+
"gsd": {
40+
"minimum": 0.512,
41+
"maximum": 0.66
42+
},
43+
"eo:cloud_cover": {
44+
"minimum": 1.2,
45+
"maximum": 1.2
46+
},
47+
"proj:cpde": ["EPSG:32659"],
48+
"view:sun_elevation": {
49+
"minimum": 54.9,
50+
"maximum": 54.9
51+
},
52+
"view:off_nadir": {
53+
"minimum": 3.8,
54+
"maximum": 3.8
55+
},
56+
"view:sun_azimuth": {
57+
"minimum": 135.7,
58+
"maximum": 135.7
59+
},
60+
"statistics": {
61+
"type": "object",
62+
"properties": {
63+
"vegetation": {
64+
"description": "Percentage of pixels that are detected as vegetation, e.g. forests, grasslands, etc.",
65+
"minimum": 0,
66+
"maximum": 100
67+
},
68+
"water": {
69+
"description": "Percentage of pixels that are detected as water, e.g. rivers, oceans and ponds.",
70+
"minimum": 0,
71+
"maximum": 100
72+
},
73+
"urban": {
74+
"description": "Percentage of pixels that detected as urban, e.g. roads and buildings.",
75+
"minimum": 0,
76+
"maximum": 100
77+
}
78+
}
79+
}
80+
},
81+
"links": [
82+
{
83+
"rel": "root",
84+
"href": "./collection.json",
85+
"type": "application/json",
86+
"title": "Simple Example Collection"
87+
},
88+
{
89+
"rel": "item",
90+
"href": "./simple-item.json",
91+
"type": "application/geo+json",
92+
"title": "Simple Item"
93+
},
94+
{
95+
"rel": "item",
96+
"href": "./core-item.json",
97+
"type": "application/geo+json",
98+
"title": "Core Item"
99+
},
100+
{
101+
"rel": "item",
102+
"href": "./extended-item.json",
103+
"type": "application/geo+json",
104+
"title": "Extended Item"
105+
},
106+
{
107+
"rel": "self",
108+
"href": "https://raw.githubusercontent.com/radiantearth/stac-spec/v1.1.0/examples/collection.json",
109+
"type": "application/json"
110+
}
111+
]
112+
}

tests/test_data/v110/simple-item.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"stac_version": "1.1.0",
3+
"stac_extensions": [],
4+
"type": "Feature",
5+
"id": "20201211_223832_CS2",
6+
"bbox": [
7+
172.91173669923782, 1.3438851951615003, 172.95469614953714,
8+
1.3690476620161975
9+
],
10+
"geometry": {
11+
"type": "Polygon",
12+
"coordinates": [
13+
[
14+
[172.91173669923782, 1.3438851951615003],
15+
[172.95469614953714, 1.3438851951615003],
16+
[172.95469614953714, 1.3690476620161975],
17+
[172.91173669923782, 1.3690476620161975],
18+
[172.91173669923782, 1.3438851951615003]
19+
]
20+
]
21+
},
22+
"properties": {
23+
"datetime": "2020-12-11T22:38:32.125000Z"
24+
},
25+
"collection": "simple-collection",
26+
"links": [
27+
{
28+
"rel": "collection",
29+
"href": "./collection.json",
30+
"type": "application/json",
31+
"title": "Simple Example Collection"
32+
},
33+
{
34+
"rel": "root",
35+
"href": "./collection.json",
36+
"type": "application/json",
37+
"title": "Simple Example Collection"
38+
},
39+
{
40+
"rel": "parent",
41+
"href": "./collection.json",
42+
"type": "application/json",
43+
"title": "Simple Example Collection"
44+
}
45+
],
46+
"assets": {
47+
"visual": {
48+
"href": "https://storage.googleapis.com/open-cogs/stac-examples/20201211_223832_CS2.tif",
49+
"type": "image/tiff; application=geotiff; profile=cloud-optimized",
50+
"title": "3-Band Visual",
51+
"roles": ["visual"]
52+
},
53+
"thumbnail": {
54+
"href": "https://storage.googleapis.com/open-cogs/stac-examples/20201211_223832_CS2.jpg",
55+
"title": "Thumbnail",
56+
"type": "image/jpeg",
57+
"roles": ["thumbnail"]
58+
}
59+
}
60+
}

0 commit comments

Comments
 (0)