本文整理汇总了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
示例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
示例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))