• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python factories.get_default_customer_group函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中shoop.testing.factories.get_default_customer_group函数的典型用法代码示例。如果您正苦于以下问题:Python get_default_customer_group函数的具体用法?Python get_default_customer_group怎么用?Python get_default_customer_group使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_default_customer_group函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_category_links_plugin_with_customer

def test_category_links_plugin_with_customer(rf, show_all_categories):
    """
    Test plugin for categories that is visible for certain group
    """
    shop = get_default_shop()
    group = get_default_customer_group()
    customer = create_random_person()
    customer.groups.add(group)
    customer.save()

    request = rf.get("/")
    request.shop = get_default_shop()
    apply_request_middleware(request)
    request.customer = customer

    category = get_default_category()
    category.status = CategoryStatus.VISIBLE
    category.visibility = CategoryVisibility.VISIBLE_TO_GROUPS
    category.visibility_groups.add(group)
    category.shops.add(shop)
    category.save()

    vars = {"request": request}
    context = get_jinja_context(**vars)
    plugin = CategoryLinksPlugin({"categories": [category.pk], "show_all_categories": show_all_categories})
    assert category.is_visible(customer)
    assert category in plugin.get_context_data(context)["categories"]

    customer_without_groups = create_random_person()
    customer_without_groups.groups.clear()

    assert not category.is_visible(customer_without_groups)
    request.customer = customer_without_groups
    context = get_jinja_context(**vars)
    assert category not in plugin.get_context_data(context)["categories"]
开发者ID:00WhengWheng,项目名称:shuup,代码行数:35,代码来源:test_plugins.py


示例2: _get_test_product

def _get_test_product():
    shop = get_default_shop()
    product = create_product("Just-A-Pricing-Product", shop, default_price=200)
    SimpleProductPrice.objects.create(
        product=product, shop=shop, group=get_default_customer_group(),
        price_value=250)
    return product
开发者ID:akx,项目名称:shoop,代码行数:7,代码来源:test_form.py


示例3: test_editing_sales_ranges_multi_shop

def test_editing_sales_ranges_multi_shop(rf, admin_user):
    get_default_shop()
    another_shop = get_shop(prices_include_tax=True)
    another_shop.status = ShopStatus.ENABLED
    another_shop.save()
    group = get_default_customer_group()
    data = {}
    for shop in Shop.objects.all():
        data.update(get_edit_view_data(shop, group, 0, 50))

    assert ContactGroupSalesRange.objects.count() == 0
    # To make this test work we need to mock members form_part since the extra
    # forms does not render correctly
    with patch.object(ContactGroupEditView, "base_form_part_classes", [ContactGroupBaseFormPart]):
        request = apply_request_middleware(rf.post("/", data=data), user=admin_user)
        view = ContactGroupEditView.as_view()
        response = view(request=request, pk=group.pk)
        if hasattr(response, "render"):
            response.render()
        assert response.status_code in [200, 302]

    assert ContactGroupSalesRange.objects.count() == 2
    for shop in Shop.objects.all():
        sales_range = ContactGroupSalesRange.objects.filter(group=group, shop=shop).first()
        assert sales_range.min_value == 0
        assert sales_range.max_value == 50
开发者ID:monokrome,项目名称:shuup,代码行数:26,代码来源:test_sales_ranges_admin.py


示例4: get_default_behavior_settings

def get_default_behavior_settings():
    return {
        FixedCostBehaviorComponent.__name__.lower(): {
            "description__en": "Fixed cost test",
            "price_value": 1,
            "id": "",
        },
        WaivingCostBehaviorComponent.__name__.lower(): {
            "description__en": "Waiving cost test",
            "price_value": 1,
            "waive_limit_value": 1,
            "id": "",
        },
        "weight_based_price_ranges": {
            "description__en": "Weight based pricing test",
            "price_value": 1,
            "min_value": 1,
            "max_value": 2,
            "id": "",
        },
        WeightLimitsBehaviorComponent.__name__.lower(): {
            "min_weight": 0,
            "max_weight": 1,
            "id": "",
        },
        GroupAvailabilityBehaviorComponent.__name__.lower(): {
            "groups": [get_default_customer_group().pk]
        },
        RoundingBehaviorComponent.__name__.lower(): {
            "mode": RoundingMode.ROUND_UP.value,
            "quant": decimal.Decimal('0.05')
        }
    }
开发者ID:monokrome,项目名称:shuup,代码行数:33,代码来源:test_service_behavior_components.py


示例5: test_basic_form_sanity

def test_basic_form_sanity():
    shop = get_default_shop()
    group = get_default_customer_group()
    product = _get_test_product()
    frm = SimplePricingForm(product=product, empty_permitted=True)
    assert len(frm.groups) == ContactGroup.objects.count()
    assert len(frm.shops) == Shop.objects.count()

    assert "s_%d_g_%d" % (shop.id, group.id) in frm.fields
