Skip to content
This repository was archived by the owner on Aug 20, 2025. It is now read-only.

Commit 42f5484

Browse files
committed
Issue #3 fix/update failing unit tests
also related to #4
1 parent 96cec28 commit 42f5484

File tree

2 files changed

+39
-12
lines changed

2 files changed

+39
-12
lines changed

tests/data/ogcapi-records/algorithm01.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@
1111
},
1212
"links": [
1313
{
14-
"rel": "udp",
14+
"rel": "openeo-process",
1515
"type": "application/json",
1616
"title": "UDP One",
1717
"href": "https://esa-apex.test/udp/algorithm01.json"
18-
}
18+
},{
19+
"rel": "service",
20+
"type": "application/json",
21+
"title": "openEO service",
22+
"href": "https://openeo.test/"
23+
}
1924
]
2025
}

tests/test_algorithms.py

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
Algorithm,
88
GithubAlgorithmRepository,
99
InvalidMetadataError,
10+
ServiceLink,
1011
UdpLink,
1112
)
1213

@@ -74,6 +75,9 @@ def test_from_ogc_api_record_minimal(self):
7475
"properties": {
7576
"type": "apex_algorithm",
7677
},
78+
"links": [
79+
{"rel": "service", "href": "https://openeo.test/"},
80+
],
7781
}
7882
algorithm = Algorithm.from_ogc_api_record(data)
7983
assert algorithm.id == "minimal"
@@ -132,7 +136,13 @@ def test_from_ogc_api_record_basic(self):
132136
"type": "application/json",
133137
"title": "Basic UDP",
134138
"href": "https://esa-apex.test/udp/basic.json",
135-
}
139+
},
140+
{
141+
"rel": "service",
142+
"type": "application/json",
143+
"title": "openEO service",
144+
"href": "https://openeo.test/",
145+
},
136146
],
137147
}
138148
algorithm = Algorithm.from_ogc_api_record(data)
@@ -143,6 +153,7 @@ def test_from_ogc_api_record_basic(self):
143153
href="https://esa-apex.test/udp/basic.json",
144154
title="Basic UDP",
145155
)
156+
assert algorithm.service_links == [ServiceLink(href="https://openeo.test/", title="openEO service")]
146157

147158
@pytest.mark.parametrize("path_type", [str, Path])
148159
def test_from_ogc_api_record_path(self, path_type):
@@ -155,6 +166,7 @@ def test_from_ogc_api_record_path(self, path_type):
155166
href="https://esa-apex.test/udp/algorithm01.json",
156167
title="UDP One",
157168
)
169+
assert algorithm.service_links == [ServiceLink(href="https://openeo.test/", title="openEO service")]
158170

159171
def test_from_ogc_api_record_str(self):
160172
dump = (DATA_ROOT / "ogcapi-records/algorithm01.json").read_text()
@@ -166,6 +178,7 @@ def test_from_ogc_api_record_str(self):
166178
href="https://esa-apex.test/udp/algorithm01.json",
167179
title="UDP One",
168180
)
181+
assert algorithm.service_links == [ServiceLink(href="https://openeo.test/", title="openEO service")]
169182

170183
def test_from_ogc_api_record_url(self, requests_mock):
171184
url = "https://esa-apex.test/algorithms/a1.json"
@@ -179,32 +192,41 @@ def test_from_ogc_api_record_url(self, requests_mock):
179192
href="https://esa-apex.test/udp/algorithm01.json",
180193
title="UDP One",
181194
)
195+
assert algorithm.service_links == [ServiceLink(href="https://openeo.test/", title="openEO service")]
182196

183197

184198
class TestGithubAlgorithmRepository:
185199
@pytest.fixture
186200
def repo(self) -> GithubAlgorithmRepository:
187201
# TODO: avoid depending on an actual GitHub repository. Mock it instead?
188202
# Or run this as an integration test?
203+
# https://github.com/ESA-APEx/esa-apex-toolbox-python/issues/4
189204
return GithubAlgorithmRepository(
190205
owner="ESA-APEx",
191206
repo="apex_algorithms",
192207
folder="algorithm_catalog",
193208
)
194209

195210
def test_list_algorithms(self, repo):
196-
assert repo.list_algorithms() == [
197-
"worldcereal.json",
198-
]
211+
listing = repo.list_algorithms()
212+
assert listing
213+
assert all(re.fullmatch(r"[a-z0-9_]+\.json", item) for item in listing)
199214

200215
def test_get_algorithm(self, repo):
201-
algorithm = repo.get_algorithm("worldcereal.json")
216+
algorithm = repo.get_algorithm("max_ndvi_composite.json")
202217
assert algorithm == Algorithm(
203-
id="worldcereal_maize",
204-
title="ESA worldcereal global maize detector",
205-
description="A maize detection algorithm.",
218+
id="max_ndvi_composite",
219+
title="Max NDVI Composite based on Sentinel-2 data",
220+
description="A compositing algorithm for Sentinel-2 L2A data, ranking observations by their maximum NDVI.",
206221
udp_link=UdpLink(
207-
href="https://github.com/ESA-APEX/apex_algorithms/blob/main/openeo_udp/worldcereal_inference.json",
208-
title="openEO UDP",
222+
href="https://raw.githubusercontent.com/ESA-APEx/apex_algorithms/main/openeo_udp/examples/max_ndvi_composite/max_ndvi_composite.json",
223+
title="openEO Process Definition",
209224
),
225+
organization="VITO",
226+
service_links=[
227+
ServiceLink(
228+
href="https://openeofed.dataspace.copernicus.eu",
229+
title="CDSE openEO federation",
230+
)
231+
],
210232
)

0 commit comments

Comments
 (0)