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

Python utils.SmartClient类代码示例

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

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



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

示例1: test_theme_without_default_template_dir

def test_theme_without_default_template_dir():
    get_default_shop()
    with override_current_theme_class(ShuupTestingTheme):
        c = SmartClient()
        soup = c.soup(reverse("shuup:index"))
        assert "Simple base for themes to use" not in soup
        assert "Welcome to test Shuup!" in soup.find("div", {"class": "page-content"}).text
开发者ID:suutari,项目名称:shoop,代码行数:7,代码来源:test_default_template_dir.py


示例2: test_update_injection

def test_update_injection():
    shop = factories.get_default_shop()
    client = SmartClient()
    index_url = reverse("shuup:index")

    page = ensure_gdpr_privacy_policy(shop)
    shop_gdpr = GDPRSettings.get_for_shop(shop)
    shop_gdpr.enabled = True
    shop_gdpr.privacy_policy = page
    shop_gdpr.save()

    assert_update(client, index_url, False)  # nothing consented in past, should not show

    user = factories.create_random_user("en")
    password = "test"
    user.set_password(password)
    user.save()

    client.login(username=user.username, password=password)
    assert_update(client, index_url, False)  # no consent given, should not be visible

    create_user_consent_for_all_documents(shop, user)
    assert_update(client, index_url, False)

    with reversion.create_revision():
        page.save()

    assert not is_documents_consent_in_sync(shop, user)
    assert_update(client, index_url, True)

    # consent
    client.get(reverse("shuup:gdpr_policy_consent", kwargs=dict(page_id=page.pk)))
    assert is_documents_consent_in_sync(shop, user)
    assert_update(client, index_url, False)
开发者ID:ruqaiya,项目名称:shuup,代码行数:34,代码来源:test_consent_resource.py


示例3: test_get_installments_cc_does_not_allow_installments

def test_get_installments_cc_does_not_allow_installments():
    """
        Max 9 installs with SIMPLE intereset
        interest_rate = 4.00%
        Credit card does not allow installments
    """
    patch_cielo_request()

    shop = get_default_shop()
    create_default_order_statuses()
    populate_if_required()
    set_current_theme('shuup.themes.classic_gray')
    c = SmartClient()
    _configure_basket(c)
    CieloConfig.objects.create(shop=shop,
                               max_installments=9,
                               installments_without_interest=3,
                               interest_type=InterestType.Simple,
                               interest_rate=Decimal(4.0))

    order_total = (PRODUCT_QTNTY * PRODUCT_PRICE)
    total_price_str = "{0}".format(format_money(shop.create_price(order_total)))

    response = c.get(INSTALLMENTS_PATH, {"cc_brand": CieloCardBrand.Discover})
    json_content = json.loads(response.content.decode("utf-8"))
    assert len(json_content['installments']) == 1
    assert json_content['installments'][0]['number'] == 1
    assert total_price_str in json_content['installments'][0]['name']
开发者ID:rockho-team,项目名称:shuup-cielo,代码行数:28,代码来源:test_views.py


示例4: test_theme_with_default_template_dir

def test_theme_with_default_template_dir():
    get_default_shop()
    with override_current_theme_class(ShuupTestingThemeWithCustomBase):
        c = SmartClient()
        soup = c.soup(reverse("shuup:index"))
        assert "Simple base for themes to use" in soup.find("h1").text
        assert "Welcome to test Shuup!" in soup.find("h1").text
开发者ID:suutari,项目名称:shoop,代码行数:7,代码来源:test_default_template_dir.py


示例5: test_get_installments_12x_with_simples_intereset

def test_get_installments_12x_with_simples_intereset():
    """
        Max 12 installs with PRICE intereset
        interest_rate = 2.30%
        min_installment_amount = 30.00
    """
    patch_cielo_request()
    shop = get_default_shop()
    create_default_order_statuses()
    populate_if_required()
    set_current_theme('shuup.themes.classic_gray')
    c = SmartClient()
    _configure_basket(c)
    cielo_config = CieloConfig.objects.create(shop=shop,
                                              max_installments=12,
                                              installments_without_interest=2,
                                              interest_type=InterestType.Price,
                                              interest_rate=Decimal(2.3),
                                              min_installment_amount=Decimal(30))

    order_total = (PRODUCT_QTNTY * PRODUCT_PRICE)
    installment_choices = InstallmentContext(order_total, cielo_config).get_intallments_choices()

    response = c.get(INSTALLMENTS_PATH, {"cc_brand": CieloCardBrand.Visa})
    json_content = json.loads(response.content.decode("utf-8"))
    assert len(json_content['installments']) == len(installment_choices)

    for installment in range(len(installment_choices)):
        total = format_money(shop.create_price(installment_choices[installment][2]))
        installment_amount = format_money(shop.create_price(installment_choices[installment][1]))

        assert json_content['installments'][installment]['number'] == installment+1
        assert installment_amount in json_content['installments'][installment]['name']
        assert total in json_content['installments'][installment]['name']
开发者ID:rockho-team,项目名称:shuup-cielo,代码行数:34,代码来源:test_views.py


示例6: test_get_installments_3x_no_intereset

def test_get_installments_3x_no_intereset():
    """
        Max 3 installs with no intereset
    """
    patch_cielo_request()
    shop = get_default_shop()
    create_default_order_statuses()
    populate_if_required()
    set_current_theme('shuup.themes.classic_gray')
    c = SmartClient()
    _configure_basket(c)
    CieloConfig.objects.create(shop=shop,
                               max_installments=3,
                               installments_without_interest=3)

    order_total = PRODUCT_QTNTY * PRODUCT_PRICE
    total_price_str = "{0}".format(format_money(shop.create_price(order_total)))

    response = c.get(INSTALLMENTS_PATH, {"cc_brand": CieloCardBrand.Visa})
    json_content = json.loads(response.content.decode("utf-8"))
    assert len(json_content['installments']) == 3

    assert json_content['installments'][0]['number'] == 1
    assert total_price_str in json_content['installments'][0]['name']

    total_2x_no_interest = format_money(shop.create_price(order_total / Decimal(2)))
    assert json_content['installments'][1]['number'] == 2
    assert total_price_str in json_content['installments'][1]['name']
    assert total_2x_no_interest in json_content['installments'][1]['name']

    total_3x_no_interest = format_money(shop.create_price(order_total / Decimal(3)))
    assert json_content['installments'][2]['number'] == 3
    assert total_price_str in json_content['installments'][2]['name']
    assert total_3x_no_interest in json_content['installments'][2]['name']
开发者ID:rockho-team,项目名称:shuup-cielo,代码行数:34,代码来源:test_views.py


示例7: test_extender_renders_main_menu

def test_extender_renders_main_menu(rf):
    get_default_shop()

    with override_provides("front_menu_extender", ["shuup_tests.xtheme.test_extenders:TestExtender"]):
        c = SmartClient()
        soup = c.soup(reverse("shuup:index"))
        link_texts = [a.text for a in soup.findAll("a")]
        assert "Test Link to Front" in link_texts
开发者ID:ruqaiya,项目名称:shuup,代码行数:8,代码来源:test_extenders.py


示例8: initialize_test

def initialize_test(regular_user, person=True):
    client = SmartClient()
    get_default_shop()
    if person:
        contact = get_person_contact(regular_user)
    else:
        contact = get_company_contact(regular_user)

    client.login(username=REGULAR_USER_USERNAME, password=REGULAR_USER_PASSWORD)
    return client, contact
开发者ID:ruqaiya,项目名称:shuup,代码行数:10,代码来源:test_addressbook.py


示例9: test_shop_remove_available_languages

def test_shop_remove_available_languages(admin_user):
    shop = factories.get_default_shop()
    client = SmartClient()

    with override_settings(
        LANGUAGES=[
            ("en", "English"),
            ("fi", "Finnish"),
        ],
        LANGUAGE_CODE="en",
        PARLER_DEFAULT_LANGUAGE_CODE = "en"
    ):
        # there is no language set for the shop, the first one will be used
        response = client.get(reverse("shuup:index"))
        assert get_language() == "en"

        # request js catalog file
        response = client.get(reverse("shuup:js-catalog"))
        assert get_language() == "en"

        # when requesting admin js catalog, the language should be any of the available
        client.get("shuup_admin:js-catalog")
        assert get_language() == "en"

        set_shop_available_languages(shop, ["fi"])

        response = client.get(reverse("shuup:index"))
        assert get_language() == "fi"

        response = client.get(reverse("shuup:js-catalog"))
        assert get_language() == "fi"

        client.get("shuup_admin:js-catalog")
        assert get_language() == "en"
开发者ID:ruqaiya,项目名称:shuup,代码行数:34,代码来源:test_languages.py


示例10: test_consent_cookies

def test_consent_cookies():
    """
    Test that the GDPR consent is generated and saved into a cooki
    """
    for code, lang in settings.LANGUAGES:
        activate(code)
        shop = factories.get_default_shop()
        client = SmartClient()
        index_url = reverse("shuup:index")
        response = client.get(index_url)

        # create a GDPR setting for the shop
        shop_gdpr = GDPRSettings.get_for_shop(shop)
        shop_gdpr.cookie_banner_content = "my cookie banner content"
        shop_gdpr.cookie_privacy_excerpt = "my cookie privacyexcerpt"
        shop_gdpr.enabled = True
        shop_gdpr.save()

        # create cookie categories
        required_cookie_category = GDPRCookieCategory.objects.create(
            shop=shop,
            always_active=True,
            cookies="cookie1,cookir2,_cookie3",
            name="RequiredCookies",
            how_is_used="to make the site work"
        )
        optional_cookie_category = GDPRCookieCategory.objects.create(
            shop=shop,
            always_active=False,
            cookies="_opt1,_opt2,_opt3",
            name="OptionalCookies",
            how_is_used="to spy users"
        )

        # create privacy policy GDPR document
        privacy_policy = ensure_gdpr_privacy_policy(shop)
        response = client.get(index_url)
        assert settings.SHUUP_GDPR_CONSENT_COOKIE_NAME not in response.cookies

        # send consent
        response = client.post(reverse("shuup:gdpr_consent"), data={
            "cookie_category_{}".format(required_cookie_category.id): "on",
            "cookie_category_{}".format(optional_cookie_category.id): "on"
        })

        assert settings.SHUUP_GDPR_CONSENT_COOKIE_NAME in response.cookies
        cookies_data = json.loads(response.cookies[settings.SHUUP_GDPR_CONSENT_COOKIE_NAME].value)
        assert privacy_policy.id == cookies_data["documents"][0]["id"]
        assert privacy_policy.url == cookies_data["documents"][0]["url"]

        for cookie in required_cookie_category.cookies.split(","):
            assert cookie in cookies_data["cookies"]
        for cookie in optional_cookie_category.cookies.split(","):
            assert cookie in cookies_data["cookies"]
开发者ID:ruqaiya,项目名称:shuup,代码行数:54,代码来源:test_consent_resource.py


示例11: test_basic_order_flow_registered

def test_basic_order_flow_registered(regular_user):
    cache.clear()
    create_default_order_statuses()
    n_orders_pre = Order.objects.count()
    populate_if_required()
    get_test_script("test script", "order_received")
    # paths
    addresses_path = reverse("shuup:checkout", kwargs={"phase": "addresses"})
    methods_path = reverse("shuup:checkout", kwargs={"phase": "methods"})
    confirm_path = reverse("shuup:checkout", kwargs={"phase": "confirm"})

    template_data = STEP_DATA[0]["actions"][0]["template_data"]

    LANG_CODE = {
        "en": "US",
        "fi": "FI"
    }

    for lang in ["en", "fi"]:
        n_outbox_pre = len(mail.outbox)
        contact = get_person_contact(regular_user)
        contact.language = lang
        contact.save()

        c = SmartClient()
        c.login(username=REGULAR_USER_USERNAME, password=REGULAR_USER_PASSWORD)

        product_ids = _populate_client_basket(c)

        addresses_soup = c.soup(addresses_path)
        address = get_address(country=LANG_CODE[lang])

        inputs = fill_address_inputs(addresses_soup, address)
        response = c.post(addresses_path, data=inputs)
        assert response.status_code == 302  # Should redirect forth

        methods_soup = c.soup(methods_path)
        assert c.post(methods_path, data=extract_form_fields(methods_soup)).status_code == 302  # Should redirect forth

        confirm_soup = c.soup(confirm_path)
        Product.objects.get(pk=product_ids[0]).soft_delete()
        assert c.post(confirm_path, data=extract_form_fields(confirm_soup)).status_code == 200  # user needs to reconfirm
        data = extract_form_fields(confirm_soup)
        data['product_ids'] = ','.join(product_ids[1:])
        assert c.post(confirm_path, data=data).status_code == 302  # Should redirect forth

        n_orders_post = Order.objects.count()
        assert n_orders_post > n_orders_pre, "order was created"
        assert (len(mail.outbox) == n_outbox_pre + 1), "Sending email failed"
        latest_mail = mail.outbox[-1]

        # mail is always sent in fallback language since user is not registered
        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,代码行数:54,代码来源:test_order_notifications.py


示例12: test_theme_with_default_template_dir

def test_theme_with_default_template_dir():
    with override_settings(CACHES={
        'default': {
            'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
            'LOCATION': 'test_configuration_cache',
        }
    }):
        cache.init_cache()
        get_default_shop()
        with override_current_theme_class(ShuupTestingThemeWithCustomBase, get_default_shop()):
            c = SmartClient()
            soup = c.soup(reverse("shuup:index"))
            assert "Simple base for themes to use" in soup.find("h1").text
            assert "Welcome to test Shuup!" in soup.find("h1").text
开发者ID:ruqaiya,项目名称:shuup,代码行数:14,代码来源:test_default_template_dir.py


示例13: test_checkout_empty_basket

def test_checkout_empty_basket(rf):
    create_default_order_statuses()
    n_orders_pre = Order.objects.count()
    populate_if_required()
    c = SmartClient()
    product_ids = _populate_client_basket(c)
    addresses_path = reverse("shuup:checkout", kwargs={"phase": "addresses"})
    addresses_soup = c.soup(addresses_path)
    inputs = fill_address_inputs(addresses_soup)
    for product_id in product_ids:
        Product.objects.get(pk=product_id).soft_delete()
    response, soup = c.response_and_soup(addresses_path, data=inputs, method="post")
    assert response.status_code == 200  # Should redirect forth
    assert b"Your shopping cart is empty." in soup.renderContents()
开发者ID:hrayr-artunyan,项目名称:shuup,代码行数:14,代码来源:test_checkout_flow.py


示例14: test_basic_order_flow

def test_basic_order_flow(with_company):
    create_default_order_statuses()
    n_orders_pre = Order.objects.count()
    populate_if_required()
    c = SmartClient()
    product_ids = _populate_client_basket(c)

    addresses_path = reverse("shuup:checkout", kwargs={"phase": "addresses"})
    addresses_soup = c.soup(addresses_path)
    inputs = fill_address_inputs(addresses_soup, with_company=with_company)
    response = c.post(addresses_path, data=inputs)
    assert response.status_code == 302  # Should redirect forth

    methods_path = reverse("shuup:checkout", kwargs={"phase": "methods"})
    methods_soup = c.soup(methods_path)
    assert c.post(methods_path, data=extract_form_fields(methods_soup)).status_code == 302  # Should redirect forth

    confirm_path = reverse("shuup:checkout", kwargs={"phase": "confirm"})
    confirm_soup = c.soup(confirm_path)
    Product.objects.get(pk=product_ids[0]).soft_delete()
    assert c.post(confirm_path, data=extract_form_fields(confirm_soup)).status_code == 200  # user needs to reconfirm
    data = extract_form_fields(confirm_soup)
    data['product_ids'] = ','.join(product_ids[1:])
    assert c.post(confirm_path, data=data).status_code == 302  # Should redirect forth

    n_orders_post = Order.objects.count()
    assert n_orders_post > n_orders_pre, "order was created"
开发者ID:hrayr-artunyan,项目名称:shuup,代码行数:27,代码来源:test_checkout_flow.py


示例15: test_shop_available_languages

def test_shop_available_languages(admin_user):
    original_language = get_language()
    shop = factories.get_default_shop()
    client = SmartClient()

    with override_settings(
        LANGUAGES=[
            ("it", "Italian"),
            ("fr", "French"),
            ("fi", "Finnish"),
            ("pt", "Portuguese")
        ],
        LANGUAGE_CODE="it",
        PARLER_DEFAULT_LANGUAGE_CODE = "it"
    ):
        # there is no language set for the shop, the first one will be used
        response = client.get(reverse("shuup:index"))
        assert get_language() == "it"

        # set an invalid language code
        with pytest.raises(ValueError):
            set_shop_available_languages(shop, ["xpto"])

        # limit the langauges for the shop to "fi" and "pt"
        set_shop_available_languages(shop, ["fi", "pt"])

        # the middleware will automatically set the language to "fi" as that is the first one available for the shop
        response = client.get(reverse("shuup:index"))
        assert get_language() == "fi"

        # the same won't happen for any other url - the middleware will only affect front urls
        client.get("shuup_admin:index")
        assert get_language() == "it"

        # test againt front again
        client.get(reverse("shuup:index"))
        assert get_language() == "fi"

        # again for admin
        client.get("shuup_admin:index")
        assert get_language() == "it"

        # remote all available languages
        set_shop_available_languages(shop, [])
        # this should fallback to settings.LAGUAGE_CODE
        response = client.get(reverse("shuup:index"))
        assert get_language() == "it"

    activate(original_language)
开发者ID:ruqaiya,项目名称:shuup,代码行数:49,代码来源:test_languages.py


示例16: test_notify_on_company_created

def test_notify_on_company_created(regular_user, allow_company_registration):
    if "shuup.front.apps.customer_information" not in settings.INSTALLED_APPS:
        pytest.skip("shuup.front.apps.customer_information required in installed apps")
    if "shuup.notify" not in settings.INSTALLED_APPS:
        pytest.skip("shuup.notify required in installed apps")

    configuration.set(None, "allow_company_registration", allow_company_registration)
    step = Step(
        cond_op=StepConditionOperator.NONE,
        actions=[
            AddNotification({
                "message": {"constant": "It Works. {{ customer_email }}"},
                "message_identifier": {"constant": "company_created"},
            })
        ],
        next=StepNext.STOP
    )
    script = Script(
        event_identifier=CompanyAccountCreated.identifier, name="Test Script", enabled=True, shop=get_default_shop())
    script.set_steps([step])
    script.save()

    assert not Notification.objects.filter(identifier="company_created").exists()

    assert get_person_contact(regular_user)
    assert not get_company_contact(regular_user)

    client = SmartClient()
    client.login(username=REGULAR_USER_USERNAME, password=REGULAR_USER_PASSWORD)
    company_edit_url = reverse("shuup:company_edit")

    if allow_company_registration:
        client.soup(company_edit_url)

        data = _default_company_data()
        data.update(_default_address_data("billing"))
        data.update(_default_address_data("shipping"))

        response, soup = client.response_and_soup(company_edit_url, data, "post")

        assert response.status_code == 302
        assert get_company_contact(regular_user)
        assert Notification.objects.filter(identifier="company_created").count() == 1
        notification = Notification.objects.filter(identifier="company_created").first()
        assert notification
        assert data["contact-email"] in notification.message

        # New save should not add new notifications
        response, soup = client.response_and_soup(company_edit_url, data, "post")
        assert response.status_code == 302
        assert Notification.objects.filter(identifier="company_created").count() == 1
        script.delete()
    else:
        response = client.get(company_edit_url)
        assert reverse("shuup:customer_edit") in response.url
        assert Notification.objects.filter(identifier="company_created").count() == 0
开发者ID:ruqaiya,项目名称:shuup,代码行数:56,代码来源:test_notify_on_company_created.py


示例17: test_user_change_password

def test_user_change_password(regular_user, password_value, new_password_2, expected):
    get_default_shop()
    assert check_password(REGULAR_USER_PASSWORD, regular_user.password)

    client = SmartClient()
    client.login(username=REGULAR_USER_USERNAME, password=REGULAR_USER_PASSWORD)
    change_password_url = reverse("shuup:change_password")

    new_password = "12345"
    data = {"old_password": password_value, "new_password1": new_password, "new_password2": new_password_2}

    response, soup = client.response_and_soup(change_password_url, data, "post")
    user = get_user_model().objects.get(pk=regular_user.pk)
    assert regular_user == user

    assert check_password(REGULAR_USER_PASSWORD, user.password) != expected
    assert check_password(new_password, user.password) == expected
开发者ID:shawnadelic,项目名称:shuup,代码行数:17,代码来源:test_customer_information.py


示例18: test_resource_injection

def test_resource_injection(client):
    """
    Test that the GDPR warning is injected into the front template when enabled
    """
    activate("en")
    shop = factories.get_default_shop()
    client = SmartClient()
    index_url = reverse("shuup:index")
    response = client.get(index_url)
    assert "gdpr-consent-warn-bar" not in response.content.decode("utf-8")

    # create a GDPR setting for the shop
    shop_gdpr = GDPRSettings.get_for_shop(shop)
    shop_gdpr.cookie_banner_content = "my cookie banner content"
    shop_gdpr.cookie_privacy_excerpt = " my cookie privacyexcerpt"
    shop_gdpr.enabled = True
    shop_gdpr.save()

    # the contents should be injected in the html
    response = client.get(index_url)
    response_content = response.content.decode("utf-8")
    assert "gdpr-consent-warn-bar" in response_content
    assert shop_gdpr.cookie_banner_content in response_content
    assert shop_gdpr.cookie_privacy_excerpt in response_content

    # create cookie categories
    cookie_category = GDPRCookieCategory.objects.create(
        shop=shop,
        always_active=True,
        cookies="cookie1,cookie2,_cookie3",
        name="RequiredCookies",
        how_is_used="to make the site work"
    )
    response = client.get(index_url)
    response_content = response.content.decode("utf-8")
    assert "gdpr-consent-warn-bar" in response_content
    assert cookie_category.cookies in response_content
    assert cookie_category.name in response_content
    assert cookie_category.how_is_used in response_content

    # make sure no other shop has this
    with override_settings(SHUUP_ENABLE_MULTIPLE_SHOPS=True):
        shop2 = factories.get_shop(identifier="shop2", status=ShopStatus.DISABLED, domain="shop2")
        response = client.get(index_url, HTTP_HOST=shop2.domain)
        response_content = response.content.decode("utf-8")
        assert "gdpr-consent-warn-bar" not in response_content
开发者ID:ruqaiya,项目名称:shuup,代码行数:46,代码来源:test_consent_resource.py


示例19: test_company_edit_form_links_company

def test_company_edit_form_links_company(regular_user, rf):
    get_default_shop()
    person = get_person_contact(regular_user)
    assert not get_company_contact(regular_user)

    client = SmartClient()
    client.login(username=REGULAR_USER_USERNAME, password=REGULAR_USER_PASSWORD)
    company_edit_url = reverse("shuup:company_edit")
    soup = client.soup(company_edit_url)

    data = default_company_data()
    data.update(default_address_data("billing"))
    data.update(default_address_data("shipping"))

    response, soup = client.response_and_soup(company_edit_url, data, "post")

    assert response.status_code == 302
    assert get_company_contact(regular_user)
开发者ID:ahmadzai,项目名称:shuup,代码行数:18,代码来源:test_customer_information.py


示例20: test_download_examples

def test_download_examples(rf, admin_user):
    shop = get_default_shop()
    import_url = reverse("shuup_admin:importer.import")

    shop.staff_members.add(admin_user)
    client = SmartClient()
    client.login(username="admin", password="password")

    # test downloading all default importers
    from shuup.importer.utils import get_importer, get_importer_choices

    assert len(get_importer_choices())
    for importer, name in get_importer_choices():
        importer_cls = get_importer(importer)

        if importer_cls.has_example_file():
            import_response = client.get("{}?importer={}".format(import_url, importer_cls.identifier))
            assert import_response.status_code == 200
            assert "This importer provides example files" in import_response.content.decode("utf-8")

            for example_file in importer_cls.example_files:
                assert example_file.file_name in import_response.content.decode("utf-8")

                # download file
                download_url = "{}?importer={}&file_name={}".format(
                    reverse("shuup_admin:importer.download_example"),
                    importer_cls.identifier,
                    example_file.file_name
                )
                response = client.get(download_url)

                if importer_cls.identifier == "dummy_file_importer":
                    assert response.status_code == 404
                else:
                    assert response.status_code == 200
                    assert response._headers["content-type"] == ("Content-Type", str(example_file.content_type))
                    assert response._headers["content-disposition"] == ("Content-Disposition", 'attachment; filename=%s' % example_file.file_name)

                    if example_file.template_name:
                        from django.template.loader import get_template
                        template_file = get_template(example_file.template_name).template.filename
                        assert open(template_file, "r").read().strip() == response.content.decode("utf-8").strip()
                    else:
                        assert response.content
开发者ID:ruqaiya,项目名称:shuup,代码行数:44,代码来源:test_admin.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python basketish_order_source.BasketishOrderSource类代码示例发布时间: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