def test_code_whitespace_removal(self, code, expected): promo_code = PromoCode(code=code) promo_code._attribute_adjustments() assert expected == promo_code.code
def test_empty_code_auto_generated(self, code, monkeypatch): monkeypatch.setattr(PromoCode, 'generate_random_code', Mock()) promo_code = PromoCode(code=code) promo_code._attribute_adjustments() assert PromoCode.generate_random_code.called
def test_badge_price_fixed_discount_is_free(self, discount): promo_code = PromoCode(discount=discount, discount_type=PromoCode._FIXED_DISCOUNT) promo_code._attribute_adjustments() assert promo_code.is_free
def test_100_percent_discount_is_free(self, discount): promo_code = PromoCode(discount=discount, discount_type=PromoCode._PERCENT_DISCOUNT) promo_code._attribute_adjustments() assert promo_code.is_free
def test_empty_discount_set_to_none(self, discount, discount_type): promo_code = PromoCode(discount=discount, discount_type=discount_type) promo_code._attribute_adjustments() assert promo_code.discount is None assert promo_code.is_free
def test_empty_uses_set_to_none(self, uses_allowed): promo_code = PromoCode(uses_allowed=uses_allowed) promo_code._attribute_adjustments() assert promo_code.uses_allowed is None assert promo_code.is_unlimited