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


Python factories.get_default_tax_class函数代码示例

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


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

示例1: test_product_create

def test_product_create(browser, admin_user, live_server, settings):
    activate("en")
    shop = get_default_shop()
    get_default_product_type()
    get_default_sales_unit()
    get_default_tax_class()
    configuration.set(None, "shuup_product_tour_complete", True)
    object_created.connect(_add_custom_product_created_message, sender=Product, dispatch_uid="object_created_signal_test")
    initialize_admin_browser_test(browser, live_server, settings)

    url = reverse("shuup_admin:shop_product.new")
    browser.visit("%s%s" % (live_server, url))
    sku = "testsku"
    name = "Some product name"
    price_value = 10
    short_description = "short but gold"

    browser.fill("base-sku", sku)
    browser.fill("base-name__en", name)
    browser.fill("base-short_description__en", short_description)
    browser.fill("shop%s-default_price_value" % shop.pk, price_value)

    configuration.set(None, "shuup_category_tour_complete", True)
    _add_primary_category(browser, shop)
    _add_additional_category(browser, shop)

    click_element(browser, "button[form='product_form']")
    wait_until_appeared(browser, "div[class='message success']")
    product = Product.objects.filter(sku=sku).first()
    assert product.log_entries.filter(identifier=OBJECT_CREATED_LOG_IDENTIFIER).count() == 1
    object_created.disconnect(sender=Product, dispatch_uid="object_created_signal_test")
    shop_product = product.get_shop_instance(shop)
    assert shop_product.categories.count() == 2
开发者ID:gurch101,项目名称:shuup,代码行数:33,代码来源:test_product_create.py

示例2: test_create_services

def test_create_services():
    carrier = CorreiosCarrier.objects.create(name="Correios")

    pac_service = carrier.create_service(
        'PAC',
        shop=get_default_shop(),
        enabled=True,
        tax_class=get_default_tax_class(),
        name="Correios PAC")
    assert pac_service.behavior_components.count() == 1

    sedex_service = carrier.create_service(
        'SEDEX',
        shop=get_default_shop(),
        enabled=True,
        tax_class=get_default_tax_class(),
        name="Correios SEDEX")
    assert sedex_service.behavior_components.count() == 1

    strange_service = carrier.create_service(
        'STRANGE',
        shop=get_default_shop(),
        enabled=True,
        tax_class=get_default_tax_class(),
        name="unknown")

    assert strange_service.behavior_components.count() == 0
开发者ID:rockho-team,项目名称:shuup-correios,代码行数:27,代码来源:test_methods.py

示例3: test_refunds_report

def test_refunds_report(rf):
    shop = get_default_shop()
    get_default_tax_class()
    creator = OrderCreator()

    source1 = seed_source()
    source2 = seed_source()
    source3 = seed_source()
    source4 = seed_source()

    order1 = creator.create_order(source1)
    order2 = creator.create_order(source2)
    order3 = creator.create_order(source3)
    order4 = creator.create_order(source4)

    # pay orders
    [o.create_payment(o.taxful_total_price) for o in Order.objects.all()]

    order1.create_full_refund()
    order2.create_refund(
        [{"line": order2.lines.first(), "amount": order2.taxful_total_price.amount * Decimal(0.5), "quantity": 1}]
    )
    order3.create_refund(
        [{"line": order3.lines.first(), "amount": order3.taxful_total_price.amount * Decimal(0.3), "quantity": 1}]
    )
    order4.create_refund(
        [{"line": order4.lines.first(), "amount": order4.taxful_total_price.amount * Decimal(0.1), "quantity": 1}]
    )

    total_refunded = (order1.get_total_refunded_amount() +
                      order2.get_total_refunded_amount() +
                      order3.get_total_refunded_amount() +
                      order4.get_total_refunded_amount())

    data = {
        "report": RefundedSalesReport.get_name(),
        "shop": shop.pk,
        "date_range": DateRangeChoices.ALL_TIME,
        "writer": "json",
        "force_download": 1,
    }
    report = RefundedSalesReport(**data)
    writer = get_writer_instance(data["writer"])
    response = writer.get_response(report=report)
    if hasattr(response, "render"):
        response.render()
    json_data = json.loads(response.content.decode("utf-8"))
    assert force_text(RefundedSalesReport.title) in json_data.get("heading")
    data = json_data.get("tables")[0].get("data")
    assert len(data) == 1
    data = data[0]

    expected_data = {
        "refunded_orders": "4",
        "total_refunded": str(total_refunded.value)
    }

    for k, v in expected_data.items():
        assert data[k] == v
