当前位置: 首页>>代码示例>>Python>>正文


Python factories.get_default_customer_group函数代码示例

本文整理汇总了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函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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