Skip to content

Commit d2acf20

Browse files
committed
test: ValidationError handling
1 parent 92862b8 commit d2acf20

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tuttle_tests/test_model.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,19 @@ def test_valid_instantiation(self):
122122
)
123123
assert store_and_retrieve(client)
124124

125+
def test_missing_name(self):
126+
"""Test that a ValidationError is raised when the name is missing."""
127+
with pytest.raises(ValidationError):
128+
Client.validate(dict())
129+
130+
try:
131+
client = Client.validate(dict())
132+
except ValidationError as ve:
133+
for error in ve.errors():
134+
field_name = error.get("loc")[0]
135+
error_message = error.get("msg")
136+
assert field_name == "name"
137+
125138
def test_missing_fields_instantiation(self):
126139
with pytest.raises(ValidationError):
127140
Client.validate(dict())

0 commit comments

Comments
 (0)