Skip to content

Commit

Permalink
fixup some server tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sfoster1 committed Sep 9, 2024
1 parent 9159f4a commit 666b3ff
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
24 changes: 17 additions & 7 deletions robot-server/tests/service/json_api/test_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,23 @@ def test_attributes_as_item_model_empty_dict():
{
"loc": ("data", "name"),
"msg": "Field required",
"type": "value_error.missing",
"type": "missing",
"input": {},
"url": "https://errors.pydantic.dev/2.9/v/missing",
},
{
"loc": ("data", "quantity"),
"msg": "Field required",
"type": "value_error.missing",
"type": "missing",
"input": {},
"url": "https://errors.pydantic.dev/2.9/v/missing",
},
{
"loc": ("data", "price"),
"msg": "Field required",
"type": "value_error.missing",
"type": "missing",
"input": {},
"url": "https://errors.pydantic.dev/2.9/v/missing",
},
]

Expand All @@ -54,8 +60,10 @@ def test_attributes_required():
assert e.value.errors() == [
{
"loc": ("data",),
"msg": "none is not an allowed value",
"type": "type_error.none.not_allowed",
"msg": "Input should be a valid dictionary",
"input": None,
"url": "https://errors.pydantic.dev/2.9/v/dict_type",
"type": "dict_type",
},
]

Expand All @@ -69,8 +77,10 @@ def test_data_required():
assert e.value.errors() == [
{
"loc": ("data",),
"msg": "none is not an allowed value",
"type": "type_error.none.not_allowed",
"msg": "Input should be a valid dictionary",
"input": None,
"url": "https://errors.pydantic.dev/2.9/v/dict_type",
"type": "dict_type",
},
]

Expand Down
8 changes: 7 additions & 1 deletion robot-server/tests/service/json_api/test_resource_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,11 @@ def test_must_be_self_key_with_string_value():
with raises(ValidationError) as e:
ThingWithLink.model_validate(invalid_structure_to_validate)
assert e.value.errors() == [
{"loc": ("links",), "msg": "Field required", "type": "value_error.missing"}
{
"loc": ("links",),
"msg": "Field required",
"type": "missing",
"input": {"invalid": {"key": "value"}},
"url": "https://errors.pydantic.dev/2.9/v/missing",
}
]
4 changes: 2 additions & 2 deletions robot-server/tests/service/legacy/models/test_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ def test_robot_home_target():


def test_robot_move_target_points_too_few():
with pytest.raises(ValueError, match="ensure this value has at least 3 items"):
with pytest.raises(ValueError, match="List should have at least 3 items"):
control.RobotMoveTarget(target=control.MotionTarget.pipette, point=[1, 2])


def test_robot_move_target_points_too_many():
with pytest.raises(ValueError, match="ensure this value has at most 3 items"):
with pytest.raises(ValueError, match="List should have at most 3 items"):
control.RobotMoveTarget(target=control.MotionTarget.pipette, point=[1, 2, 3, 4])


Expand Down
2 changes: 1 addition & 1 deletion robot-server/tests/service/legacy/routers/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ def test_reset_invalid_option(
assert resp.status_code == 422
body = resp.json()
assert "message" in body
assert "not a valid enumeration member" in body["message"]
assert "Input should be" in body["message"]


@pytest.fixture()
Expand Down

0 comments on commit 666b3ff

Please sign in to comment.