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")
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")
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')
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
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
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))
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))
def setUp(self): self.rng = custom.create_range(CustomRange)
def test_creating_duplicate_range_fails(self): custom.create_range(CustomRange) self.assertRaises(ValueError, custom.create_range, CustomRange)
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))
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))