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

Python basketish_order_source.BasketishOrderSource类代码示例

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

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



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

示例1: test_weight_limits

def test_weight_limits():
    sm = ShippingMethod(tax_class=get_default_tax_class())
    sm.module_data = {"min_weight": "100", "max_weight": "500"}
    source = BasketishOrderSource(get_default_shop())
    assert any(ve.code == "min_weight" for ve in sm.get_validation_errors(source))
    source.add_line(type=OrderLineType.PRODUCT, weight=600)
    assert any(ve.code == "max_weight" for ve in sm.get_validation_errors(source))
开发者ID:taedori81,项目名称:shoop,代码行数:7,代码来源:test_methods.py


示例2: test_source_lines_with_multiple_fixed_costs

def test_source_lines_with_multiple_fixed_costs():
    """
    Costs with description creates new line always and costs without
    description is combined into one line.
    """
    translation.activate("en")
    starting_price_value = 5
    sm = get_shipping_method(name="Multiple costs", price=starting_price_value)
    sm.behavior_components.clear()

    source = BasketishOrderSource(get_default_shop())
    source.shipping_method = sm

    lines = list(sm.get_lines(source))
    assert len(lines) == 1
    assert get_total_price_value(lines) == Decimal("0")

    sm.behavior_components.add(FixedCostBehaviorComponent.objects.create(price_value=10))
    lines = list(sm.get_lines(source))
    assert len(lines) == 1
    assert get_total_price_value(lines) == Decimal("10")

    sm.behavior_components.add(FixedCostBehaviorComponent.objects.create(price_value=15, description="extra"))
    lines = list(sm.get_lines(source))
    assert len(lines) == 2
    assert get_total_price_value(lines) == Decimal("25")

    sm.behavior_components.add(FixedCostBehaviorComponent.objects.create(price_value=1))
    lines = list(sm.get_lines(source))
    assert len(lines) == 2
    assert get_total_price_value(lines) == Decimal("26")
开发者ID:00WhengWheng,项目名称:shuup,代码行数:31,代码来源:test_methods.py


示例3: test_package

def test_package():
    shop = get_default_shop()
    supplier = get_default_supplier()
    package_product = create_product("PackageParent", shop=shop, supplier=supplier)
    assert not package_product.get_package_child_to_quantity_map()
    children = [create_product("PackageChild-%d" % x, shop=shop, supplier=supplier) for x in range(4)]
    package_def = {child: 1 + i for (i, child) in enumerate(children)}
    package_product.make_package(package_def)
    assert package_product.mode == ProductMode.PACKAGE_PARENT
    package_product.save()
    sp = package_product.get_shop_instance(shop)
    assert not list(sp.get_orderability_errors(supplier=supplier, quantity=1, customer=AnonymousContact()))

    with pytest.raises(ValueError):  # Test re-packaging fails
        package_product.make_package(package_def)

    # Check that OrderCreator can deal with packages

    source = BasketishOrderSource()
    source.lines.append(SourceLine(
        type=OrderLineType.PRODUCT,
        product=package_product,
        supplier=get_default_supplier(),
        quantity=10,
        unit_price=TaxlessPrice(10),
    ))

    source.shop = get_default_shop()
    source.status = get_initial_order_status()
    creator = OrderCreator(request=None)
    order = creator.create_order(source)
    pids_to_quantities = order.get_product_ids_and_quantities()
    for child, quantity in six.iteritems(package_def):
        assert pids_to_quantities[child.pk] == 10 * quantity
开发者ID:charn,项目名称:shoop,代码行数:34,代码来源:test_product_packages.py


示例4: 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:00WhengWheng,项目名称:shuup,代码行数:7,代码来源:test_order_source.py


示例5: test_tax