开发者ID:akx,项目名称:shoop,代码行数:9,代码来源:test_form.py


示例6: test_condition_doesnt_match

def test_condition_doesnt_match(rf):
    activate("en")
    request, shop, group = initialize_test(rf, False)
    condition = ContactGroupCondition.objects.create()
    condition.contact_groups = [get_default_customer_group()]
    condition.save()

    request.customer = None

    assert not condition.matches(request)
开发者ID:00WhengWheng,项目名称:shuup,代码行数:10,代码来源:test_catalog_campaigns.py


示例7: test_form_part_for_random_group

def test_form_part_for_random_group(rf, admin_user):
    get_default_shop()
    group = get_default_customer_group()
    request = apply_request_middleware(rf.get("/"), user=admin_user)
    initialized_view = ContactGroupEditView(request=request, kwargs={"pk": group.pk})
    initialized_view.object = initialized_view.get_object() # Just for test
    form_def_values = initialized_view.get_form().form_defs.values()
    assert [form_def for form_def in form_def_values if form_def.name == "base"]
    # contact_group_sales_ranges should be in form defs
    assert [form_def for form_def in form_def_values if "contact_group_sales_ranges" in form_def.name]
开发者ID:monokrome,项目名称:shuup,代码行数:10,代码来源:test_sales_ranges_admin.py


示例8: test_customers

def test_customers(django_user_model):
    users = [django_user_model.objects.create_user('Joe-%d' % x, 'joe%[email protected]' % x, 'password') for x in range(10)]
    group = get_default_customer_group()
    assert str(group) == DEFAULT_NAME
    for user in users:
        contact = get_person_contact(user)
        group.members.add(contact)

    for user in users:
        assert PersonContact.objects.get(user=user).user_id == user.pk, "Customer profile found"
        assert tuple(user.contact.groups.values_list("identifier", flat=True)) == (DEFAULT_IDENTIFIER,), "Joe is now in the group"
开发者ID:cuberskulk,项目名称:shoop,代码行数:11,代码来源:test_customers.py


示例9: initialize_test

def initialize_test(rf, include_tax=False):
    shop = get_shop_with_tax(include_tax=include_tax)

    group = get_default_customer_group()
    customer = create_random_person()
    customer.groups.add(group)
    customer.save()

    request = rf.get("/")
    request.shop = shop
    request.customer = customer
    return request, shop, group
开发者ID:portlyjent,项目名称:shoop,代码行数:12,代码来源:test_default_pricing.py


示例10: initialize_test

def initialize_test(rf, include_tax=False):
    shop = get_shop(prices_include_tax=include_tax)

    group = get_default_customer_group()
    customer = create_random_person()
    customer.groups.add(group)
    customer.save()

    request = apply_request_middleware(rf.get("/"))
    request.shop = shop
    request.customer = customer
    return request, shop, group
开发者ID:00WhengWheng,项目名称:shuup,代码行数:12,代码来源:test_customer_group_pricing.py


示例11: test_basic_form_sanity

def test_basic_form_sanity():
    shop = get_default_shop()
    group = get_default_customer_group()
    product = _get_test_product()
    frm = SimplePricingForm(product=product, empty_permitted=True)
    assert len(frm.groups) == 1 + ContactGroup.objects.count()
    assert len(frm.shops) == 1 + Shop.objects.count()
    for shop_id in (0, shop.id):
        for group_id in (0, group.id):
            assert "s_%d_g_%d" % (shop_id, group_id) in frm.fields

    form_data = get_form_data(frm)
    assert form_data["s_%d_g_0" % shop.id] == 250
    assert form_data["s_0_g_0"] == 200
开发者ID:charn,项目名称:shoop,代码行数:14,代码来源:test_form.py


示例12: test_contact_group_members_formset

def test_contact_group_members_formset(rf):
    FormSet = formset_factory(ContactGroupMembersForm, ContactGroupMembersFormSet, extra=1, can_delete=True)
    contact_group = get_default_customer_group()
    person = create_random_person()

    # No members
    formset = FormSet(contact_group=contact_group)
    assert formset.initial_form_count() == 0

    # Add a member
    data = dict(get_form_data(formset, True), **{"form-0-member": person.pk})
    formset = FormSet(contact_group=contact_group, data=data)
    formset.save()
    assert contact_group.members.filter(pk=person.pk).exists()
开发者ID:00WhengWheng,项目名称:shuup,代码行数:14,代码来源:test_contact_group_edit.py


示例13: test_context_contact_group_condition

