Skip to content

Commit

Permalink
Fix malformed f-String
Browse files Browse the repository at this point in the history
  • Loading branch information
dexter2206 committed Sep 30, 2024
1 parent 3c351cb commit 877c80c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/qref/schema_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def _validate_connections(self) -> Self:
if missed_ports:
raise ValueError(
"The following ports appear in a connection but are not "
"among routine's port or their children's ports: {missed_ports}."
f"among routine's port or their children's ports: {missed_ports}."
)
return self

Expand Down
18 changes: 18 additions & 0 deletions tests/qref/test_schema_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,21 @@ def test_invalid_program_fails_to_validate_with_pydantic_model_v1(input):

def test_valid_program_succesfully_validate_with_pydantic_model_v1(valid_program):
SchemaV1.model_validate(valid_program)


def test_validation_error_includes_name_of_the_missed_port():
input = {
"version": "v1",
"program": {
"name": "root",
"ports": [{"name": "in_0", "direction": "input", "size": 1}],
"connections": ["in_0 -> out_0"],
},
}

pattern = (
"The following ports appear in a connection but are not among routine's port "
r"or their children's ports: \['out_0'\]." # <- out_0 is the important bit here
)
with pytest.raises(pydantic.ValidationError, match=pattern):
SchemaV1.model_validate(input)

0 comments on commit 877c80c

Please sign in to comment.