def test_tax():
    sm = ShippingMethod(tax_class=None, module_data={"price": 50})
    source = BasketishOrderSource(get_default_shop())
    # Since `tax_class` is None, the highest tax percentage in the order should be used:
    source.add_line(type=OrderLineType.PRODUCT, tax_rate=Decimal("0.8"))
    source.add_line(type=OrderLineType.PRODUCT, tax_rate=Decimal("0.3"))
    line = list(sm.get_source_lines(source))[0]
    assert line.tax_rate == Decimal("0.8")

    sm.tax_class = get_default_tax_group()
    line = list(sm.get_source_lines(source))[0]
    assert line.tax_rate == sm.tax_class.tax_rate
开发者ID:hitchhooker,项目名称:shoop,代码行数:12,代码来源:test_methods.py


示例6: test_weight_limits

def test_weight_limits():
    carrier = CustomCarrier.objects.create()
    sm = carrier.create_service(
        None, shop=get_default_shop(), enabled=True,
        tax_class=get_default_tax_class())
    sm.behavior_components.add(
        WeightLimitsBehaviorComponent.objects.create(
            min_weight=100, max_weight=500))
    source = BasketishOrderSource(get_default_shop())
    assert any(ve.code == "min_weight" for ve in sm.get_unavailability_reasons(source))
    source.add_line(type=OrderLineType.PRODUCT, weight=600)
    assert any(ve.code == "max_weight" for ve in sm.get_unavailability_reasons(source))
开发者ID:00WhengWheng,项目名称:shuup,代码行数:12,代码来源:test_methods.py


示例7: test_waiver

def test_waiver():
    sm = ShippingMethod(
        name="Waivey",
        tax_class=get_default_tax_class(),
        module_data={"price_waiver_product_minimum": "370", "price": "100"},
    )
    source = BasketishOrderSource()
    assert not source.prices_include_tax()
    assert sm.get_effective_name(source) == u"Waivey"
    assert sm.get_effective_price(source) == TaxlessPrice(100)
    source.lines = [
        SourceLine(type=OrderLineType.PRODUCT, product=get_default_product(), unit_price=TaxlessPrice(400), quantity=1)
    ]
    assert sm.get_effective_price(source) == TaxlessPrice(0)
开发者ID:kloudsio,项目名称:shoop,代码行数:14,代码来源:test_methods.py


示例8: test_methods

def test_methods(admin_user, country):
    contact = get_person_contact(admin_user)
    source = BasketishOrderSource(
        lines=[
            SourceLine(
                type=OrderLineType.PRODUCT,
                product=get_default_product(),
                supplier=get_default_supplier(),
                quantity=1,
                unit_price=TaxlessPrice(10),
                weight=Decimal("0.2"),
            )
        ]
    )
    billing_address = get_address()
    shipping_address = get_address(name="Shippy Doge", country=country)
    source.shop = get_default_shop()
    source.billing_address = billing_address
    source.shipping_address = shipping_address
    source.customer = contact

    with override_provides_for_expensive_sweden_shipping_method():
        source.shipping_method = get_expensive_sweden_shipping_method()
        source.payment_method = PaymentMethod.objects.create(
            identifier="neat", module_data={"price": 4}, tax_class=get_default_tax_class()
        )
        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])
            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)

        # TODO: (TAX) for some reason SourceLine.taxless_total_price property has been removed
        # I think it should be implemented back like in OrderLine / janne

        for line in final_lines:
            if line.type == OrderLineType.SHIPPING:
                if country == "SE":  # We _are_ using Expenseefe-a Svedee Sheepping after all.
                    assert line.taxless_total_price == TaxlessPrice("5.00")
                else:
                    assert line.taxless_total_price == TaxlessPrice("4.00")
                assert line.text == u"Expenseefe-a Svedee Sheepping"
            if line.type == OrderLineType.PAYMENT:
                assert line.taxless_total_price == TaxlessPrice("4")
开发者ID:kloudsio,项目名称:shoop,代码行数:55,代码来源:test_methods.py


示例9: get_order_source_with_a_package

def get_order_source_with_a_package():
    package_product = get_package_product()

    source = BasketishOrderSource(get_default_shop())
    source.add_line(
        type=OrderLineType.PRODUCT,
        product=package_product,
        supplier=get_default_supplier(),
        quantity=10,
        base_unit_price=source.create_price(10),
        sku=package_product.sku,
        text=package_product.name,
    )

    source.status = get_initial_order_status()
    return source
