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


Python BasketishOrderSource.get_lines方法代码示例

本文整理汇总了Python中shuup_tests.utils.basketish_order_source.BasketishOrderSource.get_lines方法的典型用法代码示例。如果您正苦于以下问题:Python BasketishOrderSource.get_lines方法的具体用法?Python BasketishOrderSource.get_lines怎么用?Python BasketishOrderSource.get_lines使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在shuup_tests.utils.basketish_order_source.BasketishOrderSource的用法示例。


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

示例1: get_order_and_source

# 需要导入模块: from shuup_tests.utils.basketish_order_source import BasketishOrderSource [as 别名]
# 或者: from shuup_tests.utils.basketish_order_source.BasketishOrderSource import get_lines [as 别名]
def get_order_and_source(admin_user, product):
    # 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=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:NamiStudio,项目名称:shuup,代码行数:29,代码来源:test_order_modifier.py

示例2: get_order_and_source

# 需要导入模块: from shuup_tests.utils.basketish_order_source import BasketishOrderSource [as 别名]
# 或者: from shuup_tests.utils.basketish_order_source.BasketishOrderSource import get_lines [as 别名]
def get_order_and_source(admin_user, product, language, language_fallback):
    # create original source to tamper with

    contact = get_person_contact(admin_user)
    contact.language = language
    contact.save()

    assert contact.language == language  # contact language is naive

    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 = contact
    source.payment_method = get_default_payment_method()
    source.shipping_method = get_default_shipping_method()
    source.add_line(
        type=OrderLineType.PRODUCT,
        product=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

    assert not source._language  # is None because it was not directly assigned
    assert source.language == language_fallback

    creator = OrderCreator()
    order = creator.create_order(source)

    assert order.language == source.language

    return order, source
开发者ID:ruqaiya,项目名称:shuup,代码行数:43,代码来源:test_order_languages.py

示例3: test_order_source_rounding

# 需要导入模块: from shuup_tests.utils.basketish_order_source import BasketishOrderSource [as 别名]
# 或者: from shuup_tests.utils.basketish_order_source.BasketishOrderSource import get_lines [as 别名]
def test_order_source_rounding(prices):
    shop = Shop.objects.create(
        name="test",
        identifier="test",
        status=ShopStatus.ENABLED,
        public_name="test",
        prices_include_tax=False
    )
    expected = 0
    for p in prices:
        expected += bankers_round(p, 2)

    source = BasketishOrderSource(shop)
    for x, price in enumerate(prices):
        source.add_line(
            type=OrderLineType.OTHER,
            quantity=1,
            text=x,
            base_unit_price=source.create_price(price),
            ordering=x,
        )

    for x, order_source in enumerate(source.get_lines()):
        price = Decimal(prices[x]).quantize(Decimal(".1") ** 9)

        # make sure prices are in database with original precision
        assert order_source.base_unit_price == source.shop.create_price(price)

        # make sure the line taxless price is rounded
        assert order_source.taxless_price == source.shop.create_price(bankers_round(price, 2))

        # Check that total prices calculated from priceful parts still matches
        assert _get_taxless_price(order_source) == order_source.taxless_price
        assert _get_taxful_price(order_source) == order_source.taxful_price

        # make sure the line price is rounded
        assert order_source.price == source.shop.create_price(price)

    # make sure order total is rounded
    assert source.taxless_total_price == source.shop.create_price(bankers_round(expected, 2))
开发者ID:ruqaiya,项目名称:shuup,代码行数:42,代码来源:test_rounding.py


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