def test_select_room_type_ok(service: CalculateNewReservation, context: Context, house, room_type): service._roomtypes_repo = Mock(get=Mock(return_value=Some(room_type))) context.house = house result = service.select_room_type(context) assert is_successful(result), result.failure() assert result.unwrap().room_type == room_type
def test_select_room_type_fail(service: CalculateNewReservation, context: Context, house): service._roomtypes_repo = Mock(get=Mock(return_value=Nothing)) context.house = house result = service.select_room_type(context) assert not is_successful(result) assert result.failure().failure == ReservationErrors.missed_roomtype
def test_missed_roomtype_id(service: CalculateNewReservation, context: Context, house): context.house = house context.roomtype_id = None result = service.select_room_type(context) assert not is_successful(result) assert result.failure().failure == ReservationErrors.missed_roomtype
def test_select_room_type_error(service: CalculateNewReservation, context: Context, house): service._roomtypes_repo = Mock(get=Mock(side_effect=RuntimeError("ERR"))) context.house = house result = service.select_room_type(context) assert not is_successful(result) assert result.failure().failure == ReservationErrors.error assert str(result.failure().exc) == "ERR"