Skip to content

Commit 43b5ce4

Browse files
chore: Improve raster integration tests (#397)
1 parent e6f66d8 commit 43b5ce4

File tree

5 files changed

+587
-314
lines changed

5 files changed

+587
-314
lines changed
Lines changed: 263 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,263 @@
1+
"""
2+
Test fixtures and data for STAC and Raster API integration testing.
3+
"""
4+
5+
import httpx
6+
import pytest
7+
8+
SEEDED_COLLECTION = "noaa-emergency-response"
9+
SEEDED_ID = "20200307aC0853900w361030"
10+
11+
COLLECTIONS_ROUTE = "collections"
12+
INDEX_ROUTE = "index.html"
13+
DOCS_ROUTE = "docs"
14+
STAC_ENDPOINT = "http://0.0.0.0:8081"
15+
STAC_HEALTH_ENDPOINT = "http://0.0.0.0:8081/_mgmt/ping"
16+
SEARCH_ROUTE = "search"
17+
18+
RASTER_SEARCHES_ENDPOINT = "http://0.0.0.0:8082/searches"
19+
RASTER_HEALTH_ENDPOINT = "http://0.0.0.0:8082/healthz"
20+
TILEMATRIX = {"z": 15, "x": 8589, "y": 12849}
21+
22+
SEARCHES = [
23+
{
24+
"filter": {
25+
"op": "=",
26+
"args": [{"property": "collection"}, "collection1"],
27+
},
28+
"metadata": {"owner": "vincent"},
29+
},
30+
{
31+
"filter": {
32+
"op": "=",
33+
"args": [{"property": "collection"}, "collection2"],
34+
},
35+
"metadata": {"owner": "vincent"},
36+
},
37+
{
38+
"filter": {
39+
"op": "=",
40+
"args": [{"property": "collection"}, "collection3"],
41+
},
42+
"metadata": {"owner": "vincent"},
43+
},
44+
{
45+
"filter": {
46+
"op": "=",
47+
"args": [{"property": "collection"}, "collection4"],
48+
},
49+
"metadata": {"owner": "vincent"},
50+
},
51+
{
52+
"filter": {
53+
"op": "=",
54+
"args": [{"property": "collection"}, "collection5"],
55+
},
56+
"metadata": {"owner": "vincent"},
57+
},
58+
{
59+
"filter": {
60+
"op": "=",
61+
"args": [{"property": "collection"}, "collection6"],
62+
},
63+
"metadata": {"owner": "vincent"},
64+
},
65+
{
66+
"filter": {
67+
"op": "=",
68+
"args": [{"property": "collection"}, "collection7"],
69+
},
70+
"metadata": {"owner": "vincent"},
71+
},
72+
{
73+
"filter": {
74+
"op": "=",
75+
"args": [{"property": "collection"}, "collection8"],
76+
},
77+
"metadata": {"owner": "sean"},
78+
},
79+
{
80+
"filter": {
81+
"op": "=",
82+
"args": [{"property": "collection"}, "collection9"],
83+
},
84+
"metadata": {"owner": "sean"},
85+
},
86+
{
87+
"filter": {
88+
"op": "=",
89+
"args": [{"property": "collection"}, "collection10"],
90+
},
91+
"metadata": {"owner": "drew"},
92+
},
93+
{
94+
"filter": {
95+
"op": "=",
96+
"args": [{"property": "collection"}, "collection11"],
97+
},
98+
"metadata": {"owner": "drew"},
99+
},
100+
{
101+
"filter": {
102+
"op": "=",
103+
"args": [{"property": "collection"}, "collection12"],
104+
},
105+
"metadata": {"owner": "drew"},
106+
},
107+
]
108+
109+
110+
@pytest.fixture
111+
def stac_endpoint():
112+
"""
113+
Fixture providing a valid STAC url for integration testing.
114+
115+
Returns:
116+
string: A valid STAC endpoint url.
117+
"""
118+
return STAC_ENDPOINT
119+
120+
121+
@pytest.fixture
122+
def stac_health_endpoint():
123+
"""
124+
Fixture providing a health endpoint url for integration testing.
125+
126+
Returns:
127+
string: A valid url.
128+
"""
129+
return STAC_HEALTH_ENDPOINT
130+
131+
132+
@pytest.fixture
133+
def search_route():
134+
"""
135+
Fixture providing a search endpoint url for integration testing of STAC api.
136+
137+
Returns:
138+
string: A valid url.
139+
"""
140+
return SEARCH_ROUTE
141+
142+
143+
@pytest.fixture
144+
def index_route():
145+
"""
146+
Fixture providing a index endpoint url for integration testing.
147+
148+
Returns:
149+
string: A valid url.
150+
"""
151+
return INDEX_ROUTE
152+
153+
154+
@pytest.fixture
155+
def docs_route():
156+
"""
157+
Fixture providing a docs endpoint url for integration testing.
158+
159+
Returns:
160+
string: A valid url.
161+
"""
162+
return DOCS_ROUTE
163+
164+
165+
@pytest.fixture
166+
def seeded_collection():
167+
"""
168+
Fixture providing a seeded collection in .github/workflows/data
169+
170+
Returns:
171+
string: A collection
172+
"""
173+
return SEEDED_COLLECTION
174+
175+
176+
@pytest.fixture
177+
def seeded_id():
178+
"""
179+
Fixture providing a seeded collection id in .github/workflows/data
180+
181+
Returns:
182+
string: A collection ID
183+
"""
184+
return SEEDED_ID
185+
186+
187+
@pytest.fixture
188+
def collections_route():
189+
"""
190+
Fixture providing a collections endpoint url for integration testing.
191+
192+
Returns:
193+
string: A valid url
194+
"""
195+
return COLLECTIONS_ROUTE
196+
197+
198+
@pytest.fixture
199+
def raster_searches_endpoint():
200+
"""
201+
Fixture providing a collections endpoint url for integration testing.
202+
203+
Returns:
204+
string: A valid url
205+
"""
206+
return RASTER_SEARCHES_ENDPOINT
207+
208+
209+
@pytest.fixture
210+
def raster_health_endpoint():
211+
"""
212+
Fixture providing a collections endpoint url for integration testing.
213+
214+
Returns:
215+
string: A valid url
216+
"""
217+
return RASTER_HEALTH_ENDPOINT
218+
219+
220+
@pytest.fixture
221+
def seeded_tilematrix():
222+
"""
223+
Fixture providing a matrix of seeded data for integration testing.
224+
225+
Returns:
226+
dict: A [z, x, y] set of dimensions
227+
"""
228+
return TILEMATRIX
229+
230+
231+
@pytest.fixture
232+
def searches():
233+
"""
234+
Fake searches to register
235+
236+
Returns:
237+
dict: An array of searches
238+
"""
239+
return SEARCHES
240+
241+
242+
@pytest.fixture(scope="session")
243+
def collection_schema():
244+
"""Retrieve Collection Schema from
245+
246+
Returns:
247+
String: A string representation of the yaml schema
248+
"""
249+
response = httpx.get("https://api.stacspec.org/v1.0.0/collections/openapi.yaml")
250+
content = response.text
251+
return content
252+
253+
254+
@pytest.fixture(scope="session")
255+
def feature_schema():
256+
"""Retrieve Feature Schema from
257+
258+
Returns:
259+
String: A string representation of the yaml schema
260+
"""
261+
response = httpx.get("https://api.stacspec.org/v1.0.0/ogcapi-features/openapi.yaml")
262+
content = response.text
263+
return content

0 commit comments

Comments
 (0)