def test_check_los_discounts(service: CalculateNewReservation, context: Context, house, room_type, rate, los_discount): period = [ context.start_date, context.start_date + datetime.timedelta(days=1), context.start_date + datetime.timedelta(days=2), context.start_date + datetime.timedelta(days=3), ] context.end_date = context.start_date + datetime.timedelta(days=4) context.house = house context.room_type = room_type context.rate = rate context.prices = { period[0]: Decimal(100), period[1]: Decimal(100), period[2]: Decimal(100), period[3]: Decimal(100), } context.discounts = {DiscountTypes.LOS: [los_discount]} result = service.check_los_discounts(context) assert is_successful(result) assert result.unwrap().prices == { period[0]: Decimal(85), period[1]: Decimal(85), period[2]: Decimal(85), period[3]: Decimal(85), }
def test_check_los_discounts_empty(service: CalculateNewReservation, context: Context, house, room_type, rate): period = [ context.start_date, context.start_date + datetime.timedelta(days=1) ] context.house = house context.room_type = room_type context.rate = rate context.prices = {period[0]: Decimal(100), period[1]: Decimal(110)} context.discounts = {DiscountTypes.LOS: []} result = service.check_los_discounts(context) assert is_successful(result) assert result.unwrap().prices == context.prices