예제 #1
0
def test_browser_config_as_shop_staff(rf):
    shop = factories.get_default_shop()
    staff_user = factories.UserFactory(is_staff=True)
    permission_group = factories.get_default_permission_group()
    staff_user.groups.add(permission_group)
    shop.staff_members.add(staff_user)

    request = apply_request_middleware(rf.post("/"), user=staff_user)
    urls = get_browser_urls(request)
    # staff does not have media permission
    assert urls["media"] is None

    set_permissions_for_group(permission_group, ["media.browse"])
    urls = get_browser_urls(request)
    assert urls["media"] == reverse("shuup_admin:media.browse")

    media_module_permission_urls = set(get_permissions_from_urls(MediaModule().get_urls()))
    assert "media.browse" in media_module_permission_urls
    assert "shuup_admin:media.browse" not in media_module_permission_urls
예제 #2
0
def test_browser_config_as_superuser(rf, admin_user):
    request = apply_request_middleware(rf.post("/"), user=admin_user)
    urls = get_browser_urls(request)
    assert urls["media"] == reverse("shuup_admin:media.browse")