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

Python factories.create_empty_order函数代码示例

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

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



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

示例1: test_process_payment_return_request

def test_process_payment_return_request(rf):
    """
    Order payment with default payment method with ``CustomPaymentProcessor``
    should be deferred.

    Payment can't be processed if method doesn't have provider or provider
    is not enabled or payment method is not enabled.
    """
    pm = PaymentMethod.objects.create(
        shop=get_default_shop(), name="Test method", enabled=False, tax_class=get_default_tax_class())
    order = create_empty_order()
    order.payment_method = pm
    order.save()
    assert order.payment_status == PaymentStatus.NOT_PAID
    with pytest.raises(ValueError):  # Can't process payment with unusable method
        order.payment_method.process_payment_return_request(order, rf.get("/"))
    assert order.payment_status == PaymentStatus.NOT_PAID
    pm.payment_processor = get_custom_payment_processor()
    pm.payment_processor.enabled = False
    pm.save()

    with pytest.raises(ValueError):  # Can't process payment with unusable method
        order.payment_method.process_payment_return_request(order, rf.get("/"))
    assert order.payment_status == PaymentStatus.NOT_PAID
    pm.payment_processor.enabled = True
    pm.save()

    with pytest.raises(ValueError):  # Can't process payment with unusable method
        order.payment_method.process_payment_return_request(order, rf.get("/"))
    assert order.payment_status == PaymentStatus.NOT_PAID
    pm.enabled = True
    pm.save()

    order.payment_method.process_payment_return_request(order, rf.get("/"))
    assert order.payment_status == PaymentStatus.DEFERRED
开发者ID:00WhengWheng,项目名称:shuup,代码行数:35,代码来源:test_methods.py


示例2: test_refno_generation

def test_refno_generation(method):
    for attempt in range(10):
        with override_settings(SHOOP_REFERENCE_NUMBER_METHOD=method):
            order = create_empty_order()
            order.save()
            assert order.reference_number
        with pytest.raises(ValueError):
            get_reference_number(order)
开发者ID:taedori81,项目名称:shoop,代码行数:8,代码来源:test_order_reference.py


示例3: test_custom_ident_generation

def test_custom_ident_generation():
    methods = (
        custom_ident_gen,
        "%s.%s" % (__name__, custom_ident_gen.__name__)
    )
    for method in methods:
        with override_settings(SHOOP_ORDER_IDENTIFIER_METHOD=method):
            order = create_empty_order()
            order.save()
            assert order.identifier == custom_ident_gen(order)
        with pytest.raises(ValueError):
            get_order_identifier(order)
开发者ID:taedori81,项目名称:shoop,代码行数:12,代码来源:test_order_reference.py


示例4: test_custom_refno_generation

def test_custom_refno_generation():
    methods = (
        custom_refno_gen,
        "%s.%s" % (__name__, custom_refno_gen.__name__)
    )
    for method in methods:
        with override_settings(SHOOP_REFERENCE_NUMBER_METHOD=method):
            order = create_empty_order()
            order.save()
            assert order.reference_number == custom_refno_gen(order)
        with pytest.raises(ValueError):
            get_reference_number(order)
开发者ID:taedori81,项目名称:shoop,代码行数:12,代码来源:test_order_reference.py


示例5: test_empty_order

def test_empty_order():
    order = create_empty_order()
    order.save()
    with pytest.raises(NoProductsToShipException):
        order.create_shipment_of_all_products()
    with pytest.raises(NoProductsToShipException):
        order.create_shipment(supplier=None, product_quantities={1: 0})
    order.set_canceled()
    assert not order.can_set_complete(), "Can't process canceled order"
    order.set_canceled()  # Again! (This should be a no-op)
    order.delete()
    assert order.pk and order.deleted, "Order is soft-deleted"
    order.delete()  # Again! (This, too, should be a no-op)
开发者ID:Jeewes,项目名称:shoop,代码行数:13,代码来源:test_orders.py


示例6: test_shipment_creation_with_invalid_unsaved_shipment

def test_shipment_creation_with_invalid_unsaved_shipment():
    shop = get_default_shop()
    supplier = get_default_supplier()
    order = _get_order(shop, supplier)
    second_order = create_empty_order(shop=shop)
    second_order.full_clean()
    second_order.save()
    product_lines = order.lines.exclude(product_id=None)
    for line in product_lines:
        for i in range(0, int(line.quantity)):
            with pytest.raises(AssertionError):
                unsaved_shipment = Shipment(supplier=supplier, order=second_order)
                order.create_shipment({line.product: 1}, shipment=unsaved_shipment)
    assert order.shipments.count() == 0
开发者ID:00WhengWheng,项目名称:shuup,代码行数:14,代码来源:test_shipments.py


示例7: test_editing_existing_order