开发者ID:00WhengWheng,项目名称:shuup,代码行数:16,代码来源:test_product_packages.py


示例10: test_waiver

def test_waiver():
    sm = ShippingMethod(name="Waivey", tax_class=get_default_tax_class(),
                        module_data={
                            "price_waiver_product_minimum": "370",
                            "price": "100"
                        })
    source = BasketishOrderSource(get_default_shop())
    assert sm.get_effective_name(source) == u"Waivey"
    assert sm.get_effective_price_info(source).price == source.shop.create_price(100)
    source.add_line(
        type=OrderLineType.PRODUCT,
        product=get_default_product(),
        base_unit_price=source.shop.create_price(400),
        quantity=1
    )
    assert sm.get_effective_price_info(source).price == source.shop.create_price(0)
开发者ID:taedori81,项目名称:shoop,代码行数:16,代码来源:test_methods.py


示例11: test_translations_of_method_and_component

def test_translations_of_method_and_component():
    sm = get_shipping_method(name="Unique shipping")
    sm.set_current_language('en')
    sm.name = "Shipping"
    sm.set_current_language('fi')
    sm.name = "Toimitus"
    sm.save()

    cost = FixedCostBehaviorComponent.objects.language('fi').create(
        price_value=10, description="kymppi")
    cost.set_current_language('en')
    cost.description = "ten bucks"
    cost.save()
    sm.behavior_components.add(cost)

    source = BasketishOrderSource(get_default_shop())
    source.shipping_method = sm

    translation.activate('fi')
    shipping_lines = [
        line for line in source.get_final_lines()
        if line.type == OrderLineType.SHIPPING]
    assert len(shipping_lines) == 1
    assert shipping_lines[0].text == 'Toimitus: kymppi'

    translation.activate('en')
    source.uncache()
    shipping_lines = [
        line for line in source.get_final_lines()
        if line.type == OrderLineType.SHIPPING]
    assert len(shipping_lines) == 1
    assert shipping_lines[0].text == 'Shipping: ten bucks'
开发者ID:00WhengWheng,项目名称:shuup,代码行数:32,代码来源:test_methods.py


示例12: seed_source

def seed_source(user):
    source = BasketishOrderSource()
    billing_address = get_address()
    shipping_address = get_address(name="Shippy Doge")
    source.status = get_initial_order_status()
    source.shop = get_default_shop()
    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:portlyjent,项目名称:shoop,代码行数:14,代码来源:test_order_creator.py


示例13: test_waiver

def test_waiver():
    sm = get_shipping_method(name="Waivey", price=100, waive_at=370)
    source = BasketishOrderSource(get_default_shop())
    assert sm.get_effective_name(source) == u"Waivey"
    assert sm.get_total_cost(source).price == source.create_price(100)
    source.add_line(
        type=OrderLineType.PRODUCT,
        product=get_default_product(),
        base_unit_price=source.create_price(400),
        quantity=1
    )
    assert sm.get_total_cost(source).price == source.create_price(0)
开发者ID:00WhengWheng,项目名称:shuup,代码行数:12,代码来源:test_methods.py


示例14: get_source

def get_source():
    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),
    )
    source.add_line(
        type=OrderLineType.OTHER,
        quantity=1,
        base_unit_price=source.create_price(10),
        require_verification=True,
    )
    return source
开发者ID:NARESHARADHYULA,项目名称:shoop,代码行数:16,代码来源:test_taxes.py


示例15: test_methods

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)
开发者ID:00WhengWheng,项目名称:shuup,代码行数:46,代码来源:test_methods.py


示例16: test_order_creator_parent_linkage