开发者ID:ruqaiya,项目名称:shuup,代码行数:59,代码来源:test_default_reports.py

示例4: test_wizard_pane

def test_wizard_pane(rf, admin_user, settings):
    with override_settings(SHUUP_SETUP_WIZARD_PANE_SPEC=["shuup.admin.modules.service_providers.views.PaymentWizardPane"]):
        factories.get_default_shop()
        factories.get_default_tax_class()

        request = apply_request_middleware(rf.get("/"), user=admin_user)
        response = WizardView.as_view()(request)
        assert response.status_code == 200
开发者ID:shuup,项目名称:shuup-stripe,代码行数:8,代码来源:test_wizard.py

示例5: test_quick_add

def test_quick_add(browser, admin_user, live_server, settings):
    shop = get_default_shop()
    get_default_product_type()
    get_default_sales_unit()
    get_default_tax_class()
    initialize_admin_browser_test(browser, live_server, settings)

    url = reverse("shuup_admin:shop_product.new")
    browser.visit("%s%s" % (live_server, url))
    sku = "testsku"
    name = "Some product name"
    price_value = 10
    short_description = "short but gold"

    browser.fill("base-sku", sku)
    browser.fill("base-name__en", name)
    browser.fill("base-short_description__en", short_description)
    browser.fill("shop%s-default_price_value" % shop.pk, price_value)

    wait_until_appeared(browser, "#id_shop%d-primary_category ~ .quick-add-btn a.btn" % shop.id)
    click_element(browser, "#id_shop%d-primary_category ~ .quick-add-btn a.btn" % shop.id)
    wait_until_appeared(browser, "#create-object-iframe")

    with browser.get_iframe('create-object-iframe') as iframe:
        assert Category.objects.count() == 0
        wait_until_appeared(iframe, "input[name='base-name__en']")
        iframe.fill("base-name__en", "Test Category")
        time.sleep(3)  # Let's just wait here to the iFrame to open fully (for Chrome and headless)
        wait_until_appeared(iframe, "button[form='category_form']")
        click_element(browser, "button[form='category_form']")
        wait_until_condition(browser, condition=lambda x: Category.objects.count() == 1, timeout=20)

    assert Category.objects.first().name == "Test Category"

    # click to edit the button
    click_element(browser, "#id_shop%d-primary_category ~ .edit-object-btn a.btn" % shop.id)

    with browser.get_iframe('create-object-iframe') as iframe:
        wait_until_appeared(iframe, "input[name='base-name__en']")
        new_cat_name = "Changed Name"
        iframe.fill("base-name__en", new_cat_name)
        time.sleep(3)  # Let's just wait here to the iFrame to open fully (for Chrome and headless)
        wait_until_appeared(iframe, "button[form='category_form']")
        click_element(iframe, "button[form='category_form']")

    wait_until_condition(browser, condition=lambda x: Category.objects.first().name == new_cat_name, timeout=20)

    click_element(browser, "button[form='product_form']")
    wait_until_appeared(browser, "div[class='message success']")
开发者ID:ruqaiya,项目名称:shuup,代码行数:49,代码来源:test_quick_add_edit_button.py

示例6: test_complex_import

