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

Python factories.get_default_supplier函数代码示例

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

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



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

示例1: get_frontend_order_state

def get_frontend_order_state(contact, valid_lines=True):
    """
    Get a dict structure mirroring what the frontend JavaScript would submit.
    :type contact: Contact|None
    """
    translation.activate("en")
    shop = get_default_shop()
    tax = Tax.objects.create(code="test_code", rate=decimal.Decimal("0.20"), name="Default")
    tax_class = TaxClass.objects.create(identifier="test_tax_class", name="Default")
    rule = TaxRule.objects.create(tax=tax)
    rule.tax_classes.add(tax_class)
    rule.save()
    product = create_product(
        sku=printable_gibberish(),
        supplier=get_default_supplier(),
        shop=shop
    )
    product.tax_class = tax_class
    product.save()
    if valid_lines:
        lines = [
            {"id": "x", "type": "product", "product": {"id": product.id}, "quantity": "32", "baseUnitPrice": 50},
            {"id": "y", "type": "other", "sku": "hello", "text": "A greeting", "quantity": 1, "unitPrice": "5.5"},
            {"id": "z", "type": "text", "text": "This was an order!", "quantity": 0},
        ]
    else:
        unshopped_product = create_product(sku=printable_gibberish(), supplier=get_default_supplier())
        not_visible_product = create_product(
            sku=printable_gibberish(),
            supplier=get_default_supplier(),
            shop=shop
        )
        not_visible_shop_product = not_visible_product.get_shop_instance(shop)
        not_visible_shop_product.visible = False
        not_visible_shop_product.save()
        lines = [
            {"id": "x", "type": "product"},  # no product?
            {"id": "x", "type": "product", "product": {"id": unshopped_product.id}},  # not in this shop?
            {"id": "y", "type": "product", "product": {"id": -product.id}},  # invalid product?
            {"id": "z", "type": "other", "quantity": 1, "unitPrice": "q"},  # what's that price?
            {"id": "rr", "type": "product", "quantity": 1, "product": {"id": not_visible_product.id}}  # not visible
        ]

    state = {
        "customer": {"id": contact.id if contact else None},
        "lines": lines,
        "methods": {
            "shippingMethod": {"id": get_default_shipping_method().id},
            "paymentMethod": {"id": get_default_payment_method().id},
        },
        "shop": {
            "selected": {
                "id": shop.id,
                "name": shop.name,
                "currency": shop.currency,
                "priceIncludeTaxes": shop.prices_include_tax
            }
        }
    }
    return state
开发者ID:Carolina061,项目名称:shoop,代码行数:60,代码来源:test_order_creator.py


示例2: seed_default

    def seed_default(self):
        migrator = MigrateCommand()
        migrator.stdout = self.stdout
        migrator.handle(database="default", verbosity=1, noinput=True, app_label=None, migration_name=None)

        if not Shop.objects.exists():
            Shop.objects.create(name="B2B", identifier="b2b", status=ShopStatus.ENABLED)
            try:
                tax_class = TaxClass.objects.create(identifier="default", tax_rate=0)
            except:
                tax_class = TaxClass.objects.create(identifier="default")

            PaymentMethod.objects.create(identifier="default", name="Invoice", tax_class=tax_class)
            PaymentMethod.objects.create(identifier="bank_xfer", name="Bank Transfer", tax_class=tax_class)
            PaymentMethod.objects.create(identifier="cash", name="Cash (Pickup Only)", tax_class=tax_class)
            ShippingMethod.objects.create(identifier="default", name="Post Parcel", tax_class=tax_class)
            ShippingMethod.objects.create(identifier="pickup", name="Pickup at Helsinki Store", tax_class=tax_class)
            create_default_order_statuses()
            get_default_supplier()
            ProductType.objects.create(identifier="default")
            SalesUnit.objects.create(identifier="pcs", short_name="pcs", name="pieces")
            print("Seeded basic shop information")
        if not User.objects.filter(is_superuser=True).exists():
            User.objects.create_superuser(
                username="admin",
                email="[email protected]",
                password="admin",
            )
            print("Superuser created: admin / admin")
