def test_select_rates_ok(service: CalculateNewReservation, context: Context, house, room_type, rate_plan, rate): service._prices_repo = Mock(select_rates=Mock(return_value=[rate])) context.house = house context.room_type = room_type context.rate_plan = rate_plan result = service.select_rates(context) assert is_successful(result) assert result.unwrap().rates == [rate]
def test_select_rates_error(service: CalculateNewReservation, context: Context, house, room_type, rate_plan): service._prices_repo = Mock(select_rates=Mock( side_effect=RuntimeError("ERR"))) context.house = house context.room_type = room_type context.rate_plan = rate_plan result = service.select_rates(context) assert not is_successful(result) assert result.failure().failure == ReservationErrors.error assert str(result.failure().exc) == "ERR"