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


Python testing.override_current_theme_class函数代码示例

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


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

示例1: 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

示例2: pytest_runtest_call

def pytest_runtest_call(item):
    # All tests are run with a theme override `shuup.themes.classic_gray.ClassicGrayTheme`.
    # To un-override, use `with override_current_theme_class()` (no arguments to re-enable database lookup)
    from shuup.themes.classic_gray.theme import ClassicGrayTheme

    item.session._theme_overrider = override_current_theme_class(ClassicGrayTheme)
    item.session._theme_overrider.__enter__()
开发者ID:suutari,项目名称:shoop,代码行数:7,代码来源:conftest.py

示例3: test_rendering

def test_rendering(edit, injectable, theme_class, global_type):
    request = get_request(edit)
    request.resolver_match = mock.Mock()
    request.resolver_match.app_name = "shuup"

    with override_current_theme_class(theme_class):
        with plugin_override():
            jeng = get_jinja2_engine()
            if global_type:
                template = jeng.get_template("global_complex.jinja")
            else:
                template = jeng.get_template("complex.jinja")
            view = FauxView()
            view.xtheme_injection = bool(injectable)
            output = template.render(context={
                "view": view,
                "request": request
            }, request=request)

            # From now on we render placholders in views that
            # actually can be edited.
            if injectable and theme_class:
                assert "wider column" in output
                assert "less wide column" in output

            if edit and injectable and theme_class:
                assert "xt-ph-edit" in output
                assert "data-xt-placeholder-name" in output
                assert "data-xt-row" in output
                assert "data-xt-cell" in output
                assert "XthemeEditorConfig" in output
开发者ID:ruqaiya,项目名称:shuup,代码行数:31,代码来源:test_rendering.py

示例4: 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

示例5: test_layout_edit_render

def test_layout_edit_render():
    request = get_request(edit=True)
    with override_current_theme_class(None):
        with plugin_override():
            (template, layout, gibberish, ctx) = get_test_template_bits(request)
            result = six.text_type(render_placeholder(ctx, "test", layout, "test"))
            # Look for evidence of editing:
            assert "xt-ph-edit" in result
            assert "data-xt-placeholder-name" in result
            assert "data-xt-row" in result
            assert "data-xt-cell" in result
开发者ID:ruqaiya,项目名称:shuup,代码行数:11,代码来源:test_layout.py

示例6: test_xtheme_extra_views

def test_xtheme_extra_views(rf):
    with override_current_theme_class(H2G2Theme):
        request = rf.get("/", {"name": "Arthur Dent"})
        # Simulate /xtheme/greeting
        response = extra_view_dispatch(request, "greeting")
        assert force_text(response.content) == "So long, and thanks for all the fish, Arthur Dent"
        # Try that again (to exercise the _VIEW_CACHE code path):
        response = extra_view_dispatch(request, "greeting")
        assert force_text(response.content) == "So long, and thanks for all the fish, Arthur Dent"
        # Now test that CBVs work
        assert not extra_view_dispatch(request, "faux").content
开发者ID:shawnadelic,项目名称:shuup,代码行数:11,代码来源:test_extra_views.py

示例7: test_product_detail_theme_configs

def test_product_detail_theme_configs(client):
    shop = factories.get_default_shop()
    product = factories.create_product("sku", shop=shop, default_price=30)

    # Show only product description section
    assert ThemeSettings.objects.count() == 1
    theme_settings = ThemeSettings.objects.first()
    theme_settings.update_settings({"product_detail_tabs": ["description"]})

    with override_current_theme_class(ClassicGrayTheme, shop):  # Ensure settings is refreshed from DB
        soup = _get_product_detail_soup(client, product)
        assert soup.find("div", attrs={"class": "product-tabs"})
        tabs = soup.find_all("ul", attrs={"class": "nav-tabs"})[0].find_all("li")
        assert len(tabs) == 1
        assert "Description" in tabs[0].text

    # disable product details completely
    theme_settings.update_settings({"show_product_detail_section": False})
    with override_current_theme_class(ClassicGrayTheme, shop):
        soup = _get_product_detail_soup(client, product)
        assert not soup.find("div", attrs={"class": "product-tabs"})
开发者ID:ruqaiya,项目名称:shuup,代码行数:21,代码来源:test_product_detail_theme_settings.py

示例8: test_simple_addon_injection

def test_simple_addon_injection():
    request = get_request(edit=False)
    jeng = get_jinja2_engine()
    template = jeng.get_template("resinject.jinja")

    with override_current_theme_class():
        with override_provides(
                "xtheme_resource_injection", ["shuup_tests.xtheme.test_addon_injections:add_test_injection",]):
            # TestInjector should add alert to end of the body for every request
            output = template.render(request=request)
            head, body = output.split("</head>", 1)
            assert "window.injectedFromAddon=true;" in body
开发者ID:gurch101,项目名称:shuup,代码行数:12,代码来源:test_addon_injections.py

示例9: test_view_config_caches_into_context

def test_view_config_caches_into_context(rf):
    # This is a silly test...
    request = get_request(edit=False)
    with override_current_theme_class(None):
        (template, layout, gibberish, ctx) = get_test_template_bits(request)
        cfg1 = get_view_config(ctx)
        cfg2 = get_view_config(ctx)
        assert cfg1 is cfg2
        (template, layout, gibberish, ctx) = get_test_template_bits(request, False)
        cfg1 = get_view_config(ctx)
        cfg2 = get_view_config(ctx)
        assert cfg1 is cfg2
开发者ID:ruqaiya,项目名称:shuup,代码行数:12,代码来源:test_layout.py

示例10: initialize_editor_view

def initialize_editor_view(view_name, placeholder_name, request=None):
    if request is None:
        request = RequestFactory().get("/")
    request.user = SuperUser()
    if hasattr(request.GET, "_mutable"):
        request.GET._mutable = True  # Ahem
    request.GET.update({"theme": FauxTheme.identifier, "view": view_name, "ph": placeholder_name})

    with plugin_override():
        with override_provides("xtheme", ["shuup_tests.xtheme.utils:FauxTheme"]):
            with override_current_theme_class(FauxTheme):
                yield EditorView(request=request, args=(), kwargs={})
开发者ID:shawnadelic,项目名称:shuup,代码行数:12,代码来源:test_editor_view.py

示例11: test_product_view_prices_and_basket_visibility

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,代码行数:38,代码来源:test_hide_prices_and_catalog_mode.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_xtheme_extra_view_exceptions

def test_xtheme_extra_view_exceptions(rf):
    with override_settings(CACHES={
        'default': {
            'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
            'LOCATION': 'test_configuration_cache',
        }
    }):
        cache.init_cache()
        with override_current_theme_class(H2G2Theme, get_default_shop()):
            request = rf.get("/")
            request.shop = get_default_shop()
            assert extra_view_dispatch(request, "vogons").status_code == 404
            with pytest.raises(ImproperlyConfigured):
                assert extra_view_dispatch(request, "true")
开发者ID:ruqaiya,项目名称:shuup,代码行数:14,代码来源:test_extra_views.py

示例14: test_theme_activation

def test_theme_activation():
    with override_current_theme_class():
        with override_provides("xtheme", [
            "shuup_tests.xtheme.utils:FauxTheme",
            "shuup_tests.xtheme.utils:FauxTheme2"
        ]):
            ThemeSettings.objects.all().delete()
            assert not get_current_theme()
            set_current_theme(FauxTheme.identifier)
            assert isinstance(get_current_theme(), FauxTheme)
            set_current_theme(FauxTheme2.identifier)
            assert isinstance(get_current_theme(), FauxTheme2)
            with pytest.raises(ValueError):
                set_current_theme(printable_gibberish())
开发者ID:shawnadelic,项目名称:shuup,代码行数:14,代码来源:test_theme.py

示例15: test_layout_rendering

def test_layout_rendering(rf):
    request = get_request(edit=False)
    with override_current_theme_class(None):
        with plugin_override():
            (template, layout, gibberish, ctx) = get_test_template_bits(request)

            result = six.text_type(render_placeholder(ctx, "test", layout, "test"))
            expect = """
            <div class="xt-ph" id="xt-ph-test">
            <div class="row xt-ph-row">
            <div class="col-md-12 hidden-xs xt-ph-cell"><p>%s</p></div>
            </div>
            </div>
            """ % gibberish
            assert close_enough(result, expect)
开发者ID:hrayr-artunyan,项目名称:shuup,代码行数:15,代码来源:test_layout.py


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