开发者ID:tulimaki,项目名称:shoop-gifter-demo,代码行数:29,代码来源:b2b_import_demo.py


示例3: test_package

def test_package():
    shop = get_default_shop()
    supplier = get_default_supplier()
    package_product = create_product("PackageParent", shop=shop, supplier=supplier)
    assert not package_product.get_package_child_to_quantity_map()
    children = [create_product("PackageChild-%d" % x, shop=shop, supplier=supplier) for x in range(4)]
    package_def = {child: 1 + i for (i, child) in enumerate(children)}
    package_product.make_package(package_def)
    assert package_product.mode == ProductMode.PACKAGE_PARENT
    package_product.save()
    sp = package_product.get_shop_instance(shop)
    assert not list(sp.get_orderability_errors(supplier=supplier, quantity=1, customer=AnonymousContact()))

    with pytest.raises(ValueError):  # Test re-packaging fails
        package_product.make_package(package_def)

    # Check that OrderCreator can deal with packages

    source = BasketishOrderSource()
    source.lines.append(SourceLine(
        type=OrderLineType.PRODUCT,
        product=package_product,
        supplier=get_default_supplier(),
        quantity=10,
        unit_price=TaxlessPrice(10),
    ))

    source.shop = get_default_shop()
    source.status = get_initial_order_status()
    creator = OrderCreator(request=None)
    order = creator.create_order(source)
    pids_to_quantities = order.get_product_ids_and_quantities()
    for child, quantity in six.iteritems(package_def):
        assert pids_to_quantities[child.pk] == 10 * quantity
开发者ID:charn,项目名称:shoop,代码行数:34,代码来源:test_product_packages.py


示例4: test_order_source_parentage

def test_order_source_parentage(rf, admin_user):
    source = seed_source(admin_user)
    product = get_default_product()
    source.add_line(
        type=OrderLineType.PRODUCT,
        product=product,
        supplier=get_default_supplier(),
        quantity=1,
        base_unit_price=source.create_price(10),
        line_id="parent"
    )
    source.add_line(
        type=OrderLineType.OTHER,
        text="Child Line",
        sku="KIDKIDKID",
        quantity=1,
        base_unit_price=source.create_price(5),
        parent_line_id="parent"
    )
    request = apply_request_middleware(rf.get("/"))

    creator = OrderCreator(request)
    order = Order.objects.get(pk=creator.create_order(source).pk)
    kid_line = order.lines.filter(sku="KIDKIDKID").first()
    assert kid_line
    assert kid_line.parent_line.product_id == product.pk
开发者ID:DemOneEh,项目名称:shoop,代码行数:26,代码来源:test_order_creator.py


示例5: test_order_creator

def test_order_creator(rf, admin_user):
    source = seed_source(admin_user)
    source.add_line(
        type=OrderLineType.PRODUCT,
        product=get_default_product(),
        supplier=get_default_supplier(),
        quantity=1,
        base_unit_price=source.create_price(10),
    )
    source.add_line(
        type=OrderLineType.OTHER,
        quantity=1,
        base_unit_price=source.create_price(10),
        require_verification=True,
    )

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

    creator = OrderCreator(request)
    order = creator.create_order(source)
    assert get_data_dict(source.billing_address) == get_data_dict(order.billing_address)
    assert get_data_dict(source.shipping_address) == get_data_dict(order.shipping_address)
    assert source.customer == order.customer
    assert source.payment_method == order.payment_method
    assert source.shipping_method == order.shipping_method
    assert order.pk
开发者ID:DemOneEh,项目名称:shoop,代码行数:26,代码来源:test_order_creator.py


示例6: test_basket_shipping_error

