Skip to content

Commit e46c054

Browse files
fix tests
1 parent 0baf9ab commit e46c054

File tree

6 files changed

+14
-12
lines changed

6 files changed

+14
-12
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ class LongTruncatedStr(ConstrainedStr):
130130
IdInt: TypeAlias = PositiveInt
131131
PrimaryKeyInt: TypeAlias = PositiveInt
132132

133+
AnyUrl = Annotated[str, pydantic.AnyUrl]
133134

134135
AnyHttpUrl = Annotated[str, pydantic.AnyHttpUrl]
135136

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
from typing import Annotated, TypeAlias
1212
from uuid import UUID
1313

14-
from models_library.basic_types import ConstrainedStr, KeyIDStr
14+
from models_library.basic_types import AnyUrl, ConstrainedStr, KeyIDStr
1515
from pydantic import (
16-
AnyUrl,
1716
BaseModel,
1817
ConfigDict,
1918
Field,

packages/models-library/src/models_library/utils/specs_substitution.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import Any, NamedTuple, TypeAlias, cast
22

3+
from models_library.errors_classes import OsparcErrorMixin
34
from pydantic import StrictBool, StrictFloat, StrictInt
4-
from pydantic.errors import PydanticErrorMixin
55

66
from .json_serialization import json_dumps, json_loads
77
from .string_substitution import (
@@ -15,7 +15,7 @@
1515
SubstitutionValue: TypeAlias = StrictBool | StrictInt | StrictFloat | str
1616

1717

18-
class IdentifierSubstitutionError(PydanticErrorMixin, KeyError):
18+
class IdentifierSubstitutionError(OsparcErrorMixin, KeyError):
1919
msg_template: str = (
2020
"Was not able to substitute identifier "
2121
"'{name}'. It was not found in: {substitutions}"

packages/models-library/tests/test_utils_nodes.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
SimcoreS3FileID,
1515
)
1616
from models_library.utils.nodes import compute_node_hash
17-
from pydantic import AnyUrl, parse_obj_as
1817

1918

2019
@pytest.fixture()
@@ -45,9 +44,7 @@ def node_id() -> NodeID:
4544
"input_bool": True,
4645
"input_string": "string",
4746
"input_downloadlink": DownloadLink(
48-
downloadLink=parse_obj_as(
49-
AnyUrl, "http://httpbin.org/image/jpeg"
50-
)
47+
downloadLink="http://httpbin.org/image/jpeg"
5148
),
5249
"input_simcorelink": SimCoreFileLink(
5350
store=0,

packages/models-library/tests/test_utils_pydantic_tools_extension.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,20 @@ class MyModel(BaseModel):
1414

1515

1616
def test_schema():
17-
assert MyModel.schema() == {
17+
assert MyModel.model_json_schema() == {
1818
"title": "MyModel",
1919
"type": "object",
2020
"properties": {
2121
"a": {"title": "A", "type": "integer"},
22-
"b": {"title": "B", "type": "integer"},
22+
"b": {"anyOf": [{"type": "integer"}, {"type": "null"}], "title": "B"},
2323
"c": {"title": "C", "default": 42, "type": "integer"},
24-
"d": {"title": "D", "type": "integer"},
24+
"d": {
25+
"anyOf": [{"type": "integer"}, {"type": "null"}],
26+
"default": None,
27+
"title": "D",
28+
},
2529
"e": {
30+
"default": None,
2631
"title": "E",
2732
"type": "integer",
2833
"description": "optional non-nullable",

packages/models-library/tests/test_utils_service_io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def service_port(request: pytest.FixtureRequest) -> ServiceInput | ServiceOutput
4040

4141

4242
def test_get_schema_from_port(service_port: ServiceInput | ServiceOutput):
43-
print(service_port.json(indent=2))
43+
print(service_port.model_dump_json(indent=2))
4444

4545
# get
4646
schema = get_service_io_json_schema(service_port)

0 commit comments

Comments
 (0)