def test_is_red_pencil__stable_price_4_discount_returns_false(self): prices = [100] * 30 red_pencils = [False] * len(prices) prices.append(96) red_pencils.append(False) self.assertEqual(is_red_pencil(prices), red_pencils, "Stable prices followed by 4% drop should be false.")
def test_is_red_pencil__stable_price_5_discount_returns_true(self): prices = [100] * 30 red_pencils = [False] * len(prices) prices.append(95) red_pencils.append(True) self.assertEqual(is_red_pencil(prices), red_pencils, "Stable prices followed by 5% drop should be true.")
def test_is_red_pencil__red_pencil_discount_stops_on_price_increase(self): prices = [100] * 30 red_pencils = [False] * len(prices) prices.extend([75, 75, 75, 80]) red_pencils.extend([True, True, True, False]) self.assertEqual( is_red_pencil(prices), red_pencils, "Red pencil discount should stop when the price goes up.")
def test_is_red_pencil__stable_price_25_discount_returns_true_repeatedly_if_sale_continues( self): prices = [100] * 30 red_pencils = [False] * len(prices) prices.extend([75] * 5) red_pencils.extend([True] * 5) self.assertEqual(is_red_pencil(prices), red_pencils, "Stable prices followed by 25% drop should be true.")
def test_is_red_pencil__price_not_stable_returns_false(self): prices = [100, 100, 100, 85] red_pencils = [False] * len(prices) self.assertEqual(is_red_pencil(prices), red_pencils, "Only four days of prices should always be false.")
def test_is_red_pencil__red_pencil_discount_stops_on_price_increase(self): prices = [100] * 30 red_pencils = [False] * len(prices) prices.extend([75, 75, 75, 80]) red_pencils.extend([True, True, True, False]) self.assertEqual(is_red_pencil(prices), red_pencils, "Red pencil discount should stop when the price goes up.")
def test_is_red_pencil__stable_price_25_discount_returns_true_repeatedly_if_sale_continues(self): prices = [100] * 30 red_pencils = [False] * len(prices) prices.extend([75] * 5) red_pencils.extend([True] * 5) self.assertEqual(is_red_pencil(prices), red_pencils, "Stable prices followed by 25% drop should be true.")
def test_is_red_pencil__stable_price_31_discount_returns_false(self): prices = [100] * 30 red_pencils = [False] * len(prices) prices.append(69) red_pencils.append(False) self.assertEqual(is_red_pencil(prices), red_pencils, "Stable prices followed by 31% drop should be false.")
def test_when_is_red_pencil_passed_29_after_red_pencil_return_false(self): self.assertFalse( rp.is_red_pencil((dt(1, 1, 1), 1.00), (dt(1, 2, 1), .95), dt(1, 1, 3)))
def test_when_is_red_pencil_passed_29_days_after_price_change_return_false( self): self.assertFalse( rp.is_red_pencil((dt(1, 1, 1), 1.00), (dt(1, 1, 30), .95)))
def test_when_is_red_pencil_passed_5_percent_reduction_return_true(self): self.assertTrue( rp.is_red_pencil((dt(1, 1, 1), 1.00), (dt(1, 2, 1), .95)))
def test_when_is_red_pencil_passed_31_percent_reduction_return_false(self): self.assertFalse( rp.is_red_pencil((dt(1, 1, 1), 1.00), (dt(1, 2, 1), .69)))
def test_when_is_red_pencil_passed_greater_second_price_return_false(self): self.assertFalse( rp.is_red_pencil((dt(1, 1, 1), 1.00), (dt(1, 2, 1), 2.00)))
def test_when_is_red_pencil_passed_arrays_return_none(self): self.assertIsNone( rp.is_red_pencil([dt(1, 1, 1), 1.00], [dt(1, 1, 1), 1.00]))