def test_basket_shipping_error(rf):
    StoredBasket.objects.all().delete()
    shop = get_default_shop()
    supplier = get_default_supplier()
    shipped_product = create_product(
        printable_gibberish(), shop=shop, supplier=supplier, default_price=50,
        shipping_mode=ShippingMode.SHIPPED
    )
    unshipped_product = create_product(
        printable_gibberish(), shop=shop, supplier=supplier, default_price=50,
        shipping_mode=ShippingMode.NOT_SHIPPED
    )

    request = rf.get("/")
    request.session = {}
    request.shop = shop
    apply_request_middleware(request)
    basket = get_basket(request)

    # With a shipped product but no shipping methods, we oughta get an error
    basket.add_product(supplier=supplier, shop=shop, product=shipped_product, quantity=1)
    assert any(ve.code == "no_common_shipping" for ve in basket.get_validation_errors())
    basket.clear_all()

    # But with an unshipped product, we should not
    basket.add_product(supplier=supplier, shop=shop, product=unshipped_product, quantity=1)
    assert not any(ve.code == "no_common_shipping" for ve in basket.get_validation_errors())
开发者ID:00WhengWheng,项目名称:shuup,代码行数:27,代码来源:test_basket.py


示例7: _get_frontend_order_state

def _get_frontend_order_state(shop, contact):
    tax = Tax.objects.create(code="test_code", rate=decimal.Decimal("0.20"), name="Default")
    tax_class = TaxClass.objects.create(identifier="test_tax_class", name="Default")
    rule = TaxRule.objects.create(tax=tax)
    rule.tax_classes.add(tax_class)
    rule.save()
    product = create_product(
        sku=printable_gibberish(),
        supplier=get_default_supplier(),
        shop=shop
    )
    product.tax_class = tax_class
    product.save()
    lines = [
        {"id": "x", "type": "product", "product": {"id": product.id}, "quantity": "32", "baseUnitPrice": 50}
    ]

    state = {
        "customer": {"id": contact.id if contact else None},
        "lines": lines,
        "methods": {
            "shippingMethod": {"id": get_shipping_method(shop=shop).id},
            "paymentMethod": {"id": get_payment_method(shop=shop).id},
        },
        "shop": {
            "selected": {
                "id": shop.id,
                "name": shop.safe_translation_getter("name"),
                "currency": shop.currency,
                "priceIncludeTaxes": shop.prices_include_tax
            }
        }
    }
    return state
开发者ID:NinaWelch,项目名称:shoop,代码行数:34,代码来源:test_order_edit_with_coupons.py


示例8: test_percentage_campaign

def test_percentage_campaign(rf):
    request, shop, group = initialize_test(rf, False)
    price = shop.create_price

    basket = get_basket(request)
    supplier = get_default_supplier()
    # create a basket rule that requires atleast value of 200
    rule = BasketTotalAmountCondition.objects.create(value="200")

    product_price = "200"

    discount_percentage = "0.1"

    expected_discounted_price = price(product_price) - (price(product_price) * Decimal(discount_percentage))

    product = create_product(printable_gibberish(), shop=shop, supplier=supplier, default_price=product_price)
    basket.add_product(supplier=supplier, shop=shop, product=product, quantity=1)

    campaign = BasketCampaign.objects.create(
        shop=shop, public_name="test", name="test", discount_percentage=discount_percentage, active=True
    )
    campaign.conditions.add(rule)
    campaign.save()

    assert len(basket.get_final_lines()) == 2
    assert basket.product_count == 1
    assert basket.total_price == expected_discounted_price
开发者ID:luizgustavo90,项目名称:shoop,代码行数:27,代码来源:test_basket_campaigns.py


示例9: test_form_populate_initial_data