def test_complex_import():
    filename = "complex_import.xlsx"
    activate("en")
    shop = get_default_shop()
    get_default_tax_class()
    get_default_product_type()
    get_default_supplier()
    get_default_sales_unit()

    path = os.path.join(os.path.dirname(__file__), "data", "product", filename)
    transformed_data = transform_file(filename.split(".")[1], path)
    importer = ProductImporter(transformed_data, shop, "en")
    importer.process_data()

    assert len(importer.unmatched_fields) == 0
    importer.do_import(ImportMode.CREATE_UPDATE)
    products = importer.new_objects
    assert len(products) == 6
    assert ShopProduct.objects.count() == 6
    assert Category.objects.count() == 11
    assert Manufacturer.objects.count() == 4

    for idx, product in enumerate(Product.objects.all().order_by("sku")):
        shop_product = product.get_shop_instance(shop)

        data = PRODUCT_DATA[idx]
        assert product.sku == data["sku"]
        assert product.name == data["name"]

        assert shop_product.default_price_value == Decimal(data["price"])
        assert product.description == data["description"]

        if data.get("categories"):
            all_cats = set(data["categories"])
            all_cats.add(data["category"])

            for cat in shop_product.categories.all():
                assert cat.name in all_cats
            assert shop_product.categories.count() == len(all_cats)  # also add primary category

        if data.get("category"):
            assert shop_product.primary_category.name == data["category"]

        assert force_text(shop_product.visibility.label) == data["visibility"].lower()
        assert product.tax_class.name == data["tax_class"]

        if data.get("manufacturer"):
            assert product.manufacturer.name == data["manufacturer"]
开发者ID:ruqaiya,项目名称:shuup,代码行数:48,代码来源:test_product_import.py

示例7: test_stripe_checkout_phase

def test_stripe_checkout_phase(rf, stripe_payment_processor):
    request = rf.get("/")
    request.shop = get_default_shop()
    request.session = {}
    request.basket = get_basket(request)
    service = stripe_payment_processor.create_service(
        None, shop=request.shop, tax_class=get_default_tax_class(),
        enabled=True)
    checkout_phase = StripeCheckoutPhase(
        request=request, service=service)
    assert not checkout_phase.is_valid()  # We can't be valid just yet
    context = checkout_phase.get_context_data()
    assert context["stripe"]
    request.method = "POST"
    token = get_stripe_token(stripe_payment_processor)
    request.POST = {
        "stripeToken": token["id"],
        "stripeTokenType": token["type"],
        "stripeTokenEmail": token.get("email"),
    }
    checkout_phase.post(request)
    assert checkout_phase.is_valid()  # We should be valid now
    assert request.session  # And things should've been saved into the session
    checkout_phase.process()  # And this should do things to the basket
    assert request.basket.payment_data.get("stripe")
开发者ID:farzeni,项目名称:shuup-stripe,代码行数:25,代码来源:test_stripe.py

示例8: get_correios_carrier_2

def get_correios_carrier_2():
    carrier = CorreiosCarrier.objects.create(name="Correios C2")

    pac_service2 = carrier.create_service(
        'PAC',
        shop=get_default_shop(),
        enabled=True,
        tax_class=get_default_tax_class(),
        name="Correios - PAC #2")

    pac_service_bc2 = pac_service2.behavior_components.first()
    pac_service_bc2.cep_origem = '88220000'
    pac_service_bc2.max_weight = Decimal(40000.0)
    pac_service_bc2.max_width = Decimal(800.0)
    pac_service_bc2.max_length = Decimal(600.0)
    pac_service_bc2.max_height = Decimal(400.0)
    pac_service_bc2.min_width = Decimal(90.0)
    pac_service_bc2.min_length = Decimal(60.0)
    pac_service_bc2.min_height = Decimal(50.0)
    pac_service_bc2.max_edges_sum = Decimal(2000.0)
    pac_service_bc2.mao_propria = True
    pac_service_bc2.valor_declarado = True
    pac_service_bc2.aviso_recebimento = True
    pac_service_bc2.additional_delivery_time = 2
    pac_service_bc2.additional_price = Decimal(13.3)
    pac_service_bc2.save()

    return carrier
开发者ID:rockho-team,项目名称:shuup-correios,代码行数:28,代码来源:test_methods.py

示例9: test_sample_ignore_column

