Error Management in a Use Case
Let’s learn about error management in use cases and internal systems.
We'll cover the following...
Now that our implementation of requests and responses is complete, we can implement the final version of our use case. In our program, a proper validation of the incoming request for the room_list_use_case
function is still missing. So, it doesn’t yet return a suitable response when something goes wrong.
Update test case
The test_room_list_without_parameters
test must match the new API, so we add filters=None
to assert_called_with
in the code below:
Press + to interact
def test_room_list_without_parameters(domain_rooms):repo = mock.Mock()repo.list.return_value = domain_roomsrequest = build_room_list_request()response = room_list_use_case(repo, request)assert bool(response) is Truerepo.list.assert_called_with(filters=None)assert response.value == domain_rooms
There are three new tests that we can add to check the behavior of the use case when filters
are not None
. The first test checks if the ...