def test_form_populate_initial_data(rf, admin_user):
    shop = get_default_shop()
    supplier = get_default_supplier()
    initial_discount_amount = 20
    campaign = BasketCampaign.objects.create(shop=shop)
    BasketDiscountAmount.objects.create(campaign=campaign, discount_amount=initial_discount_amount)

    # Test that correct initial value is returned for non-many-to-many field
    product_amount_initial = 10
    product_amount_condition = BasketTotalProductAmountCondition(product_count=product_amount_initial)
    product_amount_condition.save()
    campaign.conditions.add(product_amount_condition)

    products_count_initial = 5
    for i in range(products_count_initial):
        create_product(printable_gibberish(), shop=shop, supplier=supplier, default_price="20")
    products_initial = Product.objects.all()[:products_count_initial]
    assert len(products_initial) == products_count_initial

    # Test that correct initial value is returned for many-to-many field
    products_in_basket_condition = ProductsInBasketCondition.objects.create()
    products_in_basket_condition.values = products_initial
    products_in_basket_condition.save()
    campaign.conditions.add(products_in_basket_condition)

    assert len(campaign.conditions.all()) == 2
    assert campaign.effects.count() == 1

    request=apply_request_middleware(rf.get("/"), user=admin_user)
    form = BasketCampaignForm(request=request, instance=campaign)
    assert form.fields["basket_product_condition"].initial == product_amount_initial
    assert set(form.fields["basket_products_condition"].initial) == set([p.pk for p in products_initial])
    assert form.fields["discount_amount_effect"].initial == initial_discount_amount
开发者ID:00WhengWheng,项目名称:shuup,代码行数:33,代码来源:test_admin.py


示例10: test_basket_campaign_module_case1

def test_basket_campaign_module_case1(rf):
    request, shop, group = initialize_test(rf, False)
    price = shop.create_price

    basket = get_basket(request)
    supplier = get_default_supplier()

    single_product_price = "50"
    discount_amount_value = "10"

     # create basket rule that requires 2 products in basket
    basket_rule1 = BasketTotalProductAmountCondition.objects.create(value="2")

    product = create_product(printable_gibberish(), shop=shop, supplier=supplier, default_price=single_product_price)

    basket.add_product(supplier=supplier, shop=shop, product=product, quantity=1)
    basket.save()

    assert basket.product_count == 1

    campaign = BasketCampaign.objects.create(
        shop=shop, public_name="test", name="test", discount_amount_value=discount_amount_value, active=True)
    campaign.conditions.add(basket_rule1)
    campaign.save()

    assert len(basket.get_final_lines()) == 1  # case 1
    assert basket.total_price == price(single_product_price) # case 1

    basket.add_product(supplier=supplier, shop=shop, product=product, quantity=1)
    basket.save()

    assert len(basket.get_final_lines()) == 2  # case 1
    assert basket.product_count == 2
    assert basket.total_price == (price(single_product_price) * basket.product_count - price(discount_amount_value))
    assert OrderLineType.DISCOUNT in [l.type for l in basket.get_final_lines()]
开发者ID:NARESHARADHYULA,项目名称:shoop,代码行数:35,代码来源:test_basket_campaigns.py


示例11: get_order_and_source

def get_order_and_source(admin_user):
    # create original source to tamper with
    source = BasketishOrderSource(get_default_shop())
    source.status = get_initial_order_status()
    source.billing_address = MutableAddress.objects.create(name="Original Billing")
    source.shipping_address = MutableAddress.objects.create(name="Original Shipping")
    source.customer = get_person_contact(admin_user)
    source.payment_method = get_default_payment_method()
    source.shipping_method = get_default_shipping_method()
    source.add_line(
        type=OrderLineType.PRODUCT,
        product=get_default_product(),
        supplier=get_default_supplier(),
        quantity=1,
        base_unit_price=source.create_price(10),
    )
    source.add_line(
        type=OrderLineType.OTHER,
        quantity=1,
        base_unit_price=source.create_price(10),
        require_verification=True,
    )
    assert len(source.get_lines()) == 2
    source.creator = admin_user
    creator = OrderCreator()
    order = creator.create_order(source)
    return order, source
开发者ID:00WhengWheng,项目名称:shuup,代码行数:27,代码来源:test_order_modifier.py


示例12: __init__

 def __init__(self, image_dir):
     self.image_dir = image_dir
     self.supplier = get_default_supplier()
     self.sales_unit = SalesUnit.objects.first()
     self.tax_class = TaxClass.objects.first()
     self.product_type = ProductType.objects.first()
     self.shop = Shop.objects.first()
开发者ID:akx,项目名称:shoop-wintergear-demo,代码行数:7,代码来源:importer.py


示例13: test_tracking_codes

def test_tracking_codes():
    product = get_default_product()
    supplier = get_default_supplier()
    order = create_order_with_product(
        product,
        supplier=supplier,
        quantity=1,
        taxless_base_unit_price=10,
        tax_rate=decimal.Decimal("0.5")
    )
    _add_product_to_order(order, "duck-tape-1", 3, order.shop, supplier)
    _add_product_to_order(order, "water-1", 2, order.shop, supplier)

    order.cache_prices()
    order.check_all_verified()
    order.save()

    # Create shipment with tracking code for every product line.
    product_lines = order.lines.exclude(product_id=None)
    assert len(product_lines) == 3
    for line in product_lines:
        shipment = order.create_shipment(supplier, {line.product: line.quantity})
        if line.quantity != 3:
            shipment.tracking_code = "123FI"
            shipment.save()

    tracking_codes = order.get_tracking_codes()
    code_count = (len(product_lines)-1)  # We skipped that one
    assert len(tracking_codes) == code_count
    assert len([tracking_code for tracking_code in tracking_codes if tracking_code == "123FI"]) == code_count
开发者ID:MUDASSARHASHMI,项目名称:shoop,代码行数:30,代码来源:test_tracking_codes.py


示例14: test_best_selling_products_with_multiple_orders

def test_best_selling_products_with_multiple_orders():
    context = get_jinja_context()
    supplier = get_default_supplier()
    shop = get_default_shop()
    n_products = 2
    price = 10

    product_1 = create_product("test-sku-1", supplier=supplier, shop=shop)
    product_2 = create_product("test-sku-2", supplier=supplier, shop=shop)
    create_order_with_product(product_1, supplier, quantity=1, taxless_base_unit_price=price, shop=shop)
    create_order_with_product(product_2, supplier, quantity=1, taxless_base_unit_price=price, shop=shop)
    cache.clear()
    # Two initial products sold
    assert product_1 in general.get_best_selling_products(context, n_products=n_products)
    assert product_2 in general.get_best_selling_products(context, n_products=n_products)

    product_3 = create_product("test-sku-3", supplier=supplier, shop=shop)
    create_order_with_product(product_3, supplier, quantity=2, taxless_base_unit_price=price, shop=shop)
    cache.clear()
    # Third product sold in greater quantity
    assert product_3 in general.get_best_selling_products(context, n_products=n_products)

    create_order_with_product(product_1, supplier, quantity=4, taxless_base_unit_price=price, shop=shop)
    create_order_with_product(product_2, supplier, quantity=4, taxless_base_unit_price=price, shop=shop)
    cache.clear()
    # Third product outsold by first two products
    assert product_3 not in general.get_best_selling_products(context, n_products=n_products)
开发者ID:Reivax84,项目名称:shoop,代码行数:27,代码来源:test_general_template_helpers.py


示例15: test_protected_fields

