Skip to content

Commit fe07925

Browse files
committed
adds examples and adapts rpc tests
1 parent 86d9f68 commit fe07925

File tree

3 files changed

+41
-1
lines changed
  • packages
    • models-library/src/models_library/api_schemas_catalog
    • service-library/src/servicelib/rabbitmq/rpc_interfaces/catalog
  • services/catalog/tests/unit/with_dbs

3 files changed

+41
-1
lines changed

packages/models-library/src/models_library/api_schemas_catalog/services.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,39 @@ class MyServicesRpcBatchGet(
427427
):
428428
"""Result for batch get user services operations"""
429429

430+
@staticmethod
431+
def _update_json_schema_extra(schema: JsonDict) -> None:
432+
missing: Any = [("simcore/services/comp/itis/sleeper", "100.2.3")]
433+
schema.update(
434+
{
435+
"examples": [
436+
{
437+
"found_items": [
438+
{
439+
"key": "simcore/services/comp/itis/sleeper",
440+
"release": {
441+
"version": "2.2.1",
442+
"version_display": "Summer Release",
443+
"released": "2024-07-21T15:00:00",
444+
},
445+
"owner": 42,
446+
"my_access_rights": {
447+
"execute": True,
448+
"write": False,
449+
},
450+
}
451+
],
452+
"missing_identifiers": missing,
453+
}
454+
]
455+
}
456+
)
457+
458+
model_config = ConfigDict(
459+
extra="forbid",
460+
json_schema_extra=_update_json_schema_extra,
461+
)
462+
430463

431464
class ServiceListFilters(Filters):
432465
service_type: Annotated[

packages/service-library/src/servicelib/rabbitmq/rpc_interfaces/catalog/errors.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ class CatalogForbiddenError(CatalogApiBaseError):
1919

2020
class CatalogNotAvailableError(CatalogApiBaseError):
2121
msg_template = "Catalog service failed unexpectedly"
22+
23+
24+
class CatalogBadRequestError(CatalogApiBaseError):
25+
msg_template = "Bad request on {name}: {reason}"

services/catalog/tests/unit/with_dbs/test_api_rpc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,13 +608,16 @@ async def test_rpc_batch_get_my_services(
608608
(other_service_key, other_service_version),
609609
]
610610

611-
my_services = await catalog_rpc.batch_get_my_services(
611+
batch_got = await catalog_rpc.batch_get_my_services(
612612
rpc_client,
613613
product_name=product_name,
614614
user_id=user_id,
615615
ids=ids,
616616
)
617617

618+
my_services = batch_got.found_items
619+
assert batch_got.missing_identifiers == []
620+
618621
assert len(my_services) == 2
619622

620623
# Check access rights to all of them

0 commit comments

Comments
 (0)