def test_editing_existing_order(rf, admin_user):
    modifier = UserFactory()
    get_initial_order_status()  # Needed for the API
    contact = create_random_person(locale="en_US", minimum_name_comp_len=5)
    state = get_frontend_order_state(contact=contact)
    shop = get_default_shop()
    order = create_empty_order(shop=shop)
    order.payment_data = {"payment_data": True}
    order.shipping_data = {"shipping_data": True}
    order.extra_data = {"external_id": "123"}
    order.save()
    assert order.lines.count() == 0
    assert order.pk is not None
    assert order.modified_by == order.creator
    request = get_frontend_request_for_command(state, "finalize", modifier)
    response = OrderEditView.as_view()(request, pk=order.pk)
    assert_contains(response, "orderIdentifier")  # this checks for status codes as a side effect
    data = json.loads(response.content.decode("utf8"))
    edited_order = Order.objects.get(pk=order.pk)  # Re fetch the initial order

    # Check that identifiers has not changed
    assert edited_order.identifier == data["orderIdentifier"] == order.identifier
    assert edited_order.pk == order.pk

    # Check that the product content is updated based on state
    assert edited_order.lines.count() == 5
    assert edited_order.customer == contact

    # Check that product line have right taxes
    for line in edited_order.lines.all():
        if line.type == OrderLineType.PRODUCT:
            assert [line_tax.tax.code for line_tax in line.taxes.all()] == ["test_code"]
            assert line.taxful_price.amount > line.taxless_price.amount

    # Make sure order modification information is correct
    assert edited_order.modified_by != order.modified_by
    assert edited_order.modified_by == modifier
    assert edited_order.modified_on > order.modified_on

    # Make sure all non handled attributes is preserved from original order
    assert edited_order.creator == order.creator
    assert edited_order.ip_address == order.ip_address
    assert edited_order.orderer == order.orderer
    assert edited_order.customer_comment == order.customer_comment
    assert edited_order.marketing_permission == order.marketing_permission
    assert edited_order.order_date == order.order_date
    assert edited_order.status == order.status
    assert edited_order.payment_data == order.payment_data
    assert edited_order.shipping_data == order.shipping_data
    assert edited_order.extra_data == order.extra_data
开发者ID:00WhengWheng,项目名称:shuup,代码行数:50,代码来源:test_order_creator.py


示例8: test_known_extra_data

def test_known_extra_data():
    order = create_empty_order()
    order.shipping_data = {"instruction": "Hello"}
    order.payment_data = {"ssn": "101010-010X"}
    order.extra_data = {"wrapping_color": "blue"}
    order.save()
    with override_settings(
        SHOOP_ORDER_KNOWN_SHIPPING_DATA_KEYS=[("instruction", "Instruction")],
        SHOOP_ORDER_KNOWN_PAYMENT_DATA_KEYS=[("ssn", "Social Security Number")],
        SHOOP_ORDER_KNOWN_EXTRA_DATA_KEYS=[("wrapping_color", "Wrapping Color")],
    ):
        known_data = dict(order.get_known_additional_data())
        assert ("Instruction" in known_data)
        assert ("Social Security Number" in known_data)
        assert ("Wrapping Color" in known_data)
开发者ID:Jeewes,项目名称:shoop,代码行数:15,代码来源:test_orders.py


示例9: test_line_discount

def test_line_discount():
    order = create_empty_order(prices_include_tax=False)
    order.save()
    currency = order.shop.currency
    ol = OrderLine(order=order, type=OrderLineType.OTHER, quantity=5, text="Thing")
    ol.discount_amount = order.shop.create_price(50)
    ol.base_unit_price = order.shop.create_price(40)
    ol.save()
    ol.taxes.add(OrderLineTax.from_tax(get_default_tax(), ol.taxless_price.amount, order_line=ol))
    assert ol.taxless_discount_amount == order.shop.create_price(50)
    assert ol.taxful_discount_amount == TaxfulPrice(75, currency)
    assert ol.taxless_price == order.shop.create_price(150)
    assert ol.taxful_price == TaxfulPrice(150 + 75, currency)
    assert ol.taxless_base_unit_price == order.shop.create_price(40)
    assert ol.taxful_base_unit_price == TaxfulPrice(60, currency)
    assert "Thing" in six.text_type(ol)
开发者ID:taedori81,项目名称:shoop,代码行数:16,代码来源:test_orders.py


示例10: _get_order

def _get_order(shop, supplier):
    order = create_empty_order(shop=shop)
    order.full_clean()
    order.save()
    for product_data in _get_product_data():
        quantity = product_data.pop("quantity")
        product = create_product(
            sku=product_data.pop("sku"),
            shop=shop,
            supplier=supplier,
            default_price=3.33,
            **product_data)
        add_product_to_order(order, supplier, product, quantity=quantity, taxless_base_unit_price=1)
    order.cache_prices()
    order.check_all_verified()
    order.save()
    return order
开发者ID:00WhengWheng,项目名称:shuup,代码行数:17,代码来源:test_shipment_weights.py


示例11: test_delete_toolbar_button

def test_delete_toolbar_button(rf, admin_user, view_cls, get_method, method_attr):
    method = get_method()
    assert method.can_delete()
    view = view_cls.as_view()
    request = apply_request_middleware(rf.get("/"), user=admin_user)
    check_for_delete(view, request, method)

    # Create order for method and test the can_delete and edit view
    order = create_empty_order()
    setattr(order, method_attr, method)
    order.save()
    assert not method.can_delete()
    check_for_delete(view, request, method)

    # Make sure that the actual delete is also blocked
    with pytest.raises(ProtectedError):
        method.delete()