def test_sample_ignore_column():
    activate("en")
    shop = get_default_shop()
    get_default_tax_class()
    get_default_product_type()
    get_default_sales_unit()

    path = os.path.join(os.path.dirname(__file__), "data", "product", "sample_import_ignore.csv")
    transformed_data = transform_file("csv", path)
    importer = ProductImporter(transformed_data, shop, "en")
    importer.process_data()

    assert len(importer.unmatched_fields) == 0
    importer.do_import(ImportMode.CREATE_UPDATE)
    products = importer.new_objects
    assert len(products) == 2
开发者ID:ruqaiya,项目名称:shuup,代码行数:16,代码来源:test_product_import.py

示例10: test_process_payment_return_request

def test_process_payment_return_request(rf):
    """
    Order payment with default payment method with ``CustomPaymentProcessor``
    should be deferred.

    Payment can't be processed if method doesn't have provider or provider
    is not enabled or payment method is not enabled.
    """
    pm = PaymentMethod.objects.create(
        shop=get_default_shop(), name="Test method", enabled=False, tax_class=get_default_tax_class())
    order = create_empty_order()
    order.payment_method = pm
    order.save()
    assert order.payment_status == PaymentStatus.NOT_PAID
    with pytest.raises(ValueError):  # Can't process payment with unusable method
        order.payment_method.process_payment_return_request(order, rf.get("/"))
    assert order.payment_status == PaymentStatus.NOT_PAID
    pm.payment_processor = get_custom_payment_processor()
    pm.payment_processor.enabled = False
    pm.save()

    with pytest.raises(ValueError):  # Can't process payment with unusable method
        order.payment_method.process_payment_return_request(order, rf.get("/"))
    assert order.payment_status == PaymentStatus.NOT_PAID
    pm.payment_processor.enabled = True
    pm.save()

    with pytest.raises(ValueError):  # Can't process payment with unusable method
        order.payment_method.process_payment_return_request(order, rf.get("/"))
    assert order.payment_status == PaymentStatus.NOT_PAID
    pm.enabled = True
    pm.save()

    order.payment_method.process_payment_return_request(order, rf.get("/"))
    assert order.payment_status == PaymentStatus.DEFERRED
开发者ID:ahmadzai,项目名称:shuup,代码行数:35,代码来源:test_methods.py

示例11: test_custom_payment_processor_cash_service

def test_custom_payment_processor_cash_service(choice_identifier, expected_payment_status):
    shop = get_default_shop()
    product = get_default_product()
    supplier = get_default_supplier()
    processor = CustomPaymentProcessor.objects.create()
    payment_method = PaymentMethod.objects.create(
        shop=shop,
        payment_processor=processor,
        choice_identifier=choice_identifier,
        tax_class=get_default_tax_class())

    order = create_order_with_product(
        product=product,
        supplier=supplier,
        quantity=1,
        taxless_base_unit_price=Decimal('5.55'),
        shop=shop)
    order.taxful_total_price = TaxfulPrice(Decimal('5.55'), u'EUR')
    order.payment_method = payment_method
    order.save()

    assert order.payment_status == PaymentStatus.NOT_PAID
    processor.process_payment_return_request(choice_identifier, order, None)
    assert order.payment_status == expected_payment_status
    processor.process_payment_return_request(choice_identifier, order, None)
    assert order.payment_status == expected_payment_status
开发者ID:suutari,项目名称:shoop,代码行数:26,代码来源:test_custom_payment_processor.py

示例12: test_order_package_children_taxes

def test_order_package_children_taxes():
    """
    Test OrderCreator creates package parent links for child lines.
    """
    tax_class = get_default_tax_class()
    tax = Tax.objects.create(rate='0.25', name="Da Tax")
    TaxRule.objects.create(tax=tax).tax_classes.add(tax_class)

    source = get_order_source_with_a_package()
    assert source.get_lines()[0].tax_class == tax_class

    order = OrderCreator().create_order(source)

    lines_and_taxes = []
    for line in order.lines.all():
        lines_and_taxes.append(prettify_order_line(line))
        for line_tax in line.taxes.all():
            lines_and_taxes.append('  %s' % (line_tax,))
    assert lines_and_taxes == [
        '#0 10 x PackageParent',
        '  Da Tax: 20.000000000 EUR on 80.000000000 EUR',
        '#1   10 x PackageChild-0, child of #0',
        '#2   20 x PackageChild-1, child of #0',
        '#3   30 x PackageChild-2, child of #0',
        '#4   40 x PackageChild-3, child of #0',
    ]
