def test_select_rooms_ok(service: ShowPricesForm, context: Context, house, room): service._rooms_repo = Mock(select=Mock(return_value=[room])) context.house = house result = service.select_rooms(context) assert is_successful(result) assert result.unwrap().rooms == [room]
def test_select_rooms_error(service: ShowPricesForm, context: Context, house): service._rooms_repo = Mock(select=Mock(side_effect=RuntimeError('ERR'))) context.house = house result = service.select_rooms(context) assert not is_successful(result) assert result.failure().failure == ReservationErrors.error assert str(result.failure().exc) == 'ERR'