def test_discount_for_multi_group_using_customer(rf, admin_user, price, discount, anonymous_discount): customer = create_customer() anonymous = AnonymousContact() request, shop, _ = initialize_test(rf, True, customer) product = create_product("product", shop=shop, default_price=price) CgpDiscount.objects.create(product=product, group=customer.groups.first(), shop=shop, discount_amount_value=discount) CgpDiscount.objects.create(product=product, group=anonymous.get_default_group(), shop=shop, discount_amount_value=anonymous_discount) # discount for customer request, shop, _ = initialize_test(rf, True, customer) price_info = product.get_price_info(request) assert price_info.price == shop.create_price(max(price - discount, 0)) # discount for anonymous request, shop, _ = initialize_test(rf, True, anonymous) price_info = product.get_price_info(request) assert price_info.price == shop.create_price( max(price - anonymous_discount, 0))
def test_default_anonymous_contact_group_repr_and_str(): adg = AnonymousContact.get_default_group() assert repr(adg) == '<ContactGroup:%d-default_anonymous_group>' % adg.pk assert str(adg) == 'Anonymous Contacts'