33# pylint: disable=unused-variable
44# pylint: disable=too-many-arguments
55
6- import json
76from urllib .parse import quote
87
98import httpx
109from fastapi import status
1110from fixtures .fake_services import ServiceInRegistryInfoDict
12- from helpers import json_schema_validator
13- from simcore_service_director import resources
11+ from models_library .api_schemas_director .services import ServiceDataGet
1412
1513
1614def _assert_response_and_unwrap_envelope (got : httpx .Response ):
@@ -35,20 +33,12 @@ def _assert_services(
3533 for s in expected
3634 ]
3735
38- # TODO: check these are correct!
39- json_schema_path = resources .get_path (resources .RESOURCE_NODE_SCHEMA )
40- assert json_schema_path .exists () is True
41- with json_schema_path .open () as file_pt :
42- service_schema = json .load (file_pt )
43-
44- for service in got :
45- service .pop ("image_digest" , None )
46- if schema_version == "v1" :
47- assert (
48- expected_key_version_tuples .count ((service ["key" ], service ["version" ]))
49- == 1
50- )
51- json_schema_validator .validate_instance_object (service , service_schema )
36+ for data in got :
37+ service = ServiceDataGet .parse_obj (data )
38+ assert (
39+ expected_key_version_tuples .count ((f"{ service .key } " , f"{ service .version } " ))
40+ == 1
41+ )
5242
5343
5444async def test_list_services_with_empty_registry (
@@ -60,7 +50,7 @@ async def test_list_services_with_empty_registry(
6050
6151 # empty case
6252 resp = await client .get (f"/{ api_version_prefix } /services" )
63- assert resp .status_code == status .HTTP_200_OK
53+ assert resp .status_code == status .HTTP_200_OK , f"Got f { resp . text } "
6454
6555 services , error = _assert_response_and_unwrap_envelope (resp .json ())
6656 assert not error
@@ -78,7 +68,7 @@ async def test_list_services(
7868 assert docker_registry , "docker-registry is not ready?"
7969
8070 resp = await client .get (f"/{ api_version_prefix } /services" )
81- assert resp .status_code == status .HTTP_200_OK
71+ assert resp .status_code == status .HTTP_200_OK , f"Got f { resp . text } "
8272
8373 services , error = _assert_response_and_unwrap_envelope (resp .json ())
8474 assert not error
@@ -97,7 +87,7 @@ async def test_get_service_bad_request(
9787 assert len (created_services ) > 0
9888
9989 resp = await client .get (f"/{ api_version_prefix } /services?service_type=blahblah" )
100- assert resp .status_code == status .HTTP_400_BAD_REQUEST
90+ assert resp .status_code == status .HTTP_400_BAD_REQUEST , f"Got f { resp . text } "
10191
10292 services , error = _assert_response_and_unwrap_envelope (resp .json ())
10393 assert not services
@@ -116,15 +106,15 @@ async def test_list_services_by_service_type(
116106 resp = await client .get (
117107 f"/{ api_version_prefix } /services?service_type=computational"
118108 )
119- assert resp .status_code == status .HTTP_200_OK
109+ assert resp .status_code == status .HTTP_200_OK , f"Got f { resp . text } "
120110
121111 services , error = _assert_response_and_unwrap_envelope (resp .json ())
122112 assert not error
123113 assert services
124114 assert len (services ) == 3
125115
126116 resp = await client .get (f"/{ api_version_prefix } /services?service_type=interactive" )
127- assert resp .status_code == status .HTTP_200_OK
117+ assert resp .status_code == status .HTTP_200_OK , f"Got f { resp . text } "
128118
129119 services , error = _assert_response_and_unwrap_envelope (resp .json ())
130120 assert not error
@@ -136,17 +126,17 @@ async def test_get_services_by_key_and_version_with_empty_registry(
136126 client : httpx .AsyncClient , api_version_prefix : str
137127):
138128 resp = await client .get (f"/{ api_version_prefix } /services/whatever/someversion" )
139- assert resp .status_code == status .HTTP_400_BAD_REQUEST
129+ assert resp .status_code == status .HTTP_400_BAD_REQUEST , f"Got f { resp . text } "
140130
141131 resp = await client .get (
142132 f"/{ api_version_prefix } /services/simcore/services/dynamic/something/someversion"
143133 )
144- assert resp .status_code == status .HTTP_404_NOT_FOUND
134+ assert resp .status_code == status .HTTP_404_NOT_FOUND , f"Got f { resp . text } "
145135
146136 resp = await client .get (
147137 f"/{ api_version_prefix } /services/simcore/services/dynamic/something/1.5.2"
148138 )
149- assert resp .status_code == status .HTTP_404_NOT_FOUND
139+ assert resp .status_code == status .HTTP_404_NOT_FOUND , f"Got f { resp . text } "
150140
151141
152142async def test_get_services_by_key_and_version (
0 commit comments