本文整理汇总了Python中shuup_tests.utils.basketish_order_source.BasketishOrderSource.get_validation_errors方法的典型用法代码示例。如果您正苦于以下问题:Python BasketishOrderSource.get_validation_errors方法的具体用法?Python BasketishOrderSource.get_validation_errors怎么用?Python BasketishOrderSource.get_validation_errors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shuup_tests.utils.basketish_order_source.BasketishOrderSource
的用法示例。
在下文中一共展示了BasketishOrderSource.get_validation_errors方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_methods_impossible
# 需要导入模块: from shuup_tests.utils.basketish_order_source import BasketishOrderSource [as 别名]
# 或者: from shuup_tests.utils.basketish_order_source.BasketishOrderSource import get_validation_errors [as 别名]
def test_methods_impossible(admin_user):
contact = get_person_contact(admin_user)
source = BasketishOrderSource(get_default_shop())
default_product = get_default_product()
default_product.width = 5000
default_product.depth = 4000
default_product.heith = 1300
default_product.save()
source.add_line(
type=OrderLineType.PRODUCT,
product=default_product,
supplier=get_default_supplier(),
quantity=1,
base_unit_price=source.create_price(10),
weight=Decimal("200"))
billing_address = get_address()
shipping_address = get_address(name="My House", country='BR')
shipping_address.postal_code = "89070210"
source.billing_address = billing_address
source.shipping_address = shipping_address
source.customer = contact
source.shipping_method = get_correios_carrier_1()
source.payment_method = get_payment_method(name="neat", price=4)
assert source.shipping_method_id
assert source.payment_method_id
errors = list(source.get_validation_errors())
assert len(errors) == 1
示例2: test_methods
# 需要导入模块: from shuup_tests.utils.basketish_order_source import BasketishOrderSource [as 别名]
# 或者: from shuup_tests.utils.basketish_order_source.BasketishOrderSource import get_validation_errors [as 别名]
def test_methods(admin_user, country):
contact = get_person_contact(admin_user)
source = BasketishOrderSource(get_default_shop())
source.add_line(
type=OrderLineType.PRODUCT,
product=get_default_product(),
supplier=get_default_supplier(),
quantity=1,
base_unit_price=source.create_price(10),
weight=Decimal("0.2")
)
billing_address = get_address()
shipping_address = get_address(name="Shippy Doge", country=country)
source.billing_address = billing_address
source.shipping_address = shipping_address
source.customer = contact
source.shipping_method = get_expensive_sweden_shipping_method()
source.payment_method = get_payment_method(name="neat", price=4)
assert source.shipping_method_id
assert source.payment_method_id
errors = list(source.get_validation_errors())
if country == "FI":
# "Expenseefe-a Svedee Sheepping" will not allow shipping to
# Finland, let's see if that holds true
assert any([ve.code == "we_no_speak_finnish" for ve in errors])
assert [x.code for x in errors] == ["we_no_speak_finnish"]
return # Shouldn't try the rest if we got an error here
else:
assert not errors
final_lines = list(source.get_final_lines())
assert any(line.type == OrderLineType.SHIPPING for line in final_lines)
for line in final_lines:
if line.type == OrderLineType.SHIPPING:
if country == "SE": # We _are_ using Expenseefe-a Svedee Sheepping after all.
assert line.price == source.create_price("5.00")
else:
assert line.price == source.create_price("4.00")
assert line.text == u"Expenseefe-a Svedee Sheepping"
if line.type == OrderLineType.PAYMENT:
assert line.price == source.create_price(4)
示例3: test_methods_possible_no_shipping_address
# 需要导入模块: from shuup_tests.utils.basketish_order_source import BasketishOrderSource [as 别名]
# 或者: from shuup_tests.utils.basketish_order_source.BasketishOrderSource import get_validation_errors [as 别名]
def test_methods_possible_no_shipping_address(admin_user):
with patch.object(CorreiosWS, 'get_preco_prazo', return_value=MOCKED_SUCCESS_RESULT):
contact = get_person_contact(admin_user)
source = BasketishOrderSource(get_default_shop())
default_product = get_default_product()
default_product.width = 500
default_product.depth = 400
default_product.heith = 130
default_product.save()
source.add_line(
type=OrderLineType.PRODUCT,
product=default_product,
supplier=get_default_supplier(),
quantity=1,
base_unit_price=source.create_price(10),
weight=Decimal("0.2"))
billing_address = get_address(name="My House", country='BR')
billing_address.postal_code = "89070210"
source.billing_address = billing_address
source.shipping_address = None
source.customer = contact
source.shipping_method = get_correios_carrier_1()
source.payment_method = get_payment_method(name="neat", price=4)
assert source.shipping_method_id
assert source.payment_method_id
errors = list(source.get_validation_errors())
# no errors
assert len(errors) == 0
final_lines = list(source.get_final_lines())
assert any(line.type == OrderLineType.SHIPPING for line in final_lines)
for line in final_lines:
if line.type == OrderLineType.SHIPPING:
assert line.text == "Correios - PAC #1"
# no billing addres also - no shipping
source.billing_address = None
list(source.get_final_lines())