def test_context_contact_group_condition(rf):
    original_price_value, discount_value = 123, 15
    request = get_request_for_contact_tests(rf)
    customer = create_random_person()
    default_group = get_default_customer_group()
    customer.groups.add(default_group)
    request.customer = customer

    condition = ContactGroupCondition.objects.create()
    condition.contact_groups.add(default_group)
    product = create_random_product_and_campaign(request.shop, [condition], original_price_value, discount_value)

    discounted_value = original_price_value - discount_value
    assert_product_price_value_with_customer(request, customer, product, discounted_value)

    request.customer.groups.clear()
    assert_product_price_value_with_customer(request, customer, product, original_price_value)
开发者ID:00WhengWheng,项目名称:shuup,代码行数:17,代码来源:test_context_conditions.py


示例14: test_no_customer

def test_no_customer(rf):
    shop = get_default_shop()
    group = get_default_customer_group()

    product = create_product("random-1", shop=shop, default_price=100)

    SimpleProductPrice.objects.create(product=product, group=group, shop=shop, price=50)

    request = rf.get("/")
    request.shop = shop

    spm = SimplePricingModule()
    pricing_context = spm.get_context_from_request(request)

    price_info = spm.get_price_info(pricing_context, product)

    assert price_info.price == TaxfulPrice(100)
开发者ID:portlyjent,项目名称:shoop,代码行数:17,代码来源:test_simple_pricing.py


示例15: test_editing_sales_ranges

def test_editing_sales_ranges(rf, admin_user):
    shop = get_default_shop()
    group = get_default_customer_group()
    data = get_edit_view_data(shop, group, 1, 100)
    assert ContactGroupSalesRange.objects.count() == 0
    # To make this test work we need to mock members form_part since the
    # extra forms does not render correctly
    with patch.object(ContactGroupEditView, "base_form_part_classes", [ContactGroupBaseFormPart]):
        request = apply_request_middleware(rf.post("/", data=data), user=admin_user)
        view = ContactGroupEditView.as_view()
        response = view(request=request, pk=group.pk)
        if hasattr(response, "render"):
            response.render()
        assert response.status_code in [200, 302]

    sales_range = ContactGroupSalesRange.objects.filter(group=group, shop=shop).first()
    assert sales_range.min_value == 1
    assert sales_range.max_value == 100
开发者ID:monokrome,项目名称:shuup,代码行数:18,代码来源:test_sales_ranges_admin.py


示例16: test_basket_contact_group_condition

def test_basket_contact_group_condition(rf):
    product_price_value, campaign_discount_value = 123, 15
    request = get_request_for_contact_tests(rf)
    customer = create_random_person()
    default_group = get_default_customer_group()
    customer.groups.add(default_group)
    request.customer = customer

    condition = ContactGroupBasketCondition.objects.create()
    condition.contact_groups.add(default_group)
    basket, original_line_count, original_price = create_basket_and_campaign(
        request, [condition], product_price_value, campaign_discount_value)

    assert basket.customer == customer
    assert_discounted_basket(basket, original_line_count, original_price, campaign_discount_value)

    customer.groups.remove(default_group)
    assert_non_discounted_basket(basket, original_line_count, original_price)
开发者ID:monokrome,项目名称:shuup,代码行数:18,代码来源:test_basket_contact_conditions.py


示例17: initialize_test

def initialize_test(rf, include_tax=False):
    activate("en")
    shop = get_shop(prices_include_tax=include_tax)

    # Valid baskets needs some payment methods to be available
    get_payment_method(shop)
    # Since some of the baskets are created for the default shop:
    get_payment_method(None)

    group = get_default_customer_group()
    customer = create_random_person()
    customer.groups.add(group)
    customer.save()

    request = rf.get("/")
    request.shop = shop
    apply_request_middleware(request)
    request.customer = customer
    return request, shop, group
开发者ID:Reivax84,项目名称:shoop,代码行数:19,代码来源:__init__.py


示例18: test_sales_ranges_basic

def test_sales_ranges_basic():
    shop = get_default_shop()
    supplier = get_default_supplier()
    default_group = get_default_customer_group()
    # Create non active range for default group
    ContactGroupSalesRange.objects.create(group=default_group, shop=shop, min_value=0, max_value=0)
    person = create_random_person()
    default_group.members.add(person)
    initial_group_count = person.groups.count()
    sales_ranges = [
        ("silver", 0, 50),
        ("gold", 50, 100),
        ("diamond", 100, 1000)
    ]
    for identifier, min, max in sales_ranges:
        create_sales_range(identifier, shop, min, max)

    payment = create_fully_paid_order(shop, person, supplier, "sku1", 10)
    assert get_total_sales(shop, person) == 10
    update_customers_groups(Payment, payment)
    assert person.groups.count() == (initial_group_count + 1)
    assert bool([group for group in person.groups.all() if group.identifier == "silver"])
    # Since group has inactive range person shouldn't be removed from it
    assert bool([group for group in person.groups.all() if group == default_group])

    payment = create_fully_paid_order(shop, person, supplier, "sku2", 50)
    assert get_total_sales(shop, person) == 60
    update_customers_groups(Payment, payment)
    assert person.groups.count() == (initial_group_count + 1)
    assert bool([group for group in person.groups.all() if group.identifier == "gold"])
    # Since group has inactive range person shouldn't be removed from it
    assert bool([group for group in person.groups.all() if group == default_group])

    payment = create_fully_paid_order(shop, person, supplier, "sku3", 200)
    assert get_total_sales(shop, person) == 260
    update_customers_groups(Payment, payment)
    assert person.groups.count() == (initial_group_count + 1)
    assert bool([group for group in person.groups.all() if group.identifier == "diamond"])
    # Since group has inactive range person shouldn't be removed from it
    assert bool([group for group in person.groups.all() if group == default_group])