def test_protected_fields():
    activate("en")
    shop = Shop.objects.create(
        name="testshop",
        identifier="testshop",
        status=ShopStatus.ENABLED,
        public_name="test shop",
        domain="derp",
        currency="EUR"
    )
    assert shop.name == "testshop"
    assert shop.currency == "EUR"
    shop_form = ShopBaseForm(instance=shop, languages=settings.LANGUAGES)
    assert not shop_form._get_protected_fields()  # No protected fields just yet, right?
    data = get_form_data(shop_form, prepared=True)
    shop_form = ShopBaseForm(data=data, instance=shop, languages=settings.LANGUAGES)
    _test_cleanliness(shop_form)
    shop_form.save()

    # Now let's make it protected!
    create_product(printable_gibberish(), shop=shop, supplier=get_default_supplier())
    order = create_random_order(customer=create_random_person(), shop=shop)
    assert order.shop == shop

    # And try again...
    data["currency"] = "XBT"  # Bitcoins!
    shop_form = ShopBaseForm(data=data, instance=shop, languages=settings.LANGUAGES)
    assert shop_form._get_protected_fields()  # So protected!
    _test_cleanliness(shop_form)
    shop = shop_form.save()
    assert shop.currency == "EUR"  # But the shop form ignored the change . . .
开发者ID:00WhengWheng,项目名称:shuup,代码行数:31,代码来源:test_shop_edit.py


示例16: test_only_cheapest_price_is_selected

def test_only_cheapest_price_is_selected(rf):
    request, shop, group = initialize_test(rf, False)
    price = shop.create_price

    basket = get_basket(request)
    supplier = get_default_supplier()
    # create a basket rule that requires atleast value of 200
    rule = BasketTotalAmountCondition.objects.create(value="200")

    product_price = "200"

    discount1 = "10"
    discount2 = "20"  # should be selected
    product = create_product(printable_gibberish(), shop=shop, supplier=supplier, default_price=product_price)
    basket.add_product(supplier=supplier, shop=shop, product=product, quantity=1)

    campaign = BasketCampaign.objects.create(
        shop=shop, public_name="test", name="test", discount_amount_value=discount1, active=True
    )
    campaign.conditions.add(rule)
    campaign.save()

    campaign = BasketCampaign.objects.create(
        shop=shop, public_name="test", name="test", discount_amount_value=discount2, active=True
    )
    campaign.conditions.add(rule)
    campaign.save()

    assert len(basket.get_final_lines()) == 2
    line_types = [l.type for l in basket.get_final_lines()]
    assert OrderLineType.DISCOUNT in line_types

    for line in basket.get_final_lines():
        if line.type == OrderLineType.DISCOUNT:
            assert line.discount_amount == price(discount2)
开发者ID:luizgustavo90,项目名称:shoop,代码行数:35,代码来源:test_basket_campaigns.py


示例17: test_complex_variation

def test_complex_variation():
    request = get_request_with_basket()
    basket = request.basket
    shop = get_default_shop()
    supplier = get_default_supplier()

    parent = create_product("SuperComplexVarParent", shop=shop, supplier=supplier)
    color_var = ProductVariationVariable.objects.create(product=parent, identifier="color")
    size_var = ProductVariationVariable.objects.create(product=parent, identifier="size")

    ProductVariationVariableValue.objects.create(variable=color_var, identifier="yellow")
    ProductVariationVariableValue.objects.create(variable=size_var, identifier="small")

    combinations = list(parent.get_all_available_combinations())
    for combo in combinations:
        child = create_product("xyz-%s" % combo["sku_part"], shop=shop, supplier=supplier)
        child.link_to_parent(parent, combo["variable_to_value"])

    # Elided product should not yield a result
    yellow_color_value = ProductVariationVariableValue.objects.get(variable=color_var, identifier="yellow")
    small_size_value = ProductVariationVariableValue.objects.get(variable=size_var, identifier="small")

    # add to basket yellow + small
    kwargs = {"var_%d" % color_var.pk: yellow_color_value.pk, "var_%d" % size_var.pk: small_size_value.pk}

    basket_commands.handle_add_var(request, basket, 1, **kwargs)
    assert basket.get_product_ids_and_quantities()[child.pk] == 1

    with pytest.raises(ValidationError):
        kwargs = {"var_%d" % color_var.pk: yellow_color_value.pk, "var_%d" % size_var.pk: small_size_value.pk + 1}
        basket_commands.handle_add_var(request, basket, 1, **kwargs)
