コード例 #1
0
 def test_must_have_a_text_name(self):
     try:
         custom.create_range(CustomRangeLazy)
     except Exception:
         pass
     else:
         self.fail("Range can't have ugettext titles")
コード例 #2
0
 def test_must_have_a_text_name(self):
     try:
         custom.create_range(CustomRangeLazy)
     except ValidationError:
         pass
     else:
         self.fail("Range can't have gettext titles")
コード例 #3
0
 def test_creating_unique_custom_range(self):
     custom.create_range(CustomRange)
     try:
         custom.create_range(CustomRange)
     except IntegrityError:
         self.fail(
             'IntegrityError when added the same CustomRange as existing')
コード例 #4
0
 def test_creating_unique_custom_range(self):
     custom.create_range(CustomRange)
     try:
         custom.create_range(CustomRange)
     except IntegrityError:
         self.fail(
             'IntegrityError when added the same CustomRange as existing')
コード例 #5
0
def create_twin_product_offer():
    
    try:
        o1 = ConditionalOffer.objects.get(slug='remove-twin-products')
    except:
        print('Modelli offer non presenti, li creo')
        # creare range
        r = create_range(AllProductsRange)

        c1_new = True
        try:
            c1 = create_condition(CheckTwinDigitalProducts, range=r, value=1, type=CoverageCondition.COVERAGE)
        except:
            c1_new = False
            c1 = CheckTwinDigitalProducts.objects.get(range=r, value=1, type=CoverageCondition.COVERAGE)
        print('Check Preso?', c1, 'Nuovo?', c1_new)
        
        
        b1 = create_benefit(FreeTwinDigitalProducts, range=r, value=100, type=PercentageDiscountBenefit.PERCENTAGE)
        print('Benefit Preso?', b1)
        
        
        o1, o1_new= ConditionalOffer.objects.get_or_create(name='Remove twin products', condition=c1, benefit=b1, offer_type=ConditionalOffer.SESSION)
        print('Offer Preso?', o1, 'Nuova?', o1_new)
    
    return o1
コード例 #6
0
def create_twin_product_offer():

    try:
        o1 = ConditionalOffer.objects.get(slug='remove-twin-products')
    except:
        print('Modelli offer non presenti, li creo')
        # creare range
        r = create_range(AllProductsRange)

        c1_new = True
        try:
            c1 = create_condition(CheckTwinDigitalProducts,
                                  range=r,
                                  value=1,
                                  type=CoverageCondition.COVERAGE)
        except:
            c1_new = False
            c1 = CheckTwinDigitalProducts.objects.get(
                range=r, value=1, type=CoverageCondition.COVERAGE)
        print('Check Preso?', c1, 'Nuovo?', c1_new)

        b1 = create_benefit(FreeTwinDigitalProducts,
                            range=r,
                            value=100,
                            type=PercentageDiscountBenefit.PERCENTAGE)
        print('Benefit Preso?', b1)

        o1, o1_new = ConditionalOffer.objects.get_or_create(
            name='Remove twin products',
            condition=c1,
            benefit=b1,
            offer_type=ConditionalOffer.SESSION)
        print('Offer Preso?', o1, 'Nuova?', o1_new)

    return o1
コード例 #7
0
 def test_correctly_excludes_nonmatch(self):
     rng = custom.create_range(CustomRange)
     test_product = create_product(title=u"B tale")
     self.assertFalse(rng.contains_product(test_product))
コード例 #8
0
 def test_correctly_includes_match(self):
     rng = custom.create_range(CustomRange)
     test_product = create_product(title=u"A tale")
     self.assertTrue(rng.contains_product(test_product))
コード例 #9
0
 def setUp(self):
     self.rng = custom.create_range(CustomRange)
コード例 #10
0
 def test_creating_duplicate_range_fails(self):
     custom.create_range(CustomRange)
     self.assertRaises(ValueError, custom.create_range, CustomRange)
コード例 #11
0
 def test_correctly_excludes_nonmatch(self):
     rng = custom.create_range(CustomRange)
     test_product = create_product(title="B tale")
     self.assertFalse(rng.contains_product(test_product))
コード例 #12
0
 def test_correctly_includes_match(self):
     rng = custom.create_range(CustomRange)
     test_product = create_product(title="A tale")
     self.assertTrue(rng.contains_product(test_product))
コード例 #13
0
 def test_creating_duplicate_range_fails(self):
     custom.create_range(CustomRange)
     self.assertRaises(ValueError, custom.create_range, CustomRange)
コード例 #14
0
 def setUp(self):
     self.rng = custom.create_range(CustomRange)