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

Python factories.get_default_tax_class函数代码示例

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

本文整理汇总了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函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: test_stripe_checkout_phase_with_saved_card

def test_stripe_checkout_phase_with_saved_card(rf, stripe_payment_processor):
    shop = factories.get_default_shop()
    user = factories.create_random_user()
    contact = get_person_contact(user)
    request = apply_request_middleware(rf.post("/"), shop=shop, customer=contact)

    def return_stripe_mock_data(*args, **kwargs):
        return StripedData(**CUSTOMER_MOCK_DATA)

    with mock.patch("stripe.Customer.retrieve", new=return_stripe_mock_data):
        service = stripe_payment_processor.create_service(
            "stripe", shop=request.shop, tax_class=factories.get_default_tax_class(), enabled=True)

        StripeCustomer.objects.create(contact=contact, customer_token="123")
        checkout_phase = StripeCheckoutPhase(request=request, service=service)
        assert not checkout_phase.is_valid()
        context = checkout_phase.get_context_data()
        assert context["stripe"]
        request.method = "POST"
        request.POST = {
            "stripeCustomer": "1234"
        }
        checkout_phase.get_success_url = lambda: reverse("shuup_admin:home")
        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["stripe"]["customer"]
开发者ID:shuup,项目名称:shuup-stripe,代码行数:28,代码来源:test_stripe_saved_card.py


示例17: test_stripe_checkout_phase_with_saved_card_exception

def test_stripe_checkout_phase_with_saved_card_exception(rf, stripe_payment_processor):
    shop = factories.get_default_shop()
    user = factories.create_random_user()
    contact = get_person_contact(user)
    request = apply_request_middleware(rf.post("/"), shop=shop, customer=contact)

    def raise_stripe_exc(*args, **kwargs):
        raise stripe.StripeError("DUMMY")

    with mock.patch("stripe.Customer.retrieve", new=raise_stripe_exc):
        service = stripe_payment_processor.create_service(
            "stripe", shop=request.shop, tax_class=factories.get_default_tax_class(), enabled=True)

        StripeCustomer.objects.create(contact=contact, customer_token="123")
        checkout_phase = StripeCheckoutPhase(request=request, service=service)
        assert not checkout_phase.is_valid()
        context = checkout_phase.get_context_data()
        assert context["stripe"]
        assert not context.get("stripe_customer_data")

        request.method = "POST"
        request.POST = {}
        checkout_phase.get_success_url = lambda: reverse("shuup_admin:home")
        checkout_phase.post(request)
        assert not checkout_phase.is_valid()
开发者ID:shuup,项目名称:shuup-stripe,代码行数:25,代码来源:test_stripe_saved_card.py


示例18: test_method_creation_with_labels

def test_method_creation_with_labels(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")]):
        for identifier, name in [("pickup", "Pickup"), ("delivery", "Delivery"), ("airmail", "Airmail")]:
            label = Label.objects.create(identifier=identifier, name=name)
            assert label.name == name
            assert "%s" % label == name

        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,
            "base-labels": Label.objects.values_list("pk", flat=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)
        assert model.objects.last().labels.count() == Label.objects.count()
开发者ID:ruqaiya,项目名称:shuup,代码行数:32,代码来源:test_services.py


示例19: test_sample_data_wizard_pane

def test_sample_data_wizard_pane(rf, admin_user, settings):
    settings.SHUUP_SETUP_WIZARD_PANE_SPEC = [
        "shuup.testing.modules.sample_data.views.SampleObjectsWizardPane"
    ]

    shop = get_default_shop()
    get_default_tax_class()

    data = {
        'pane_id': 'sample',
        'sample-business_segment': 'default',
        'sample-categories': True,
        'sample-products': True,
        'sample-carousel': True
    }

    request = apply_request_middleware(rf.post("/", data=data), user=admin_user)
    response = WizardView.as_view()(request)
    assert response.status_code == 200

    assert Product.objects.count() == len(BUSINESS_SEGMENTS["default"]["products"])
    anon_contact = AnonymousContact()
    supplier = get_default_supplier()

    # check for the injected plugin using the carousel
    assert Carousel.objects.count() == 1
    carousel = Carousel.objects.first()
    assert Slide.objects.count() == len(BUSINESS_SEGMENTS["default"]["carousel"]["slides"])
    svc = SavedViewConfig.objects.first()
    assert svc.view_name == "IndexView"
    layout = svc.get_layout_data("front_content")
    assert layout['rows'][0]['cells'][0]['config']['carousel'] == carousel.pk
    assert layout['rows'][0]['cells'][0]['plugin'] == CarouselPlugin.identifier

    for product in Product.objects.all():
        # all products must be orderable and have images
        assert product.get_shop_instance(shop).is_orderable(supplier=supplier,
                                                            customer=anon_contact,
                                                            quantity=1)
        assert product.primary_image is not None

    assert Category.objects.count() == len(BUSINESS_SEGMENTS["default"]["categories"])

    request = apply_request_middleware(rf.get("/"), user=admin_user)
    response = WizardView.as_view()(request)
    assert response.status_code == 302
    assert response["Location"] == reverse("shuup_admin:dashboard")
开发者ID:ruqaiya,项目名称:shuup,代码行数:47,代码来源:test_sample_data.py


示例20: test_sample_import_no_match

def test_sample_import_no_match(stock_managed):
    filename = "sample_import_nomatch.xlsx"
    if "shuup.simple_supplier" not in settings.INSTALLED_APPS:
        pytest.skip("Need shuup.simple_supplier in INSTALLED_APPS")
    from shuup_tests.simple_supplier.utils import get_simple_supplier

    activate("en")
    shop = get_default_shop()
    tax_class = get_default_tax_class()
    product_type = get_default_product_type()
    supplier = get_simple_supplier(stock_managed)
    sales_unit = get_default_sales_unit()

    Manufacturer.objects.create(name="manufctr")
    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) == 1
    assert "gtiin" in importer.unmatched_fields
    importer.manually_match("gtiin", "shuup.core.models.Product:gtin")
    importer.do_remap()
    assert len(importer.unmatched_fields) == 0
    importer.do_import(ImportMode.CREATE_UPDATE)
    products = importer.new_objects
    assert len(products) == 2

    for product in products:
        assert product.gtin == "1280x720"
        shop_product = product.get_shop_instance(shop)
        assert shop_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
        assert product.sales_unit == sales_unit
        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]

    # stock was not managed since supplier doesn't like that
    for msg in importer.other_log_messages:
        assert "please set Stock Managed on" in msg

    supplier.stock_managed = True
    supplier.save()
    importer.do_import("create,update")

    assert len(importer.other_log_messages) == 0
    for sa in StockAdjustment.objects.all():
        assert sa.product.pk
        assert sa.delta == 20
开发者ID:ruqaiya,项目名称:shuup,代码行数:59,代码来源:test_product_import.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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