开发者ID:MIKNOTAURO,项目名称:shoop,代码行数:17,代码来源:test_services.py


示例12: test_service_methods_with_long_name

def test_service_methods_with_long_name(rf):
    """
    Make sure that service methods with long names (up to the max length of
    shipping or payment method names) don't cause exceptions when creating
    an order.
    """
    MAX_LENGTH = 100
    long_name = "X" * MAX_LENGTH
    assert len(long_name) == MAX_LENGTH
    sm = ShippingMethod.objects.language("en").create(
        shop=get_default_shop(), name=long_name, enabled=True, tax_class=get_default_tax_class())
    pm = PaymentMethod.objects.language("en").create(
        shop=get_default_shop(), name=long_name, enabled=True, tax_class=get_default_tax_class())
    order = create_empty_order()
    order.shipping_method = sm
    order.payment_method = pm
    order.full_clean()
    order.save()
开发者ID:00WhengWheng,项目名称:shuup,代码行数:18,代码来源:test_methods.py


示例13: test_line_discount_more

def test_line_discount_more():
    order = create_empty_order()
    order.save()
    ol = OrderLine(order=order, type=OrderLineType.OTHER)
    ol.quantity = 5
    ol.unit_price = TaxlessPrice(30)
    ol.total_discount = TaxlessPrice(50)
    ol.save()
    assert ol.taxless_unit_price == TaxlessPrice(30)
    assert ol.taxless_total_discount == TaxlessPrice(50)
    assert ol.taxless_total_price == TaxlessPrice(5 * 30 - 50)
    ol.taxes.add(OrderLineTax.from_tax(get_default_tax(), ol.taxless_total_price))
    assert ol.taxless_total_discount == TaxlessPrice(50)
    assert ol.taxful_total_discount == TaxfulPrice(75)
    assert ol.taxless_total_price == TaxlessPrice(100)
    assert ol.taxful_total_price == TaxfulPrice(150)
    assert ol.taxless_unit_price == TaxlessPrice(30)
    assert ol.taxful_unit_price == TaxfulPrice(45)
开发者ID:charn,项目名称:shoop,代码行数:18,代码来源:test_orders.py


示例14: test_line_discount_more

def test_line_discount_more():
    order = create_empty_order()
    order.save()
    ol = OrderLine(order=order, type=OrderLineType.OTHER)
    ol.quantity = 5
    ol.base_unit_price = order.shop.create_price(30)
    ol.discount_amount = order.shop.create_price(50)
    ol.save()
    currency = order.shop.currency
    assert ol.taxless_base_unit_price == TaxlessPrice(30, currency)
    assert ol.taxless_discount_amount == TaxlessPrice(50, currency)
    assert ol.taxless_price == TaxlessPrice(5 * 30 - 50, currency)
    ol.taxes.add(OrderLineTax.from_tax(get_default_tax(), ol.taxless_price.amount, order_line=ol))
    assert ol.taxless_discount_amount == TaxlessPrice(50, currency)
    assert ol.taxful_discount_amount == TaxfulPrice(75, currency)
    assert ol.taxless_price == TaxlessPrice(100, currency)
    assert ol.taxful_price == TaxfulPrice(150, currency)
    assert ol.taxless_base_unit_price == TaxlessPrice(30, currency)
    assert ol.taxful_base_unit_price == TaxfulPrice(45, currency)
开发者ID:taedori81,项目名称:shoop,代码行数:19,代码来源:test_orders.py


示例15: test_line_discount

def test_line_discount():
    order = create_empty_order()
    order.save()
    ol = OrderLine(
        order=order,
        type=OrderLineType.OTHER,
        quantity=5,
        text="Thing"
    )
    ol.total_discount = TaxlessPrice(50)
    ol.unit_price = TaxlessPrice(40)
    ol.save()
    ol.taxes.add(OrderLineTax.from_tax(get_default_tax(), ol.taxless_total_price))
    assert ol.taxless_total_discount == TaxlessPrice(50)
    assert ol.taxful_total_discount == TaxfulPrice(75)
    assert ol.taxless_total_price == TaxlessPrice(150)
    assert ol.taxful_total_price == TaxfulPrice(150 + 75)
    assert ol.taxless_unit_price == TaxlessPrice(40)
    assert ol.taxful_unit_price == TaxfulPrice(60)
    assert "Thing" in six.text_type(ol)
开发者ID:charn,项目名称:shoop,代码行数:20,代码来源:test_orders.py


示例16: test_anon_disabling

def test_anon_disabling():
    with override_settings(SHOOP_ALLOW_ANONYMOUS_ORDERS=False):
        with pytest.raises(ValidationError):
            order = create_empty_order()
            order.save()
开发者ID:Jeewes,项目名称:shoop,代码行数:5,代码来源:test_orders.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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