Beispiel #1
0
class PercentageDiscountOfferTest(unittest.TestCase):
    def setUp(self):
        self.offer = DiscountOffer(discount_type=PERCENTAGE_DISCOUNT,
                                   discount_value=D('25.00'))

    def test_simple_discounted_price(self):
        product = create_product(D('100.00'))
        self.assertEquals(D('75.00'), self.offer._get_discount_price(product))

    def test_rounded_discounted_price(self):
        product = create_product(D('99.99'))
        self.assertEquals(D('74.99'), self.offer._get_discount_price(product))
Beispiel #2
0
class FixedPriceDiscountOfferTest(unittest.TestCase):
    def setUp(self):
        self.offer = DiscountOffer(discount_type=FINAL_PRICE,
                                   discount_value=D('25.00'))

    def test_simple_discounted_price(self):
        product = create_product(D('100.00'))
        self.assertEquals(D('25.00'), self.offer._get_discount_price(product))

    def test_discounted_price_when_original_is_cheaper(self):
        product = create_product(D('20.00'))
        self.assertEquals(D('25.00'), self.offer._get_discount_price(product))
Beispiel #3
0
class AbsoluteDiscountOfferTest(unittest.TestCase):
    def setUp(self):
        self.offer = DiscountOffer(discount_type=ABSOLUTE_DISCOUNT,
                                   discount_value=D('25.00'))

    def test_simple_discounted_price(self):
        product = create_product(D('100.00'))
        self.assertEquals(D('75.00'), self.offer._get_discount_price(product))

    def test_discount_larger_than_price_sets_price_to_zero(self):
        product = create_product(D('20.00'))
        self.assertEquals(D('0.00'), self.offer._get_discount_price(product))
Beispiel #4
0
class PercentageDiscountOfferTest(unittest.TestCase):
    
    def setUp(self):
        self.offer = DiscountOffer(discount_type=PERCENTAGE_DISCOUNT,
                                   discount_value=D('25.00'))
    
    def test_simple_discounted_price(self):
        product = create_product(D('100.00'))
        self.assertEquals(D('75.00'), self.offer._get_discount_price(product))
        
    def test_rounded_discounted_price(self):
        product = create_product(D('99.99'))
        self.assertEquals(D('74.99'), self.offer._get_discount_price(product))
Beispiel #5
0
class FixedPriceDiscountOfferTest(unittest.TestCase):
    
    def setUp(self):
        self.offer = DiscountOffer(discount_type=FINAL_PRICE,
                                   discount_value=D('25.00'))
    
    def test_simple_discounted_price(self):
        product = create_product(D('100.00'))
        self.assertEquals(D('25.00'), self.offer._get_discount_price(product))
        
    def test_discounted_price_when_original_is_cheaper(self):
        product = create_product(D('20.00'))
        self.assertEquals(D('25.00'), self.offer._get_discount_price(product))    
Beispiel #6
0
class AbsoluteDiscountOfferTest(unittest.TestCase):
    
    def setUp(self):
        self.offer = DiscountOffer(discount_type=ABSOLUTE_DISCOUNT,
                                   discount_value=D('25.00'))
    
    def test_simple_discounted_price(self):
        product = create_product(D('100.00'))
        self.assertEquals(D('75.00'), self.offer._get_discount_price(product))
        
    def test_discount_larger_than_price_sets_price_to_zero(self):
        product = create_product(D('20.00'))
        self.assertEquals(D('0.00'), self.offer._get_discount_price(product))