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


Python factories.get_default_customer_group函数代码示例

本文整理汇总了Python中shuup.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_admin_edit

def test_admin_edit(rf, admin_user):
    shop = get_default_shop()

    group = get_default_customer_group(shop)
    cgpd = ContactGroupPriceDisplay.objects.for_group_and_shop(group, shop)
    view = ContactGroupPriceDisplayEditView.as_view()


    options = get_price_display_options_for_group_and_shop(group, shop)
    assert options.show_prices

    request = apply_request_middleware(rf.get("/"), user=admin_user)
    response = view(request, pk=cgpd.pk)
    response.render()
    content = force_text(response.content)

    data = extract_form_fields(BeautifulSoup(content))

    data.update({
        "price_display_mode": [PriceDisplayChoices.HIDE.value],
        "group": group.id,
    })

    request = apply_request_middleware(rf.post("/", data), user=admin_user, shop=shop)
    response = view(request, pk=cgpd.pk)
    assert response.status_code == 302  # save successful

    group = get_default_customer_group(shop)

    options = get_price_display_options_for_group_and_shop(group, shop)
    assert options.show_prices is False
    assert options.include_taxes is None

    # none, with_taxes, without_taxes, hide
    k = "price_display_mode"
    data.update({k: [PriceDisplayChoices.NONE.value]})
    request = apply_request_middleware(rf.post("/", data), user=admin_user, shop=shop)
    response = view(request, pk=cgpd.pk)
    assert response.status_code == 302  # save successful

    options = get_price_display_options_for_group_and_shop(group, shop)
    assert options.show_prices is True  # default
    assert options.include_taxes is None

    data.update({k: [PriceDisplayChoices.WITH_TAXES.value]})
    request = apply_request_middleware(rf.post("/", data), user=admin_user, shop=shop)
    response = view(request, pk=cgpd.pk)
    assert response.status_code == 302  # save successful
    options = get_price_display_options_for_group_and_shop(group, shop)
    assert options.show_prices is True  # default
    assert options.include_taxes is True

    data.update({k: [PriceDisplayChoices.WITHOUT_TAXES.value]})
    request = apply_request_middleware(rf.post("/", data), user=admin_user, shop=shop)
    response = view(request, pk=cgpd.pk)
    assert response.status_code == 302  # save successful

    options = get_price_display_options_for_group_and_shop(group, shop)
    assert options.show_prices is True
    assert options.include_taxes is False
开发者ID:ruqaiya,项目名称:shuup,代码行数:60,代码来源:test_contact_price_display.py

示例2: _get_test_product

def _get_test_product():
    shop = get_default_shop()
    product = create_product("Just-A-Pricing-Product", shop, default_price=200)
    CgpPrice.objects.create(
        product=product, shop=shop, group=get_default_customer_group(),
        price_value=250)
    CgpDiscount.objects.create(
        product=product, shop=shop, group=get_default_customer_group(),
        discount_amount_value=100)
    return product
开发者ID:ruqaiya,项目名称:shuup,代码行数:10,代码来源:test_form.py

示例3: test_change_shop_price

def test_change_shop_price(form):
    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 = form(product=product, shop=shop, empty_permitted=True)
    form_data = get_form_data(frm, prepared=True)

    if form == CustomerGroupPricingForm:
        form_data[form_field] = "4000"
    else:
        form_data[form_field] = "50"

    frm = form(product=product, shop=shop, data=form_data, empty_permitted=True)
    frm.full_clean()
    frm.save()

    if form == CustomerGroupPricingForm:
        assert CgpPrice.objects.get(product=product, shop=shop, group=group).price == price(4000)
    else:
        assert CgpDiscount.objects.get(product=product, shop=shop, group=group).discount_amount == price(50)

    # Never mind actually, same price for all shops
    form_data[form_field] = ""

    frm = form(product=product, shop=shop, data=form_data, empty_permitted=True)
    frm.full_clean()
    frm.save()

    if form == CustomerGroupPricingForm:
        assert not CgpPrice.objects.filter(product=product, shop=shop, group=group).exists()
    else:
        assert not CgpDiscount.objects.filter(product=product, shop=shop, group=group).exists()
开发者ID:ruqaiya,项目名称:shuup,代码行数:35,代码来源:test_form.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')
        },
        StaffOnlyBehaviorComponent.__name__.lower(): {}
    }
开发者ID:ahmadzai,项目名称:shuup,代码行数:34,代码来源:test_service_behavior_components.py

