|
5 | 5 | import jsonschema |
6 | 6 | import pytest |
7 | 7 |
|
8 | | -from marble_node_registry import update |
| 8 | +import update # type: ignore |
9 | 9 |
|
10 | 10 | GOOD_SERVICES = { |
11 | 11 | "services": [ |
12 | 12 | { |
13 | 13 | "name": "geoserver", |
| 14 | + "types": ["data", "wps", "wms", "wfs"], |
14 | 15 | "keywords": ["data", "service-wps", "service-wms", "service-wfs"], |
15 | 16 | "description": "GeoServer is a server that allows users to view and edit geospatial data.", |
16 | 17 | "links": [ |
|
20 | 21 | }, |
21 | 22 | { |
22 | 23 | "name": "weaver", |
23 | | - "keywords": ["service-ogcapi_processes"], |
| 24 | + "types": ["ogcapi_processes"], |
| 25 | + "keywords": ["service-ogcapi_processes", "some-other-keyword"], |
24 | 26 | "description": "An OGC-API flavored Execution Management Service", |
25 | 27 | "links": [ |
26 | 28 | {"rel": "service", "type": "application/json", "href": "https://daccs-uoft.example.com/weaver/"}, |
@@ -265,7 +267,7 @@ def test_last_updated_updated(self, example_node_name, example_registry_content, |
265 | 267 | example_node_name |
266 | 268 | ].get("last_updated") |
267 | 269 |
|
268 | | - def test_final_registry_valid(self, updated_registry, node_registry_schema): |
| 270 | + def test_final_registry_validity(self, updated_registry, node_registry_schema): |
269 | 271 | jsonschema.validate(instance=updated_registry.call_args.args[0], schema=node_registry_schema) |
270 | 272 |
|
271 | 273 |
|
@@ -300,7 +302,7 @@ def test_last_updated_no_change(self, example_node_name, example_registry_conten |
300 | 302 | example_node_name |
301 | 303 | ].get("last_updated") |
302 | 304 |
|
303 | | - def test_final_registry_valid(self, updated_registry, node_registry_schema): |
| 305 | + def test_final_registry_validity(self, updated_registry, node_registry_schema): |
304 | 306 | jsonschema.validate(instance=updated_registry.call_args.args[0], schema=node_registry_schema) |
305 | 307 |
|
306 | 308 |
|
@@ -350,11 +352,30 @@ class TestOnlineNodeUpdateWithInvalidServices(InvalidResponseTests, NonInitialTe |
350 | 352 | services = {"services": [{"bad_key": "some_value"}]} |
351 | 353 |
|
352 | 354 |
|
353 | | -class TestOnlineNodeUpdateWithInvalidServiceKeywords(InvalidResponseTests, NonInitialTests): |
354 | | - """Test when updates have previously been run and the reported services keywords are not valid""" |
| 355 | +class TestOnlineNodeUpdateWithInvalidServiceTypes(InvalidResponseTests, NonInitialTests): |
| 356 | + """Test when updates have previously been run and the reported services types are not valid""" |
355 | 357 |
|
356 | 358 | services = deepcopy(GOOD_SERVICES) |
357 | 359 |
|
358 | 360 | @pytest.fixture(scope="class", autouse=True) |
359 | | - def bad_keywords(self): |
360 | | - self.services["services"][0]["keywords"] = ["something-bad"] |
| 361 | + def bad_types(self): |
| 362 | + self.services["services"][0]["types"] = ["something-bad"] |
| 363 | + |
| 364 | + |
| 365 | +class TestOnlineNodeUpdateWithNoTypes(ValidResponseTests, NonInitialTests): |
| 366 | + """ |
| 367 | + Test when updates have previously been run and there are no services types |
| 368 | +
|
| 369 | + This ensures that service types are updated as expected from the provided keywords |
| 370 | + """ |
| 371 | + |
| 372 | + services = deepcopy(GOOD_SERVICES) |
| 373 | + |
| 374 | + @pytest.fixture(scope="class", autouse=True) |
| 375 | + def no_types(self): |
| 376 | + for service in self.services["services"]: |
| 377 | + service.pop("types") |
| 378 | + |
| 379 | + def test_services_updated(self, example_node_name, updated_registry): |
| 380 | + """Test that the services values are updated""" |
| 381 | + assert updated_registry.call_args.args[0][example_node_name]["services"] == GOOD_SERVICES["services"] |
0 commit comments