Skip to content

Commit 9f0d4fa

Browse files
committed
Added examples for testing
1 parent 1c02434 commit 9f0d4fa

File tree

3 files changed

+59
-4
lines changed

3 files changed

+59
-4
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,8 @@ class ServiceAccessRights(BaseModel):
363363

364364

365365
class ServiceMetaData(ServiceCommonData):
366-
# for a partial update all members must be Optional
366+
# Overrides all fields of ServiceCommonData:
367+
# - for a partial update all members must be Optional
367368
name: Optional[str]
368369
thumbnail: Optional[HttpUrl]
369370
description: Optional[str]

services/catalog/src/simcore_service_catalog/models/schemas/services.py

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,57 @@
1111

1212
# OpenAPI models (contain both service metadata and access rights)
1313
class ServiceUpdate(ServiceMetaData, ServiceAccessRights):
14-
pass
14+
class Config:
15+
schema_extra = {
16+
"examples": [
17+
{
18+
# ServiceAccessRights
19+
"access_rights": {
20+
1: {
21+
"execute_access": False,
22+
"write_access": False,
23+
},
24+
2: {
25+
"execute_access": True,
26+
"write_access": True,
27+
},
28+
44: {
29+
"execute_access": False,
30+
"write_access": False,
31+
},
32+
},
33+
# ServiceMetaData = ServiceCommonData +
34+
"name": "My Human Readable Service Name",
35+
"thumbnail": None,
36+
"description": "An interesting service that does something",
37+
"classifiers": ["RRID:SCR_018997", "RRID:SCR_019001"],
38+
"quality": {
39+
"tsr": {
40+
"r01": {"level": 3, "references": ""},
41+
"r02": {"level": 2, "references": ""},
42+
"r03": {"level": 0, "references": ""},
43+
"r04": {"level": 0, "references": ""},
44+
"r05": {"level": 2, "references": ""},
45+
"r06": {"level": 0, "references": ""},
46+
"r07": {"level": 0, "references": ""},
47+
"r08": {"level": 1, "references": ""},
48+
"r09": {"level": 0, "references": ""},
49+
"r10": {"level": 0, "references": ""},
50+
},
51+
"enabled": True,
52+
"annotations": {
53+
"vandv": "",
54+
"purpose": "",
55+
"standards": "",
56+
"limitations": "",
57+
"documentation": "",
58+
"certificationLink": "",
59+
"certificationStatus": "Uncertified",
60+
},
61+
},
62+
}
63+
]
64+
}
1565

1666

1767
class ServiceOut(

services/catalog/tests/unit/test_models_schemas_services.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44
from pprint import pformat
55

66
import pytest
7-
from simcore_service_catalog.models.schemas.services import ServiceOut, ServiceUpdate
7+
from simcore_service_catalog.models.schemas.services import (
8+
ServiceItem,
9+
ServiceOut,
10+
ServiceUpdate,
11+
)
812

913

10-
@pytest.mark.parametrize("model_cls", (ServiceOut, ServiceUpdate))
14+
@pytest.mark.parametrize("model_cls", (ServiceOut, ServiceUpdate, ServiceItem))
1115
def test_service_api_models_examples(model_cls, model_cls_examples):
1216
for name, example in model_cls_examples.items():
1317
print(name, ":", pformat(example))

0 commit comments

Comments
 (0)