开发者ID:00WhengWheng,项目名称:shuup,代码行数:40,代码来源:test_sales_ranges.py


示例19: test_product_visibility

def test_product_visibility(rf, admin_user, regular_user):
    anon_contact = get_person_contact(AnonymousUser())
    shop_product = get_default_shop_product()
    admin_contact = get_person_contact(admin_user)
    regular_contact = get_person_contact(regular_user)


    with modify(shop_product.product, deleted=True):  # NB: assigning to `product` here works because `get_shop_instance` populates `_product_cache`
        assert error_exists(shop_product.get_visibility_errors(customer=anon_contact), "product_deleted")
        assert error_exists(shop_product.get_visibility_errors(customer=admin_contact), "product_deleted")
        with pytest.raises(ProductNotVisibleProblem):
            shop_product.raise_if_not_visible(anon_contact)
        assert not shop_product.is_list_visible()

    with modify(shop_product, visibility_limit=ProductVisibility.VISIBLE_TO_ALL, visible=False):
        assert error_exists(shop_product.get_visibility_errors(customer=anon_contact), "product_not_visible")
        assert error_does_not_exist(shop_product.get_visibility_errors(customer=admin_contact), "product_not_visible")
        assert not shop_product.is_list_visible()

    with modify(shop_product, visibility_limit=ProductVisibility.VISIBLE_TO_LOGGED_IN, visible=True):
        assert error_exists(shop_product.get_visibility_errors(customer=anon_contact), "product_not_visible_to_anonymous")
        assert error_does_not_exist(shop_product.get_visibility_errors(customer=admin_contact), "product_not_visible_to_anonymous")

    customer_group = get_default_customer_group()
    grouped_user = get_user_model().objects.create_user(username=printable_gibberish(20))
    grouped_contact = get_person_contact(grouped_user)
    with modify(shop_product, visibility_limit=ProductVisibility.VISIBLE_TO_GROUPS, visible=True):
        shop_product.visibility_groups.add(customer_group)
        customer_group.members.add(grouped_contact)
        customer_group.members.remove(get_person_contact(regular_user))
        assert error_does_not_exist(shop_product.get_visibility_errors(customer=grouped_contact), "product_not_visible_to_group")
        assert error_does_not_exist(shop_product.get_visibility_errors(customer=admin_contact), "product_not_visible_to_group")
        assert error_exists(shop_product.get_visibility_errors(customer=regular_contact), "product_not_visible_to_group")

    with modify(shop_product, listed=False):
        assert not shop_product.is_list_visible()

    with modify(shop_product, listed=True):
        assert shop_product.is_list_visible()
开发者ID:00WhengWheng,项目名称:shuup,代码行数:39,代码来源:test_products_in_shops.py


示例20: test_change_shop_price

def test_change_shop_price():
    product = _get_test_product()
    shop = get_default_shop()
    group = get_default_customer_group()
    price = shop.create_price

    form_field = "s_%d_g_%d" % (shop.id, group.id)

    frm = SimplePricingForm(product=product, empty_permitted=True)
    form_data = get_form_data(frm, prepared=True)
    # Price hike time!
    form_data[form_field] = "4000"
    frm = SimplePricingForm(product=product, data=form_data, empty_permitted=True)
    frm.full_clean()
    frm.save()
    assert SimpleProductPrice.objects.get(product=product, shop=shop, group=group).price == price(4000)

    # Never mind actually, same price for all shops
    form_data[form_field] = ""
    frm = SimplePricingForm(product=product, data=form_data, empty_permitted=True)
    frm.full_clean()
    frm.save()

    assert not SimpleProductPrice.objects.filter(product=product, shop=shop, group=group).exists()
开发者ID:akx,项目名称:shoop,代码行数:24,代码来源:test_form.py



注:本文中的shoop.testing.factories.get_default_customer_group函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python factories.get_default_product函数代码示例发布时间:2022-05-27
下一篇:
Python factories.create_random_person函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap