From 666b3ff732bf0a9acdd4b87e1712e790b4e5e62e Mon Sep 17 00:00:00 2001 From: Seth Foster Date: Mon, 9 Sep 2024 16:39:05 -0400 Subject: [PATCH] fixup some server tests --- .../tests/service/json_api/test_request.py | 24 +++++++++++++------ .../service/json_api/test_resource_links.py | 8 ++++++- .../service/legacy/models/test_control.py | 4 ++-- .../service/legacy/routers/test_settings.py | 2 +- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/robot-server/tests/service/json_api/test_request.py b/robot-server/tests/service/json_api/test_request.py index 3cd621a5e8d..de93182dc7d 100644 --- a/robot-server/tests/service/json_api/test_request.py +++ b/robot-server/tests/service/json_api/test_request.py @@ -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", }, ] @@ -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", }, ] @@ -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", }, ] diff --git a/robot-server/tests/service/json_api/test_resource_links.py b/robot-server/tests/service/json_api/test_resource_links.py index 2238ca8b188..a0bf07d290e 100644 --- a/robot-server/tests/service/json_api/test_resource_links.py +++ b/robot-server/tests/service/json_api/test_resource_links.py @@ -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", + } ] diff --git a/robot-server/tests/service/legacy/models/test_control.py b/robot-server/tests/service/legacy/models/test_control.py index 058ae5c80e4..931d7c0811a 100644 --- a/robot-server/tests/service/legacy/models/test_control.py +++ b/robot-server/tests/service/legacy/models/test_control.py @@ -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]) diff --git a/robot-server/tests/service/legacy/routers/test_settings.py b/robot-server/tests/service/legacy/routers/test_settings.py index 6c9ae8adb56..9c52256b82d 100644 --- a/robot-server/tests/service/legacy/routers/test_settings.py +++ b/robot-server/tests/service/legacy/routers/test_settings.py @@ -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()