def test_select_daily_prices_with_no_rate(service: CalculateNewReservation, context: Context): context.rate = None result = service.select_daily_prices(context) assert is_successful(result) assert result.unwrap().prices == { datetime.date.today(): None, datetime.date.today() + datetime.timedelta(days=1): None, }
def test_select_daily_prices_error(service: CalculateNewReservation, context: Context, house, room_type, rate): service._prices_repo = Mock(select_prices=Mock( side_effect=RuntimeError("ERR"))) context.house = house context.room_type = room_type context.rate = rate result = service.select_daily_prices(context) assert not is_successful(result) assert result.failure().failure == ReservationErrors.error assert str(result.failure().exc) == "ERR"
def test_select_daily_prices_fail(service: CalculateNewReservation, context: Context, house, room_type, rate): service._prices_repo = Mock(select_prices=Mock(return_value={})) context.house = house context.room_type = room_type context.rate = rate result = service.select_daily_prices(context) assert is_successful(result) assert result.unwrap().prices == { datetime.date.today(): None, datetime.date.today() + datetime.timedelta(days=1): None, }
def test_select_daily_prices_ok(service: CalculateNewReservation, context: Context, house, room_type, rate): prices = { context.start_date: Decimal(100), context.start_date + datetime.timedelta(days=1): Decimal(110) } service._prices_repo = Mock(select_prices=Mock(return_value=prices)) context.house = house context.room_type = room_type context.rate = rate result = service.select_daily_prices(context) assert is_successful(result) assert result.unwrap().prices == prices