开发者ID:ahmadzai,项目名称:shuup,代码行数:26,代码来源:test_product_packages.py

示例13: test_method_creation

def test_method_creation(rf, admin_user, view, model, service_provider_attr, get_provider):
    """
    To make things little bit more simple let's use only english as
    an language.
    """
    with override_settings(LANGUAGES=[("en", "en")]):
        view = view.as_view()
        service_provider_field = "base-%s" % service_provider_attr
        data = {
            service_provider_field: get_provider().id,
            "base-choice_identifier": "manual",
            "base-name__en": "Custom method",
            "base-shop": get_default_shop().id,
            "base-tax_class": get_default_tax_class().id,
            "base-enabled": True,
        }
        # Default provider CustomCarrier/CustomPaymentProcessor should be set in form init
        methods_before = model.objects.count()
        url = "/?provider=%s" % get_provider().id
        request = apply_request_middleware(rf.post(url, data=data), user=admin_user)
        response = view(request, pk=None)
        if hasattr(response, "render"):
            response.render()
        assert response.status_code in [200, 302]
        assert model.objects.count() == (methods_before + 1)
开发者ID:NamiStudio,项目名称:shuup,代码行数:25,代码来源:test_services.py

示例14: _get_template_engine_and_context

def _get_template_engine_and_context():
    engine = django.template.engines['jinja2']
    assert isinstance(engine, django_jinja.backend.Jinja2)

    shop = get_default_shop()
    shop.currency = 'USD'
    shop.prices_include_tax = False
    shop.save()

    request = RequestFactory().get('/')
    request.shop = shop
    request.customer = AnonymousContact()
    request.person = request.customer
    PriceDisplayOptions(include_taxes=False).set_for_request(request)
    tax = get_default_tax()
    create_default_tax_rule(tax)
    tax_class = get_default_tax_class()
    order, order_line = _get_order_and_order_line(request)

    product = create_product(sku='6.0745', shop=shop, tax_class=tax_class)

    context = {
        'request': request,
        'prod': product,
        # TODO: Test also with variant products
        'sline': _get_source_line(request),
        'bline': _get_basket_line(request),
        'oline': order_line,
        'order': order
    }

    return (engine, context)
开发者ID:gurch101,项目名称:shuup,代码行数:32,代码来源:test_price_display.py

示例15: test_sample_import_all_match

def test_sample_import_all_match(filename):
    activate("en")
    shop = get_default_shop()
    tax_class = get_default_tax_class()
    product_type = get_default_product_type()

    path = os.path.join(os.path.dirname(__file__), "data", "product", filename)
    transformed_data = transform_file(filename.split(".")[1], path)
    importer = ProductImporter(transformed_data, shop, "en")
    importer.process_data()
    assert len(importer.unmatched_fields) == 0
    importer.do_import(ImportMode.CREATE_UPDATE)
    products = importer.new_objects
    assert len(products) == 2
    for product in products:
        shop_product = product.get_shop_instance(shop)
        assert shop_product.pk
        assert shop_product.pk == product.pk
        assert shop_product.default_price_value == 150
        assert shop_product.default_price == shop.create_price(150)
        assert product.type == product_type  # product type comes from importer defaults
        if product.pk == 1:
            assert product.tax_class.pk == 2  # new was created
            assert product.name == "Product English"
            assert product.description == "Description English"
        else:
            assert product.tax_class.pk == tax_class.pk  # old was found as should
            assert product.name == "Product 2 English"
            assert product.description == "Description English 2"
        assert shop_product.primary_category.pk == 1
        assert [c.pk for c in shop_product.categories.all()] == [1,2]
开发者ID:suutari,项目名称:shoop,代码行数:31,代码来源:test_product_import.py


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