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


Python SmartClient.soup方法代码示例

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


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

示例1: test_basic_order_flow

# 需要导入模块: from shuup_tests.utils import SmartClient [as 别名]
# 或者: from shuup_tests.utils.SmartClient import soup [as 别名]
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,代码行数:29,代码来源:test_checkout_flow.py

示例2: test_notify_on_company_created

# 需要导入模块: from shuup_tests.utils import SmartClient [as 别名]
# 或者: from shuup_tests.utils.SmartClient import soup [as 别名]
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,代码行数:58,代码来源:test_notify_on_company_created.py

示例3: test_company_tax_number_limitations

# 需要导入模块: from shuup_tests.utils import SmartClient [as 别名]
# 或者: from shuup_tests.utils.SmartClient import soup [as 别名]
def test_company_tax_number_limitations(regular_user):
    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)

    # re-save should work properly
    response, soup = client.response_and_soup(company_edit_url, data, "post")
    assert response.status_code == 302
    client.logout()

    # another company tries to use same tax number
    new_user_password = "derpy"
    new_user_username = "derpy"
    user = User.objects.create_user(new_user_username, "[email protected]", new_user_password)
    person = get_person_contact(user=user)
    assert not get_company_contact(user)

    client = SmartClient()
    client.login(username=new_user_username, password=new_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 == 200  # this time around, nothing was saved.
    assert not get_company_contact(user)  # company contact yet

    # change tax number
    data["contact-tax_number"] = "111111"
    response, soup = client.response_and_soup(company_edit_url, data, "post")
    assert response.status_code == 302  # this time around, nothing was saved.
    assert get_company_contact(user)  # company contact yet

    # go back to normal and try to get tax number approved
    data["contact-tax_number"] = "111110"
    response, soup = client.response_and_soup(company_edit_url, data, "post")
    assert response.status_code == 200  # this time around, nothing was saved.
开发者ID:shawnadelic,项目名称:shuup,代码行数:56,代码来源:test_customer_information.py

示例4: test_basic_order_flow_registered

# 需要导入模块: from shuup_tests.utils import SmartClient [as 别名]
# 或者: from shuup_tests.utils.SmartClient import soup [as 别名]
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,代码行数:56,代码来源:test_order_notifications.py

示例5: test_theme_without_default_template_dir

# 需要导入模块: from shuup_tests.utils import SmartClient [as 别名]
# 或者: from shuup_tests.utils.SmartClient import soup [as 别名]
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,代码行数:9,代码来源:test_default_template_dir.py

示例6: test_theme_with_default_template_dir

# 需要导入模块: from shuup_tests.utils import SmartClient [as 别名]
# 或者: from shuup_tests.utils.SmartClient import soup [as 别名]
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,代码行数:9,代码来源:test_default_template_dir.py

示例7: test_extender_renders_main_menu

# 需要导入模块: from shuup_tests.utils import SmartClient [as 别名]
# 或者: from shuup_tests.utils.SmartClient import soup [as 别名]
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,代码行数:10,代码来源:test_extenders.py

示例8: test_basic_order_flow

# 需要导入模块: from shuup_tests.utils import SmartClient [as 别名]
# 或者: from shuup_tests.utils.SmartClient import soup [as 别名]
def test_basic_order_flow(with_company, with_signal):
    cache.clear()
    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

    # Make sure the address is initialized from storage
    # Go back to addresses right before back to methods
    c.soup(addresses_path)

    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

    if with_signal:
        checkout_complete.connect(checkout_complete_signal, dispatch_uid="checkout_complete_signal")

    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"

    order = Order.objects.first()
    expected_ip = "127.0.0.2" if with_signal else "127.0.0.1"
    assert order.ip_address == expected_ip

    if with_signal:
        checkout_complete.disconnect(dispatch_uid="checkout_complete_signal")
开发者ID:ruqaiya,项目名称:shuup,代码行数:44,代码来源:test_checkout_flow.py

示例9: test_page_layout

# 需要导入模块: from shuup_tests.utils import SmartClient [as 别名]
# 或者: from shuup_tests.utils.SmartClient import soup [as 别名]
def test_page_layout():
    if "shuup.xtheme" not in settings.INSTALLED_APPS:
        pytest.skip("Need shuup.xtheme in INSTALLED_APPS")

    shop = factories.get_default_shop()
    theme = get_current_theme(shop)
    view_config = ViewConfig(theme=theme, shop=shop, view_name="PageView", draft=True)
    page1_content = printable_gibberish()
    page1 = create_page(available_from=datetime.date(1917, 12, 6), content=page1_content, shop=shop, url="test1")
    page2_content = printable_gibberish()
    page2 = create_page(available_from=datetime.date(1917, 12, 6), content=page2_content, shop=shop, url="test2")

    placeholder_name = "cms_page"
    context = {"page": page1}
    layout = view_config.get_placeholder_layout(PageLayout, placeholder_name, context=context)
    assert isinstance(layout, PageLayout)
    assert layout.get_help_text({}) == ""  # Invalid context for help text
    assert page1.title in layout.get_help_text(context)

    # Make sure layout is empty
    serialized = layout.serialize()
    assert len(serialized["rows"]) == 0
    assert serialized["name"] == placeholder_name

    # Add custom plugin to page
    layout.begin_column({"md": 8})
    plugin_text = printable_gibberish()
    layout.add_plugin("text", {"text": plugin_text})
    view_config.save_placeholder_layout(get_layout_data_key(placeholder_name, layout, context), layout)
    view_config.publish()

    c = SmartClient()
    soup = c.soup(reverse("shuup:cms_page", kwargs={"url": page1.url}))
    page_content = soup.find("div", {"class": "page-content"})
    assert page1_content in page_content.text
    assert plugin_text in page_content.text

    c = SmartClient()
    soup = c.soup(reverse("shuup:cms_page", kwargs={"url": page2.url}))
    page_content = soup.find("div", {"class": "page-content"})
    assert page2_content in page_content.text
    assert plugin_text not in page_content.text
开发者ID:ruqaiya,项目名称:shuup,代码行数:44,代码来源:test_xtheme_layout.py

示例10: test_product_detail_view

# 需要导入模块: from shuup_tests.utils import SmartClient [as 别名]
# 或者: from shuup_tests.utils.SmartClient import soup [as 别名]
def test_product_detail_view():
    vc = _get_basic_view_config(view_name="ProductDetailView")
    product = factories.create_product("test", shop=factories.get_default_shop(), name="Test product name")
    product2 = factories.create_product("test2", shop=factories.get_default_shop(), name="Test product name 2")
    placeholder_name = "product_extra_1"
    context = {"product": product}
    layout = vc.get_placeholder_layout(ProductLayout, placeholder_name, context=context)
    plugin_text = printable_gibberish()
    _add_plugin_and_test_save(vc, layout, placeholder_name, context, plugin_text)

    # Also let's confirm that the plugin visibility works with smart client
    c = SmartClient()
    soup = c.soup(reverse("shuup:product", kwargs={"pk": product.id, "slug": product.slug}))
    product_details = soup.find("div", {"class": "product-basic-details"})
    assert plugin_text in product_details.text

    c = SmartClient()
    soup = c.soup(reverse("shuup:product", kwargs={"pk": product2.id, "slug": product2.slug}))
    product_details = soup.find("div", {"class": "product-basic-details"})
    assert plugin_text not in product_details.text
开发者ID:ruqaiya,项目名称:shuup,代码行数:22,代码来源:test_custom_layouts.py

示例11: test_new_shop

# 需要导入模块: from shuup_tests.utils import SmartClient [as 别名]
# 或者: from shuup_tests.utils.SmartClient import soup [as 别名]
def test_new_shop(rf, admin_user):
    with override_settings(SHUUP_ENABLE_MULTIPLE_SHOPS=True):
        get_default_shop()
        assert Shop.objects.count() == 1

        client = SmartClient()
        client.login(username="admin", password="password")
        client.soup(reverse("shuup_admin:shop.new"))
        payload = {
            "base-public_name__en": "New Shop",
            "base-name__en": "New Shop",
            "base-status": "1",
            "base-currency": "EUR",
            "base-domain": "shop2"
        }
        response = client.post(reverse("shuup_admin:shop.new"), data=payload)
        assert response.status_code == 302
        assert Shop.objects.count() == 2
        shop = Shop.objects.last()
        assert shop.name == "New Shop"
        assert shop.domain == "shop2"
开发者ID:ruqaiya,项目名称:shuup,代码行数:23,代码来源:test_shop_edit.py

示例12: test_gdpr_admin_settings

# 需要导入模块: from shuup_tests.utils import SmartClient [as 别名]
# 或者: from shuup_tests.utils.SmartClient import soup [as 别名]
def test_gdpr_admin_settings(client, admin_user):
    """
    Test that admin user can enable GDPR and add cookie categories
    """
    activate("en")
    shop = factories.get_default_shop()
    client = SmartClient()
    admin_user.set_password("admin")
    admin_user.save()
    client.login(username=admin_user.username, password="admin")
    admin_settings_url = reverse("shuup_admin:gdpr.settings")

    assert not GDPRSettings.objects.exists()
    response = client.soup(admin_settings_url)
    assert GDPRSettings.objects.exists()
    s = GDPRSettings.objects.first()
    assert s.cookie_banner_content == settings.SHUUP_GDPR_DEFAULT_BANNER_STRING
    assert s.cookie_privacy_excerpt == settings.SHUUP_GDPR_DEFAULT_EXCERPT_STRING
    assert GDPRCookieCategory.objects.count() == 0

    page = Page.objects.create(shop=shop, available_from=now())
    page.title = "test"
    page.save()
    # create the settings with only basic options
    payload = extract_form_fields(response)
    payload.update({
        "base-enabled": True,
        "base-privacy_policy_page": page.pk,
        "base-cookie_banner_content__en": "Banner content",
        "base-cookie_privacy_excerpt__en": "Cookie excerpt",
        "cookie_categories-0-id": "",
        "cookie_categories-0-always_active": 1,
        "cookie_categories-0-name__en": "required",
        "cookie_categories-0-how_is_used__en": "to work",
        "cookie_categories-0-cookies": "sessionid"
    })
    response = client.post(admin_settings_url, data=payload)
    assert response.status_code == 302

    assert GDPRCookieCategory.objects.count() == 1

    # add one more cookie category
    payload.update({
        "cookie_categories-1-id": "",
        "cookie_categories-1-always_active": 1,
        "cookie_categories-1-name__en": "Maybe",
        "cookie_categories-1-how_is_used__en": "to spy",
        "cookie_categories-1-cookies": "_ga"
    })
    client.post(admin_settings_url, data=payload)
    assert GDPRCookieCategory.objects.count() == 2
开发者ID:ruqaiya,项目名称:shuup,代码行数:53,代码来源:test_admin_module.py

示例13: test_product_view_prices_and_basket_visibility

# 需要导入模块: from shuup_tests.utils import SmartClient [as 别名]
# 或者: from shuup_tests.utils.SmartClient import soup [as 别名]
def test_product_view_prices_and_basket_visibility(rf):
    activate("en")
    product_sku = "test-123"
    shop = factories.get_default_shop()
    supplier = factories.get_default_supplier()
    default_price = 11
    product = factories.create_product(product_sku, shop=shop, supplier=supplier, default_price=default_price)

    assert ThemeSettings.objects.count() == 1
    theme_settings = ThemeSettings.objects.first()
    assert theme_settings.shop == shop
    assert theme_settings.theme_identifier == ClassicGrayTheme.identifier

    assert not theme_settings.get_setting("hide_prices")
    assert not theme_settings.get_setting("catalog_mode")

    with override_current_theme_class(ClassicGrayTheme, shop):  # Ensure settings is refreshed from DB
        c = SmartClient()
        soup = c.soup(reverse("shuup:product", kwargs={"pk": product.pk, "slug": product.slug}))
        assert _is_basket_in_soup(soup)
        assert _is_price_in_soup(soup, default_price)
        assert _is_add_to_basket_button_in_soup(soup)

    theme_settings.update_settings({"catalog_mode": True})
    with override_current_theme_class(ClassicGrayTheme, shop):  # Ensure settings is refreshed from DB
        c = SmartClient()
        soup = c.soup(reverse("shuup:product", kwargs={"pk": product.pk, "slug": product.slug}))
        assert not _is_basket_in_soup(soup)
        assert not _is_add_to_basket_button_in_soup(soup)
        assert _is_price_in_soup(soup, default_price)

    theme_settings.update_settings({"hide_prices": True, "catalog_mode": False})
    with override_current_theme_class(ClassicGrayTheme, shop):  # Ensure settings is refreshed from DB
        c = SmartClient()
        soup = c.soup(reverse("shuup:product", kwargs={"pk": product.pk, "slug": product.slug}))
        assert not _is_add_to_basket_button_in_soup(soup)
        assert not _is_basket_in_soup(soup)
        assert not _is_price_in_soup(soup, default_price)
开发者ID:ruqaiya,项目名称:shuup,代码行数:40,代码来源:test_hide_prices_and_catalog_mode.py

示例14: test_theme_with_default_template_dir

# 需要导入模块: from shuup_tests.utils import SmartClient [as 别名]
# 或者: from shuup_tests.utils.SmartClient import soup [as 别名]
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,代码行数:16,代码来源:test_default_template_dir.py

示例15: test_checkout_empty_basket

# 需要导入模块: from shuup_tests.utils import SmartClient [as 别名]
# 或者: from shuup_tests.utils.SmartClient import soup [as 别名]
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,代码行数:16,代码来源:test_checkout_flow.py


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