def test_order_creator_parent_linkage():
    """
    Test OrderCreator creates parent links from OrderSource.
    """
    source = BasketishOrderSource(get_default_shop())
    source.status = get_initial_order_status()
    source.add_line(
        line_id='LINE1',
        type=OrderLineType.OTHER, quantity=1,
        sku='parent', text='Parent line',
    )
    source.add_line(
        line_id='LINE1.1',
        parent_line_id='LINE1',
        type=OrderLineType.OTHER, quantity=1,
        sku='child1.1', text='Child line 1.1',
    )
    source.add_line(
        line_id='LINE1.2',
        parent_line_id='LINE1',
        type=OrderLineType.OTHER, quantity=1,
        sku='child1.2', text='Child line 1.2',
    )
    source.add_line(
        line_id='LINE1.2.1',
        parent_line_id='LINE1.2',
        type=OrderLineType.OTHER, quantity=1,
        sku='child1.2.1', text='Child line 1.2.1',
    )
    source.add_line(
        line_id='LINE1.3',
        parent_line_id='LINE1',
        type=OrderLineType.OTHER, quantity=1,
        sku='child1.3', text='Child line 1.3',
    )
    order = OrderCreator().create_order(source)

    lines = [prettify_order_line(line) for line in order.lines.all()]
    assert lines == [
        '#0 1 x parent',
        '#1   1 x child1.1, child of #0',
        '#2   1 x child1.2, child of #0',
        '#3     1 x child1.2.1, child of #2',
        '#4   1 x child1.3, child of #0',
    ]
开发者ID:00WhengWheng,项目名称:shuup,代码行数:45,代码来源:test_product_packages.py


示例17: test_fixed_cost_with_waiving_costs

def test_fixed_cost_with_waiving_costs():
    sm = get_shipping_method(name="Fixed and waiving", price=5)

    sm.behavior_components.add(
        *[WaivingCostBehaviorComponent.objects.create(
            price_value=p, waive_limit_value=w)
          for (p, w) in [(3, 5), (7, 10), (10, 30)]])

    source = BasketishOrderSource(get_default_shop())
    source.shipping_method = sm

    def pricestr(pi):
        assert pi.price.unit_matches_with(source.create_price(0))
        return "%.0f EUR (%.0f EUR)" % (pi.price.value, pi.base_price.value)

    assert pricestr(sm.get_total_cost(source)) == "25 EUR (25 EUR)"
    assert source.total_price.value == 25

    source.add_line(
        type=OrderLineType.PRODUCT, product=get_default_product(),
        base_unit_price=source.create_price(2), quantity=1)
    assert pricestr(sm.get_total_cost(source)) == "25 EUR (25 EUR)"
    assert source.total_price.value == 27

    source.add_line(
        type=OrderLineType.PRODUCT, product=get_default_product(),
        base_unit_price=source.create_price(3), quantity=1)
    assert pricestr(sm.get_total_cost(source)) == "22 EUR (25 EUR)"
    assert source.total_price.value == 27

    source.add_line(
        type=OrderLineType.PRODUCT, product=get_default_product(),
        base_unit_price=source.create_price(10), quantity=1)
    assert pricestr(sm.get_total_cost(source)) == "15 EUR (25 EUR)"
    assert source.total_price.value == 30

    source.add_line(
        type=OrderLineType.PRODUCT, product=get_default_product(),
        base_unit_price=source.create_price(10), quantity=1)
    assert pricestr(sm.get_total_cost(source)) == "15 EUR (25 EUR)"
    assert source.total_price.value == 40

    source.add_line(
        type=OrderLineType.PRODUCT, product=get_default_product(),
        base_unit_price=source.create_price(10), quantity=1)
    assert pricestr(sm.get_total_cost(source)) == "5 EUR (25 EUR)"
    assert source.total_price.value == 40
开发者ID:00WhengWheng,项目名称:shuup,代码行数:47,代码来源:test_methods.py


示例18: get_order_and_source

def get_order_and_source(admin_user):
    # 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=get_default_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:00WhengWheng,项目名称:shuup,代码行数:27,代码来源:test_order_modifier.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python cart_modifiers_pool.get_modifiers_list函数代码示例发布时间:2022-05-27
下一篇:
Python utils.printable_gibberish函数代码示例发布时间: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