Skip to content

Commit

Permalink
@sanderegg review: replaced name by key
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov committed Oct 31, 2022
1 parent 27e03eb commit 21677ff
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def _guess_media_type(io: Union[ServiceInput, ServiceOutput]) -> str:


class ServicePortGet(BaseModel):
name: str = Field(
key: str = Field(
..., description="port identifier name", regex=PUBLIC_VARIABLE_NAME_RE
)
kind: PortKindStr
Expand All @@ -70,7 +70,7 @@ class ServicePortGet(BaseModel):
class Config:
schema_extra = {
"example": {
"name": "input_1",
"key": "input_1",
"kind": "input",
"content_schema": {
"title": "Sleep interval",
Expand All @@ -86,10 +86,10 @@ class Config:
def from_service_io(
cls,
kind: PortKindStr,
name: str,
key: str,
io: Union[ServiceInput, ServiceOutput],
) -> "ServicePortGet":
kwargs: dict[str, Any] = {"name": name, "kind": kind}
kwargs: dict[str, Any] = {"key": key, "kind": kind}

# Convert old format into schemas
schema = io.content_schema
Expand Down
4 changes: 2 additions & 2 deletions services/catalog/tests/unit/test_models_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_service_port_with_file():
)

assert port == {
"name": "input_1",
"key": "input_1",
"kind": "input",
"content_media_type": "text/plain", # <-- deduced from extension
"content_schema": {
Expand Down Expand Up @@ -78,7 +78,7 @@ def test_service_port_with_boolean():
)

assert port == {
"name": "input_1",
"key": "input_1",
"kind": "input",
# "content_media_type": None, # <-- no content media
"content_schema": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,16 @@ async def test_list_service_ports(
expected_inputs = service_metadata["inputs"]
expected_outputs = service_metadata["outputs"]

assert [p["name"] for p in ports if p["kind"] == "input"] == list(
assert [p["key"] for p in ports if p["kind"] == "input"] == list(
expected_inputs.keys()
)
assert [p["name"] for p in ports if p["kind"] == "output"] == list(
assert [p["key"] for p in ports if p["kind"] == "output"] == list(
expected_outputs.keys()
)

assert ports == [
{
"name": "input_1",
"key": "input_1",
"kind": "input",
"content_media_type": "text/plain",
"content_schema": {
Expand All @@ -136,7 +136,7 @@ async def test_list_service_ports(
},
},
{
"name": "input_2",
"key": "input_2",
"kind": "input",
"content_schema": {
"title": "Sleep interval",
Expand All @@ -147,7 +147,7 @@ async def test_list_service_ports(
},
},
{
"name": "input_3",
"key": "input_3",
"kind": "input",
"content_schema": {
"title": "Fail after sleep",
Expand All @@ -157,7 +157,7 @@ async def test_list_service_ports(
},
},
{
"name": "input_4",
"key": "input_4",
"kind": "input",
"content_schema": {
"title": "Distance to bed",
Expand All @@ -166,7 +166,7 @@ async def test_list_service_ports(
},
},
{
"name": "output_1",
"key": "output_1",
"kind": "output",
"content_media_type": "text/plain",
"content_schema": {
Expand All @@ -176,7 +176,7 @@ async def test_list_service_ports(
},
},
{
"name": "output_2",
"key": "output_2",
"kind": "output",
"content_schema": {
"title": "Random sleep interval",
Expand Down

0 comments on commit 21677ff

Please sign in to comment.