diff --git a/darwin/future/tests/core/items/test_move_items_to_folder.py b/darwin/future/tests/core/items/test_move_items_to_folder.py index 06c702281..66a11e728 100644 --- a/darwin/future/tests/core/items/test_move_items_to_folder.py +++ b/darwin/future/tests/core/items/test_move_items_to_folder.py @@ -1,12 +1,11 @@ -from unittest.mock import Mock from uuid import UUID -import pytest import responses +from pytest import raises -from darwin.exceptions import DarwinException from darwin.future.core.client import ClientCore from darwin.future.core.items.move_items_to_folder import move_list_of_items_to_folder +from darwin.future.exceptions import BadRequest from darwin.future.tests.core.fixtures import * @@ -41,18 +40,24 @@ def test_move_list_of_items_to_folder_including_filters( assert response == {"affected_item_count": 2} -def test_move_list_of_items_to_folder_with_error_response() -> None: - api_client = Mock(spec=ClientCore) - api_client.post.side_effect = DarwinException("Something went wrong") - - with pytest.raises(DarwinException): - move_list_of_items_to_folder( - api_client=api_client, - team_slug="test-team", - dataset_id=000000, - item_ids=[ - UUID("00000000-0000-0000-0000-000000000000"), - UUID("00000000-0000-0000-0000-000000000000"), - ], - path="/test/path", - ) +def test_move_list_of_items_to_folder_with_error_response( + base_client: ClientCore, +) -> None: + with raises(BadRequest): + with responses.RequestsMock() as rsps: + rsps.add( + responses.POST, + base_client.config.api_endpoint + "v2/teams/test-team/items/path", + status=400, + ) + + move_list_of_items_to_folder( + api_client=base_client, + team_slug="test-team", + dataset_id=000000, + item_ids=[ + UUID("00000000-0000-0000-0000-000000000000"), + UUID("00000000-0000-0000-0000-000000000000"), + ], + path="/test/path", + )