def test_select_room_fail(service: UpdateRoomClose, context: Context, house):
    service._rooms_repo = Mock(get=Mock(return_value=Nothing))
    context.house = house

    result = service.select_room(context)
    assert not is_successful(result)
    assert result.failure().failure == ReservationErrors.missed_room
def test_missed_room(service: UpdateRoomClose, context: Context, house):
    context.house = house
    context.room_id = None

    result = service.select_room(context)
    assert not is_successful(result)
    assert result.failure().failure == ReservationErrors.missed_room
def test_select_room_ok(service: UpdateRoomClose, context: Context, house,
                        room):
    service._rooms_repo = Mock(get=Mock(return_value=Some(room)))
    context.house = house

    result = service.select_room(context)
    assert is_successful(result)
    assert result.unwrap().room == room
def test_select_room_error(service: UpdateRoomClose, context: Context, house):
    service._rooms_repo = Mock(get=Mock(side_effect=RuntimeError("ERR")))
    context.house = house

    result = service.select_room(context)
    assert not is_successful(result)
    assert result.failure().failure == ReservationErrors.error
    assert str(result.failure().exc) == "ERR"