• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python factories.get_initial_order_status函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_company_contact_creation

def test_company_contact_creation(rf, admin_user):
    get_initial_order_status()
    contact = create_random_company()
    test_tax_number = "1234567-1"
    contact.tax_number = test_tax_number
    contact.save()
    contact.default_billing_address.tax_number = test_tax_number
    contact.default_billing_address.save()
    state = get_frontend_order_state(contact=contact)
    state["customer"] = {
        "id": None,
        "name": None,
        "billingAddress": encode_address(contact.default_billing_address),
        "shipToBillingAddress": True,
        "saveAddress": True,
        "isCompany": True
    }
    order = get_order_from_state(state, admin_user)
    assert order.lines.count() == 5
    assert order.customer.id != contact.id
    assert order.customer.name == contact.name
    assert order.customer.tax_number == test_tax_number
    assert order.billing_address.tax_number == contact.default_billing_address.tax_number
    assert order.billing_address.street == contact.default_billing_address.street
    assert order.billing_address.street == order.shipping_address.street
开发者ID:NamiStudio,项目名称:shuup,代码行数:25,代码来源:test_order_creator.py


示例2: test_order_creator_source_data

def test_order_creator_source_data(rf, admin_user):
    get_initial_order_status()  # Needed for the API
    contact = create_random_person(locale="en_US", minimum_name_comp_len=5)
    request = get_frontend_request_for_command(get_frontend_order_state(contact), "source_data", admin_user)
    response =OrderEditView.as_view()(request)
    data = json.loads(response.content.decode("utf8"))
    assert len(data.get("orderLines")) == 5
开发者ID:NamiStudio,项目名称:shuup,代码行数:7,代码来源:test_order_creator.py


示例3: 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


示例4: 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


示例5: test_order_received_admin

def test_order_received_admin(rf, admin_user):
    get_test_script("test script", "order_received")
    template_data = STEP_DATA[0]["actions"][0]["template_data"]
    for lang in ["en", "fi"]:
        get_initial_order_status()  # Needed for the API
        n_outbox_pre = len(mail.outbox)
        contact = create_random_person(locale=lang, minimum_name_comp_len=5)
        get_order_from_state(get_frontend_order_state(contact), admin_user)
        assert (len(mail.outbox) == n_outbox_pre + 1), "Sending email failed"
        latest_mail = mail.outbox[-1]
        assert latest_mail.subject == template_data[lang]["subject"], "Subject doesn't match"
        assert latest_mail.body == template_data[lang]["body"], "Body doesn't match"
开发者ID:ruqaiya,项目名称:shuup,代码行数:12,代码来源:test_order_notifications.py


示例6: test_order_creator_valid

def test_order_creator_valid(rf, admin_user):
    get_initial_order_status()  # Needed for the API
    contact = create_random_person(locale="en_US", minimum_name_comp_len=5)
    order = get_order_from_state(get_frontend_order_state(contact), admin_user)
    assert order.lines.count() == 5  # 3 submitted, two for the shipping and payment method
    assert order.creator == admin_user
    assert order.customer == contact

    # Check that product line have right taxes
    for line in 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
开发者ID:andela-kerinoso,项目名称:shuup,代码行数:13,代码来源:test_order_creator.py


示例7: 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


示例8: 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


示例9: seed_source

def seed_source(user, shop):
    source = BasketishOrderSource(shop)
    source.status = get_initial_order_status()
    source.customer = get_person_contact(user)
    source.payment_method = get_default_payment_method()
    source.shipping_method = get_default_shipping_method()
    return source
开发者ID:gurch101,项目名称:shuup,代码行数:7,代码来源:test_order_source.py


示例10: create_simple_order

def create_simple_order(request, creator, customer):
    billing_address = get_address().to_immutable()
    shipping_address = get_address(name="Shippy Doge").to_immutable()
    shipping_address.save()
    shop = request.shop
    order = Order(
        creator=creator,
        customer=customer,
        shop=shop,
        payment_method=get_default_payment_method(),
        shipping_method=get_default_shipping_method(),
        billing_address=billing_address,
        shipping_address=shipping_address,
        order_date=now(),
        status=get_initial_order_status(),
        currency=shop.currency,
        prices_include_tax=shop.prices_include_tax,
    )
    order.full_clean()
    order.save()

    order.cache_prices()
    order.check_all_verified()
    order.save()
    return order
开发者ID:ruqaiya,项目名称:shuup,代码行数:25,代码来源:test_basic_order.py


示例11: get_order_and_source

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,代码行数:27,代码来源:test_order_modifier.py


示例12: test_order_creator_view

def test_order_creator_view(browser, admin_user, live_server):
    shop = get_default_shop()
    pm = get_default_payment_method()
    sm = get_default_shipping_method()
    get_initial_order_status()
    supplier = get_default_supplier()
    person = create_random_person()
    product0 = create_product("test-sku0", shop=shop, default_price=10, supplier=supplier)
    product1 = create_product("test-sku1", shop=shop, default_price=10, supplier=supplier)

    initialize_admin_browser_test(browser, live_server)
    _visit_order_creator_view(browser, live_server)
    _test_customer_data(browser, person)
    _test_add_lines(browser)
    _test_quick_add_lines(browser)
    _test_methods(browser)
    _test_confirm(browser)
开发者ID:yourkin,项目名称:shuup,代码行数:17,代码来源:test_order_creator.py


示例13: _seed_source