开发者ID:akx,项目名称:shoop,代码行数:31,代码来源:test_basket_commands.py


示例18: test_order_creation_adds_usage

def test_order_creation_adds_usage(rf, admin_user):
    request, shop, group = initialize_test(rf, False)

    source = seed_source(admin_user)
    source.add_line(
        type=OrderLineType.PRODUCT,
        product=get_default_product(),
        supplier=get_default_supplier(),
        quantity=1,
        base_unit_price=source.create_price(10),
    )
    source.add_line(
        type=OrderLineType.OTHER, quantity=1, base_unit_price=source.create_price(10), require_verification=True
    )

    # add coupon
    coupon = Coupon.objects.create(active=True, code="asdf")

    campaign = BasketCampaign.objects.create(
        active=True, shop=shop, name="test", public_name="test", discount_percentage="0.1", coupon=coupon
    )

    source.add_code(coupon.code)

    request = apply_request_middleware(rf.get("/"))
    creator = OrderCreator(request)
    order = creator.create_order(source)

    assert CouponUsage.objects.count() == 1
开发者ID:luizgustavo90,项目名称:shoop,代码行数:29,代码来源:test_basket_campaigns.py


示例19: test_add_and_remove_and_clear

def test_add_and_remove_and_clear():
    product = get_default_product()
    supplier = get_default_supplier()
    request = get_request_with_basket()
    basket = request.basket

    with pytest.raises(ValidationError):
        basket_commands.handle_add(request, basket, product_id=product.pk, quantity=-3)  # Ordering antimatter is not supported

    # These will get merged into one line...
    basket_commands.handle_add(request, basket, **{"product_id": product.pk, "quantity": 1, "supplier_id": supplier.pk})
    basket_commands.handle_add(request, basket, **{"product_id": product.pk, "quantity": 2})
    # ... so there will be 3 products but one line
    assert basket.product_count == 3
    lines = basket.get_lines()
    assert len(lines) == 1
    # ... and deleting that line will clear the basket...
    basket_commands.handle_del(request, basket, lines[0].line_id)
    assert basket.product_count == 0
    # ... and adding another product will create a new line...
    basket_commands.handle_add(request, basket, product_id=product.pk, quantity=1)
    assert basket.product_count == 1
    # ... that can be cleared.
    basket_commands.handle_clear(request, basket)
    assert basket.product_count == 0
开发者ID:akx,项目名称:shoop,代码行数:25,代码来源:test_basket_commands.py


示例20: test_custom_payment_processor_cash_service

def test_custom_payment_processor_cash_service(choice_identifier, expected_payment_status):
    shop = get_default_shop()
    product = get_default_product()
    supplier = get_default_supplier()
    processor = CustomPaymentProcessor.objects.create()
    payment_method = PaymentMethod.objects.create(
        shop=shop,
        payment_processor=processor,
        choice_identifier=choice_identifier,
        tax_class=get_default_tax_class())
    order = create_order_with_product(
        product=product,
        supplier=supplier,
        quantity=1,
        taxless_base_unit_price=Decimal('5.55'),
        shop=shop)
    order.taxful_total_price = TaxfulPrice(Decimal('5.55'), u'EUR')
    order.payment_method = payment_method
    order.save()

    assert order.payment_status == PaymentStatus.NOT_PAID
    processor.process_payment_return_request(choice_identifier, order, None)
    assert order.payment_status == expected_payment_status
    processor.process_payment_return_request(choice_identifier, order, None)
    assert order.payment_status == expected_payment_status
开发者ID:monokrome,项目名称:shuup,代码行数:25,代码来源:test_custom_payment_processor.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python factories.get_initial_order_status函数代码示例发布时间:2022-05-27
下一篇:
Python factories.get_default_shop函数代码示例发布时间: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