本文整理汇总了Python中shuup_tests.utils.basketish_order_source.BasketishOrderSource.creator方法的典型用法代码示例。如果您正苦于以下问题:Python BasketishOrderSource.creator方法的具体用法?Python BasketishOrderSource.creator怎么用?Python BasketishOrderSource.creator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shuup_tests.utils.basketish_order_source.BasketishOrderSource
的用法示例。
在下文中一共展示了BasketishOrderSource.creator方法的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 creator [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: test_staff_only_behavior
# 需要导入模块: from shuup_tests.utils.basketish_order_source import BasketishOrderSource [as 别名]
# 或者: from shuup_tests.utils.basketish_order_source.BasketishOrderSource import creator [as 别名]
def test_staff_only_behavior(admin_user, regular_user):
payment_method = get_default_payment_method()
component = StaffOnlyBehaviorComponent.objects.create()
payment_method.behavior_components.add(component)
source = BasketishOrderSource(get_default_shop())
# anonymous user
unavailability_reasons = list(payment_method.get_unavailability_reasons(source))
assert len(unavailability_reasons) == 1
# regular user
source.creator = regular_user
unavailability_reasons = list(payment_method.get_unavailability_reasons(source))
assert len(unavailability_reasons) == 1
# admin
source.creator = admin_user
unavailability_reasons = list(payment_method.get_unavailability_reasons(source))
assert len(unavailability_reasons) == 0
示例3: get_order_and_source
# 需要导入模块: from shuup_tests.utils.basketish_order_source import BasketishOrderSource [as 别名]
# 或者: from shuup_tests.utils.basketish_order_source.BasketishOrderSource import creator [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