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


Python utils.assert_contains函数代码示例

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


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

示例1: test_order_creator_view_for_customer

def test_order_creator_view_for_customer(rf, admin_user):
    get_default_shop()
    contact = create_random_person(locale="en_US", minimum_name_comp_len=5)
    request = apply_request_middleware(rf.get("/", {"contact_id": contact.id}), user=admin_user)
    response = OrderEditView.as_view()(request)
    assert_contains(response, "customerData")  # in the config
    assert_contains(response, "isCompany")  # in the config
开发者ID:NamiStudio,项目名称:shuup,代码行数:7,代码来源:test_order_creator.py

示例2: test_campaign_with_non_active_coupon

def test_campaign_with_non_active_coupon(rf):
    initial_status = get_initial_order_status()
    request, shop, group = initialize_test(rf, include_tax=False)
    order = _get_order_with_coupon(request, initial_status)
    coupon = order.coupon_usages.first().coupon
    coupon.active = False
    coupon.save()

    modifier = UserFactory()
    contact = create_random_person(locale="en_US", minimum_name_comp_len=5)
    assert order.customer != contact
    state = _get_frontend_order_state(shop, contact)
    assert order.shop.id == state["shop"]["selected"]["id"]

    request = get_frontend_request_for_command(state, "finalize", modifier)
    response = OrderEditView.as_view()(request, pk=order.pk)
    assert_contains(response, "orderIdentifier")
    data = json.loads(response.content.decode("utf8"))
    edited_order = Order.objects.get(pk=order.pk)

    assert edited_order.identifier == data["orderIdentifier"] == order.identifier
    assert edited_order.pk == order.pk
    assert edited_order.lines.count() == 3
    assert OrderLineType.DISCOUNT not in [l.type for l in edited_order.lines.all()]
    assert edited_order.coupon_usages.count() == 0
开发者ID:gurch101,项目名称:shuup,代码行数:25,代码来源:test_order_edit_with_coupons.py

示例3: test_order_creator_customer_data

def test_order_creator_customer_data(rf, admin_user):
    get_default_shop()
    contact = create_random_person(locale="en_US", minimum_name_comp_len=5)
    request = apply_request_middleware(rf.get("/", {"command": "customer_data", "id": contact.id}), user=admin_user)
    response = OrderEditView.as_view()(request)
    assert_contains(response, "name")
    assert_contains(response, contact.name)
开发者ID:suutari,项目名称:shoop,代码行数:7,代码来源:test_order_creator.py

示例4: test_order_creator_invalid_base_data

def test_order_creator_invalid_base_data(rf, admin_user):
    get_initial_order_status()  # Needed for the API
    state = get_frontend_order_state(contact=None)
    # Remove some critical data...
    state["customer"]["id"] = None
    state["shop"]["selected"]["id"] = None
    request = get_frontend_request_for_command(state, "finalize", admin_user)
    response =OrderEditView.as_view()(request)
    assert_contains(response, "errorMessage", status_code=400)
开发者ID:NamiStudio,项目名称:shuup,代码行数:9,代码来源:test_order_creator.py

示例5: 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:NamiStudio,项目名称:shuup,代码行数:50,代码来源:test_order_creator.py

示例6: test_order_creator_invalid_line_data

def test_order_creator_invalid_line_data(rf, admin_user):
    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, valid_lines=False)
    request = get_frontend_request_for_command(state, "finalize", admin_user)
    response = OrderEditView.as_view()(request)
    # Let's see that we get a cornucopia of trouble:
    assert_contains(response, "does not exist", status_code=400)
    assert_contains(response, "does not have a product", status_code=400)
    assert_contains(response, "The price", status_code=400)
    assert_contains(response, "The quantity", status_code=400)
开发者ID:NamiStudio,项目名称:shuup,代码行数:11,代码来源:test_order_creator.py

示例7: test_order_creator_addresses