示例5: 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, visibility=ShopProductVisibility.NOT_VISIBLE):
        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, visibility=ShopProductVisibility.ALWAYS_VISIBLE):
        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, visibility=ShopProductVisibility.ALWAYS_VISIBLE):
        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")
开发者ID:hrayr-artunyan,项目名称:shuup,代码行数:33,代码来源:test_products_in_shops.py

示例6: 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:suutari,项目名称:shoop,代码行数:26,代码来源:test_sales_ranges_admin.py

示例7: 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:NamiStudio,项目名称:shuup,代码行数:35,代码来源:test_plugins.py

示例8: test_order_creator_customer_details

def test_order_creator_customer_details(rf, admin_user):
    shop = get_default_shop()
    contact = create_random_person(locale="en_US", minimum_name_comp_len=5)
    company = create_random_company()
    group = get_default_customer_group()
    contact.groups.add(group)
    contact.company_memberships.add(company)
    contact.save()
    product = create_product(sku=printable_gibberish(), supplier=get_default_supplier(), shop=shop)
    order = create_random_order(contact, products=[product])
    request = apply_request_middleware(rf.get("/", {"command": "customer_details", "id": contact.id}), user=admin_user)
    response = OrderEditView.as_view()(request)
    data = json.loads(response.content.decode("utf8"))

    assert "customer_info" in data
    assert "order_summary" in data
    assert "recent_orders" in data
    assert data["customer_info"]["name"] == contact.full_name
    assert data["customer_info"]["phone_no"] == contact.phone
    assert data["customer_info"]["email"] == contact.email
    assert company.full_name in data["customer_info"]["companies"]
    assert group.name in data["customer_info"]["groups"]
    assert data["customer_info"]["merchant_notes"] == contact.merchant_notes
    assert len(data["order_summary"]) == 1
    assert data["order_summary"][0]["year"] == order.order_date.year
    assert data["order_summary"][0]["total"] == format_money(order.taxful_total_price)
    assert len(data["recent_orders"]) == 1
    assert data["recent_orders"][0]["status"] == order.get_status_display()
    assert data["recent_orders"][0]["total"] == format_money(order.taxful_total_price)
    assert data["recent_orders"][0]["payment_status"] == force_text(order.payment_status.label)
    assert data["recent_orders"][0]["shipment_status"] == force_text(order.shipping_status.label)
开发者ID:suutari,项目名称:shoop,代码行数:31,代码来源:test_order_creator.py

示例9: test_basic_form_sanity

def test_basic_form_sanity(form):
    shop = get_default_shop()
    group = get_default_customer_group()
    product = _get_test_product()
    frm = form(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:suutari-ai,项目名称:shuup,代码行数:9,代码来源:test_form.py

示例10: 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:suutari,项目名称:shoop,代码行数:10,代码来源:test_sales_ranges_admin.py

示例11: 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:hrayr-artunyan,项目名称:shuup,代码行数:10,代码来源:test_catalog_campaigns.py

示例12: 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 DEFAULT_IDENTIFIER in user.contact.groups.values_list("identifier", flat=True), "Joe is now in the group"
开发者ID:suutari,项目名称:shoop,代码行数:11,代码来源:test_customers.py

示例13: 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:NamiStudio,项目名称:shuup,代码行数:12,代码来源:test_customer_group_pricing.py

示例14: test_with_multiple_groups

def test_with_multiple_groups(admin_user):
    payment_method = get_default_payment_method()
    group = get_default_customer_group()
    person = create_random_person()
    groups = [group, person.get_default_group()]
    _assign_component_for_service(payment_method, groups)

    person.user = admin_user
    person.save()
    source = _get_source_for_contact(admin_user, payment_method)
    assert source.customer == person
    assert len([group for group in person.groups.all() if group in groups]) == 1
    _test_service_availability(source, payment_method, True)
开发者ID:ruqaiya,项目名称:shuup,代码行数:13,代码来源:test_contact_group_behavior.py

示例15: test_basic_form_sanity

def test_basic_form_sanity(form):
    shop = get_default_shop()
    group = get_default_customer_group()
    product = _get_test_product()

    kwargs = dict(product=product, shop=shop)
    if form == CustomerGroupPricingForm:
        kwargs.update(dict(empty_permitted=True))

    frm = form(**kwargs)

    assert len(frm.groups) == ContactGroup.objects.count()

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


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