def test_valid_conditions_returns_false_if_conditions_not_met(self): rentalsx2 = (WeeklyRental(5), WeeklyRental(1)) rentalsx6 = (DailyRental(5), WeeklyRental(1), DailyRental(2), WeeklyRental(1), DailyRental(2), WeeklyRental(1)) self.assertFalse(self.promotion.valid_conditions(rentalsx2)) self.assertFalse(self.promotion.valid_conditions(rentalsx6))
def test_valid_conditions_returns_true_if_conditions_met(self): rentalsx4 = (WeeklyRental(5), WeeklyRental(1), WeeklyRental(2), WeeklyRental(1)) rentalsx5 = (DailyRental(5), WeeklyRental(1), DailyRental(2), WeeklyRental(1), WeeklyRental(1)) self.assertTrue(self.promotion.valid_conditions(self.rentals)) self.assertTrue(self.promotion.valid_conditions(rentalsx4)) self.assertTrue(self.promotion.valid_conditions(rentalsx5))
def setUp(self): self.store = BikeRentalStore(FamilyRental()) self.client = BikeRentalClient(self.store) self.rentals = (WeeklyRental(1), WeeklyRental(1))
def test_order_returns_total_price(self): self.assertEqual(self.store.handle_request(self.client, self.rentals), WeeklyRental.unit_price() * 2)
def test_request_increments_balance(self): self.client.request(self.rentals) self.assertEqual(self.client.balance, WeeklyRental.unit_price() * 4)
def setUp(self): self.hourly_rental = HourlyRental(5) self.daily_rental = DailyRental(4) self.weekly_rental = WeeklyRental(3)
def test_correct_unit_prices(self): self.assertEqual(HourlyRental.unit_price(), 5) self.assertEqual(DailyRental.unit_price(), 20) self.assertEqual(WeeklyRental.unit_price(), 60)
def setUp(self): self.promotion = FamilyRental() self.rentals = (WeeklyRental(5), WeeklyRental(1), WeeklyRental(2))
def test_discount_not_applied_if_conditions_not_met(self): rentalsx2 = (WeeklyRental(5), WeeklyRental(1)) self.assertNotEqual(self.promotion.apply_discount(rentalsx2), WeeklyRental.unit_price() * 6 * 0.7) self.assertEqual(self.promotion.apply_discount(rentalsx2), WeeklyRental.unit_price() * 6)
def test_discount_applied_if_conditions_met(self): self.assertEqual(self.promotion.apply_discount(self.rentals), WeeklyRental.unit_price() * 8 * 0.7)