def test_order_creator_addresses(rf, admin_user):
    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)

    # company with no tax number
    state["customer"]["isCompany"] = True
    request = get_frontend_request_for_command(state, "finalize", admin_user)
    response =OrderEditView.as_view()(request)
    assert_contains(response, "Tax number is not set", status_code=400)

    # company with tax number, should work
    state["customer"]["billingAddress"]["tax_number"] = "123"
    state["customer"]["shippingAddress"]["tax_number"] = "123"
    order = get_order_from_state(state, admin_user)
    assert order.lines.count() == 5

    # person with no shipping address
    state["customer"]["isCompany"] = False
    state["customer"]["shippingAddress"] = {}
    request = get_frontend_request_for_command(state, "finalize", admin_user)
    response =OrderEditView.as_view()(request)
    assert_contains(response, "This field is required", status_code=400)

    # ship to billing, should work now
    state["customer"]["shipToBillingAddress"] = True
    order = get_order_from_state(state, admin_user)
    assert order.lines.count() == 5

    # change name and make sure contact address is NOT updated
    original_name = contact.default_billing_address.name
    state["customer"]["billingAddress"]["name"] = "foobar"
    state["customer"]["saveAddress"] = False
    order = get_order_from_state(state, admin_user)
    contact.refresh_from_db()
    assert contact.default_billing_address.name == original_name

    # change name with saveAddress set, contact address should update
    original_name = contact.default_billing_address.name
    state["customer"]["billingAddress"]["name"] = "foobar"
    state["customer"]["saveAddress"] = True
    order = get_order_from_state(state, admin_user)
    contact.refresh_from_db()
    assert contact.default_billing_address.name == "foobar"
开发者ID:NamiStudio,项目名称:shuup,代码行数:44,代码来源:test_order_creator.py

示例8: test_order_creator_product_data

def test_order_creator_product_data(rf, admin_user):
    shop = get_default_shop()
    product = create_product(sku=printable_gibberish(), supplier=get_default_supplier(), shop=shop)
    request = apply_request_middleware(rf.get("/", {
        "command": "product_data",
        "shop_id": shop.id,
        "id": product.id,
        "quantity": 42
    }), user=admin_user)
    response =OrderEditView.as_view()(request)
    assert_contains(response, "taxClass")
    assert_contains(response, "sku")
    assert_contains(response, product.sku)
    assert_contains(response, "logicalCount")
    assert_contains(response, "physicalCount")
    assert_contains(response, "salesDecimals")
    assert_contains(response, "salesUnit")
开发者ID:NamiStudio,项目名称:shuup,代码行数:17,代码来源:test_order_creator.py

示例9: test_order_creator_view_invalid_command

def test_order_creator_view_invalid_command(rf, admin_user):
    get_default_shop()
    request = apply_request_middleware(rf.get("/", {"command": printable_gibberish()}), user=admin_user)
    response = OrderEditView.as_view()(request)
    assert_contains(response, "unknown command", status_code=400)
开发者ID:NamiStudio,项目名称:shuup,代码行数:5,代码来源:test_order_creator.py

示例10: test_order_creator_view_GET

def test_order_creator_view_GET(rf, admin_user):
    get_default_shop()
    request = apply_request_middleware(rf.get("/"), user=admin_user)
    response =OrderEditView.as_view()(request)
    assert_contains(response, "shippingMethods")  # in the config
    assert_contains(response, "shops")  # in the config
开发者ID:NamiStudio,项目名称:shuup,代码行数:6,代码来源:test_order_creator.py

示例11: get_order_from_state

def get_order_from_state(state, admin_user):
    request = get_frontend_request_for_command(state, "finalize", admin_user)
    response = OrderEditView.as_view()(request)
    assert_contains(response, "orderIdentifier")  # this checks for status codes as a side effect
    data = json.loads(response.content.decode("utf8"))
    return Order.objects.get(identifier=data["orderIdentifier"])
开发者ID:NamiStudio,项目名称:shuup,代码行数:6,代码来源:test_order_creator.py


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