Skip to content

Commit dd856b6

Browse files
Add test
1 parent bfa0cb3 commit dd856b6

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/unit/models/test_cell_morphology_protocol.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from pathlib import Path
33

44
import pytest
5+
from pydantic import ValidationError
56

67
from entitysdk.models.cell_morphology_protocol import (
78
CellMorphologyProtocol,
@@ -112,6 +113,32 @@ def test_register(request, client, httpx_mock, auth_token, json_data_fixture, mo
112113
assert registered.model_dump(mode="json", exclude_unset=True) == expected_json
113114

114115

116+
@pytest.mark.parametrize(
117+
("json_data_fixture", "model_fixture"),
118+
[
119+
("json_digital_reconstruction", "model_digital_reconstruction"),
120+
("json_modified_reconstruction", "model_modified_reconstruction"),
121+
("json_computationally_synthesized", "model_computationally_synthesized"),
122+
("json_placeholder", "model_placeholder"),
123+
],
124+
)
125+
def test_adapter(request, json_data_fixture, model_fixture):
126+
json_data = request.getfixturevalue(json_data_fixture)
127+
model = request.getfixturevalue(model_fixture)
128+
129+
new_model = Model(**json_data)
130+
assert new_model == model
131+
132+
new_model = Model.model_validate(json_data)
133+
assert new_model == model
134+
135+
with pytest.raises(TypeError, match="Positional args not supported"):
136+
new_model = Model("name")
137+
138+
with pytest.raises(ValidationError, match="Extra inputs are not permitted"):
139+
Model(generation_type=json_data["generation_type"], invalid_input="invalid")
140+
141+
115142
@pytest.mark.parametrize(
116143
("json_data_fixture", "model_fixture"),
117144
[

0 commit comments

Comments
 (0)