def _seed_source(shop, user):
    source = BasketishOrderSource(shop)
    billing_address = get_address()
    shipping_address = get_address(name="Test street")
    source.status = get_initial_order_status()
    source.billing_address = billing_address
    source.shipping_address = shipping_address
    source.customer = get_person_contact(user)
    return source
开发者ID:gurch101,项目名称:shuup,代码行数:9,代码来源:test_order_total_behavior_component.py


示例14: 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


示例15: test_person_contact_creation

def test_person_contact_creation(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)
    state["customer"] = {
        "id": None,
        "name": None,
        "billingAddress": encode_address(contact.default_billing_address),
        "shipToBillingAddress": True,
        "saveAddress": True,
        "isCompany": False
    }
    order = get_order_from_state(state, admin_user)
    assert order.lines.count() == 5
    assert order.customer.id != contact.id
    assert order.customer.name == contact.name
    assert order.billing_address.name == contact.default_billing_address.name
    assert order.billing_address.street == contact.default_billing_address.street
    assert order.billing_address.street == order.shipping_address.street
开发者ID:NamiStudio,项目名称:shuup,代码行数:19,代码来源:test_order_creator.py


示例16: _init_test_for_product_with_basket

def _init_test_for_product_with_basket(rf, default_price):
    request, product = _init_test_for_product_without_basket(rf, default_price)
    shop = factories.get_default_shop()
    supplier = factories.get_default_supplier()
    basket = get_basket(request)
    basket.status = factories.get_initial_order_status()
    basket.add_product(supplier=supplier, shop=shop, product=product, quantity=1)
    basket.shipping_method = factories.get_shipping_method(shop=shop)
    basket.payment_method = factories.get_payment_method(shop=shop)
    assert basket.shop == request.shop
    assert basket.customer == request.customer
    return request, product, basket
开发者ID:ruqaiya,项目名称:shuup,代码行数:12,代码来源:test_coupon_codes.py


示例17: test_admin_cash_order

def test_admin_cash_order(rf, admin_user, price, target, mode):
    activate("en")
    get_initial_order_status()  # Needed for the API
    shop = get_default_shop()
    contact = create_random_person(locale="en_US", minimum_name_comp_len=5)

    processor = CustomPaymentProcessor.objects.create(rounding_mode=mode)
    cash_method = PaymentMethod.objects.create(
        shop=shop,
        payment_processor=processor,
        choice_identifier="cash",
        tax_class=get_default_tax_class(), name="Cash")


    state = get_frontend_order_state(contact, cash_method, price)
    order = get_order_from_state(state, admin_user)
    assert order.payment_method == cash_method
    assert order.lines.count() == 5  # 2 submitted, two for the shipping and payment method, and a rounding line
    assert order.creator == admin_user
    assert order.customer == contact
    assert order.taxful_total_price == shop.create_price(target)
开发者ID:ruqaiya,项目名称:shuup,代码行数:21,代码来源:test_admin_orders.py


示例18: seed_source

def seed_source(user):
    source = BasketishOrderSource(get_default_shop())
    billing_address = get_address()
    shipping_address = get_address(name="Shippy Doge")
    source.status = get_initial_order_status()
    source.billing_address = billing_address
    source.shipping_address = shipping_address
    source.customer = get_person_contact(user)
    source.payment_method = get_default_payment_method()
    source.shipping_method = get_default_shipping_method()
    assert source.payment_method_id == get_default_payment_method().id
    assert source.shipping_method_id == get_default_shipping_method().id
    return source
开发者ID:suutari,项目名称:shoop,代码行数:13,代码来源:test_order_creator.py


示例19: test_order_creator_view

def test_order_creator_view(browser, admin_user, live_server, settings):
    shop = get_default_shop()
    pm = get_default_payment_method()
    sm = get_default_shipping_method()
    get_initial_order_status()
    supplier = get_default_supplier()
    person = create_random_person()
    product0 = create_product("test-sku0", shop=shop, default_price=10, supplier=supplier)
    product1 = create_product("test-sku1", shop=shop, default_price=10, supplier=supplier)
    object_created.connect(_add_custom_order_created_message, sender=Order, dispatch_uid="object_created_signal_test")
    initialize_admin_browser_test(browser, live_server, settings)
    browser.driver.maximize_window()
    _visit_order_creator_view(browser, live_server)
    _test_language_change(browser)
    _test_customer_data(browser, person)
    _test_regions(browser, person)
    _test_add_lines(browser)
    _test_quick_add_lines(browser)
    _test_methods(browser)
    _test_confirm(browser)
    assert Order.objects.first().log_entries.filter(identifier=OBJECT_CREATED_LOG_IDENTIFIER).count() == 1
    object_created.disconnect(sender=Order, dispatch_uid="object_created_signal_test")
开发者ID:suutari,项目名称:shoop,代码行数:22,代码来源:test_order_creator.py


示例20: test_order_address_immutability_unsaved_address

def test_order_address_immutability_unsaved_address(save):
    billing_address = get_address()
    if save:
        billing_address.save()
    order = Order(
        shop=get_default_shop(),
        billing_address=billing_address.to_immutable(),
        order_date=now(),
        status=get_initial_order_status()
    )
    order.save()
    order.billing_address.name = "Mute Doge"
    with pytest.raises(ValidationError):
        order.billing_address.save()
开发者ID:ruqaiya,项目名称:shuup,代码行数:14,代码来源:test_orders.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python factories.get_shipping_method函数代码示例发布时间:2022-05-27
下一篇:
Python factories.get_default_tax_class函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap