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


Python module_registry.replace_modules函数代码示例

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


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

示例1: test_permission_group_form_updates_members

def test_permission_group_form_updates_members(regular_user):
    with replace_modules([ARestrictedTestModule]):
        modules = [m for m in get_modules()]
        test_module = modules[0]
        module_permissions = test_module.get_required_permissions()

        assert module_permissions

        group = get_default_permission_group()
        form = PermissionGroupForm(instance=group, prefix=None)

        assert not group.permissions.all()
        assert not group.user_set.all()

        data = {
            "name": "New Name",
            "modules": [force_text(test_module.name)],
            "members": [force_text(regular_user.pk)],
        }

        form = PermissionGroupForm(instance=group, prefix=None, data=data)
        form.save()

        module_permissions = [get_permission_object_from_string(m) for m in module_permissions]
        assert group.name == "New Name"
        assert set(module_permissions) == set(group.permissions.all())
        assert regular_user in group.user_set.all()

        form = PermissionGroupForm(instance=group, prefix=None, data={"name": "Name"})
        form.save()

        assert not group.permissions.all()
        assert not group.user_set.all()
开发者ID:monokrome,项目名称:shuup,代码行数:33,代码来源:test_permission_groups_module.py

示例2: test_dashboard_blocks

def test_dashboard_blocks(rf):
    request = rf.get("/")
    with replace_modules([TestModule]):
        block_ids = set()
        for block in chain(*(m.get_dashboard_blocks(request) for m in get_modules())):
            block_ids.add(block.id)
        assert block_ids >= set(["test-0", "test-1", "test-2", "test-3", "test-4"])
开发者ID:taedori81,项目名称:shoop,代码行数:7,代码来源:test_modules.py

示例3: test_url_auth

def test_url_auth(rf):
    def did_disallow(view, request):
        try:
            return isinstance(view(request), HttpResponseRedirect)
        except Problem as prob:
            return True  # Problems are fine here

    with replace_modules([TestModule]):
        urls = dict((u.name, u) for u in get_module_urls())
        request = rf.get("/")

        request.user = AnonymousUser()
        assert did_disallow(urls["test-auth"].callback, request)
        assert did_disallow(urls["test-perm"].callback, request)
        assert not did_disallow(urls["test-unauth"].callback, request)
        request.user = AuthenticatedUser()
        assert did_disallow(urls["test-auth"].callback, request)
        assert did_disallow(urls["test-perm"].callback, request)
        assert not did_disallow(urls["test-unauth"].callback, request)
        request.user = StaffUser()
        assert not did_disallow(urls["test-auth"].callback, request)
        assert did_disallow(urls["test-perm"].callback, request)
        assert not did_disallow(urls["test-unauth"].callback, request)
        request.user = SuperUser()
        assert not did_disallow(urls["test-auth"].callback, request)
        assert not did_disallow(urls["test-perm"].callback, request)
        assert not did_disallow(urls["test-unauth"].callback, request)
开发者ID:taedori81,项目名称:shoop,代码行数:27,代码来源:test_modules.py

示例4: test_modules_in_core_admin_work

def test_modules_in_core_admin_work(rf, admin_user):
    get_default_shop()
    request = rf.get("/")
    apply_request_middleware(request, user=admin_user)
    request = apply_request_middleware(rf.get("/"), user=admin_user)
    with replace_modules(ShoopAdminAppConfig.provides["admin_module"]):
        assert all(get_module_urls())
        assert get_menu_entry_categories(request)
开发者ID:taedori81,项目名称:shoop,代码行数:8,代码来源:test_modules.py

示例5: test_search

def test_search(client, rf):
    if "shoop.guide" not in settings.INSTALLED_APPS:
        pytest.skip("Need shoop.guide in INSTALLED_APPS")
    request = rf.get("/")
    search_term = "customer"
    request.session = client.session
    with replace_modules([GuideAdminModule]):
        with override_settings(SHOOP_GUIDE_FETCH_RESULTS=False):
            results = get_search_results(request, search_term)
            assert [r for r in results if search_term in r.text]
开发者ID:00WhengWheng,项目名称:shuup,代码行数:10,代码来源:test_search_results.py

示例6: test_tax_edit_view_works_at_all

def test_tax_edit_view_works_at_all(rf, admin_user):
    pytest.skip("it doesn't")
    request = rf.get("/")
    request.user = admin_user

    with replace_modules([TaxModule]):
        with admin_only_urls():
            view_func = TaxClassEditView.as_view()
            response = view_func(request, pk=default_tax.pk)
            assert (default_tax.name in response.rendered_content)  # it's probable the name is there
            response = view_func(request, pk=None)  # "new mode"
            assert response.rendered_content  # yeah, something gets rendered
开发者ID:charn,项目名称:shoop,代码行数:12,代码来源:test_tax_module.py

示例7: test_product_edit_view_works_at_all

def test_product_edit_view_works_at_all(rf, admin_user):
    get_default_shop()
    request = apply_request_middleware(rf.get("/"), user=admin_user)

    with replace_modules([ProductModule]):
        with admin_only_urls():
            default_product = get_default_product()
            view_func = ProductEditView.as_view()
            response = view_func(request, pk=default_product.pk)
            assert (default_product.sku in response.rendered_content)  # it's probable the SKU is there
            response = view_func(request, pk=None)  # "new mode"
            assert response.rendered_content  # yeah, something gets rendered
开发者ID:charn,项目名称:shoop,代码行数:12,代码来源:test_product_module.py

示例8: test_product_module_search

def test_product_module_search(rf, admin_user):
    get_default_shop()
    request = apply_request_middleware(rf.get("/"), user=admin_user)

    with replace_modules([ProductModule]):
        with admin_only_urls():
            default_product = get_default_product()
            model_url = get_model_url(default_product)
            sku = default_product.sku
            assert any(sr.url == model_url for sr in get_search_results(request, query=sku))  # Queries work
            assert any(sr.is_action for sr in get_search_results(request, query=sku[:5]))  # Actions work
            assert empty_iterable(get_search_results(request, query=sku[:2]))  # Short queries don't
开发者ID:charn,项目名称:shoop,代码行数:12,代码来源:test_product_module.py

示例9: test_product_edit_view_with_params

def test_product_edit_view_with_params(rf, admin_user):
    get_default_shop()
    sku = "test-sku"
    name = "test name"
    request = apply_request_middleware(rf.get("/", {"name": name, "sku": sku}), user=admin_user)

    with replace_modules([ProductModule]):
        with admin_only_urls():
            view_func = ProductEditView.as_view()
            response = view_func(request)
            assert (sku in response.rendered_content)  # it's probable the SKU is there
            assert (name in response.rendered_content)  # it's probable the name is there
开发者ID:shaan360,项目名称:shoop,代码行数:12,代码来源:test_product_module.py

示例10: test_product_edit_view_works_at_all

def test_product_edit_view_works_at_all(rf, admin_user):
    shop = get_default_shop()
    product = create_product("test-product", shop, default_price=200)
    shop_product = product.get_shop_instance(shop)
    shop_product.visibility_limit = ProductVisibility.VISIBLE_TO_GROUPS
    shop_product.save()
    request = apply_request_middleware(rf.get("/"), user=admin_user)

    with replace_modules([ProductModule]):
        with admin_only_urls():
            view_func = ProductEditView.as_view()
            response = view_func(request, pk=product.pk)
            assert (product.sku in response.rendered_content)  # it's probable the SKU is there
            response = view_func(request, pk=None)  # "new mode"
            assert response.rendered_content  # yeah, something gets rendered
开发者ID:shaan360,项目名称:shoop,代码行数:15,代码来源:test_product_module.py

示例11: test_tax_edit_view_works_at_all

def test_tax_edit_view_works_at_all(rf, admin_user):
    get_default_shop()  # We need a shop to exists
    request = apply_request_middleware(rf.get("/"))
    request.user = admin_user

    default_tax_class = get_default_tax_class()

    with replace_modules([TaxModule]):
        with admin_only_urls():
            view_func = TaxClassEditView.as_view()
            response = view_func(request, pk=default_tax_class.pk)
            response.render()
            assert (default_tax_class.name in force_text(response.content))
            response = view_func(request, pk=None)  # "new mode"
            response.render()
            assert response.content
开发者ID:taedori81,项目名称:shoop,代码行数:16,代码来源:test_tax_module.py

示例12: test_permissions_for_menu_entries

def test_permissions_for_menu_entries(rf, admin_user):
    permissions = set(["shoop.add_product", "shoop.delete_product", "shoop.change_product"])

    request = rf.get("/")
    request.user = StaffUser()
    request.user.permissions = permissions

    with replace_modules([ARestrictedTestModule]):
        modules = [m for m in get_modules()]
        assert request.user.permissions == modules[0].get_required_permissions()

        categories = get_menu_entry_categories(request)
        assert categories

        # Make sure category is displayed if user has correct permissions
        test_category_menu_entries = categories.get("RestrictedTest")
        assert any(me.text == "OK" for me in test_category_menu_entries)

        # No menu items should be displayed if user has no permissions
        request.user.permissions = []
        categories = get_menu_entry_categories(request)
        assert not categories
开发者ID:monokrome,项目名称:shuup,代码行数:22,代码来源:test_permissions.py

示例13: test_url_auth

def test_url_auth(rf):
    def did_redirect(view, request):
        return isinstance(view(request), HttpResponseRedirect)

    with replace_modules([TestModule]):
        urls = dict((u.name, u) for u in get_module_urls())
        request = rf.get("/")

        request.user = AnonymousUser()
        assert did_redirect(urls["test-auth"].callback, request)
        assert did_redirect(urls["test-perm"].callback, request)
        assert not did_redirect(urls["test-unauth"].callback, request)
        request.user = AuthenticatedUser()
        assert did_redirect(urls["test-auth"].callback, request)
        assert did_redirect(urls["test-perm"].callback, request)
        assert not did_redirect(urls["test-unauth"].callback, request)
        request.user = StaffUser()
        assert not did_redirect(urls["test-auth"].callback, request)
        assert did_redirect(urls["test-perm"].callback, request)
        assert not did_redirect(urls["test-unauth"].callback, request)
        request.user = SuperUser()
        assert not did_redirect(urls["test-auth"].callback, request)
        assert not did_redirect(urls["test-perm"].callback, request)
        assert not did_redirect(urls["test-unauth"].callback, request)
开发者ID:charn,项目名称:shoop,代码行数:24,代码来源:test_modules.py

示例14: test_menu_entries

def test_menu_entries(rf):
    request = rf.get("/")
    with replace_modules([TestModule]):
        test_category_menu_entries = get_menu_entry_categories(request).get("Test")
        assert any(me.text == "OK" for me in test_category_menu_entries)
开发者ID:taedori81,项目名称:shoop,代码行数:5,代码来源:test_modules.py

示例15: test_notifications

def test_notifications(rf):
    request = rf.get("/")
    with replace_modules([TestModule]):
        assert any(n.text == "OK" for n in chain(*(m.get_notifications(request) for m in get_modules())))
开发者ID:taedori81,项目名称:shoop,代码行数:4,代码来源:test_modules.py


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