def test_tools_developer_and_admin(self): # Make them a developer. user = self.login('admin', get=True) AddonUser.objects.create(user=user, addon=Addon.objects.all()[0]) response = self.client.get(self.url, follow=True) assert response.status_code == 200 request = response.context['request'] assert request.user.is_developer assert acl.action_allowed(request, amo.permissions.ADDONS_REVIEW) assert acl.action_allowed(request, amo.permissions.LOCALIZER) assert acl.action_allowed(request, amo.permissions.ANY_ADMIN) expected = [ ('Tools', '#'), ('Manage My Submissions', reverse('devhub.addons')), ('Submit a New Add-on', reverse('devhub.submit.agreement')), ('Submit a New Theme', reverse('devhub.themes.submit')), ('Developer Hub', reverse('devhub.index')), ('Manage API Keys', reverse('devhub.api_key')), ('Reviewer Tools', reverse('reviewers.dashboard')), ('Admin Tools', reverse('zadmin.index')), ] check_links( expected, pq(response.content)('#aux-nav .tools a'), verify=False)
def test_tools_developer_and_admin(self): # Make them a developer. user = self.login('admin', get=True) AddonUser.objects.create(user=user, addon=Addon.objects.all()[0]) response = self.client.get(self.url, follow=True) assert response.status_code == 200 request = response.context['request'] assert request.user.is_developer assert acl.action_allowed(request, amo.permissions.ADDONS_REVIEW) assert acl.action_allowed(request, amo.permissions.LOCALIZER) assert acl.action_allowed(request, amo.permissions.ANY_ADMIN) expected = [ ('Tools', '#'), ('Manage My Submissions', reverse('devhub.addons')), ('Submit a New Add-on', reverse('devhub.submit.agreement')), ('Submit a New Theme', reverse('devhub.submit.agreement')), ('Developer Hub', reverse('devhub.index')), ('Manage API Keys', reverse('devhub.api_key')), ('Reviewer Tools', reverse('reviewers.dashboard')), ('Admin Tools', reverse('zadmin.index')), ] check_links(expected, pq(response.content)('#aux-nav .tools a'), verify=False)
def test_tools_regular_user(self): self.login('regular') r = self.client.get(self.url, follow=True) eq_(r.context['request'].user.is_developer, False) expected = [ ('Tools', '#'), ('Submit a New Add-on', reverse('devhub.submit.1')), ('Submit a New Theme', reverse('devhub.themes.submit')), ('Developer Hub', reverse('devhub.index')), ('Manage API Keys', reverse('devhub.api_key')), ] check_links(expected, pq(r.content)('#aux-nav .tools a'))
def test_tools_regular_user(self): self.login('regular') r = self.client.get(self.url, follow=True) assert not r.context['request'].user.is_developer expected = [ ('Tools', '#'), ('Submit a New Add-on', reverse('devhub.submit.agreement')), ('Submit a New Theme', reverse('devhub.submit.agreement')), ('Developer Hub', reverse('devhub.index')), ('Manage API Keys', reverse('devhub.api_key')), ] check_links(expected, pq(r.content)('#aux-nav .tools a'), verify=False)
def test_tools_regular_user(self): self.login("regular") r = self.client.get(self.url, follow=True) assert not r.context["request"].user.is_developer expected = [ ("Tools", "#"), ("Submit a New Add-on", reverse("devhub.submit.agreement")), ("Submit a New Theme", reverse("devhub.themes.submit")), ("Developer Hub", reverse("devhub.index")), ("Manage API Keys", reverse("devhub.api_key")), ] check_links(expected, pq(r.content)("#aux-nav .tools a"), verify=False)
def test_tools_reviewer(self): self.login('reviewer') r = self.client.get(self.url, follow=True) request = r.context['request'] assert not request.user.is_developer assert acl.action_allowed(request, amo.permissions.ADDONS_REVIEW) expected = [ ('Tools', '#'), ('Submit a New Add-on', reverse('devhub.submit.agreement')), ('Submit a New Theme', reverse('devhub.themes.submit')), ('Developer Hub', reverse('devhub.index')), ('Manage API Keys', reverse('devhub.api_key')), ('Reviewer Tools', reverse('reviewers.dashboard')), ] check_links(expected, pq(r.content)('#aux-nav .tools a'), verify=False)
def test_tools_editor(self): self.login('editor') r = self.client.get(self.url, follow=True) request = r.context['request'] eq_(request.user.is_developer, False) eq_(acl.action_allowed(request, 'Addons', 'Review'), True) expected = [ ('Tools', '#'), ('Submit a New Add-on', reverse('devhub.submit.1')), ('Submit a New Theme', reverse('devhub.themes.submit')), ('Developer Hub', reverse('devhub.index')), ('Manage API Keys', reverse('devhub.api_key')), ('Editor Tools', reverse('editors.home')), ] check_links(expected, pq(r.content)('#aux-nav .tools a'))
def test_tools_editor(self): self.login("editor") r = self.client.get(self.url, follow=True) request = r.context["request"] assert not request.user.is_developer assert acl.action_allowed(request, "Addons", "Review") expected = [ ("Tools", "#"), ("Submit a New Add-on", reverse("devhub.submit.agreement")), ("Submit a New Theme", reverse("devhub.themes.submit")), ("Developer Hub", reverse("devhub.index")), ("Manage API Keys", reverse("devhub.api_key")), ("Editor Tools", reverse("editors.home")), ] check_links(expected, pq(r.content)("#aux-nav .tools a"), verify=False)
def test_tools_reviewer(self): self.login('reviewer') r = self.client.get(self.url, follow=True) request = r.context['request'] assert not request.user.is_developer assert acl.action_allowed(request, amo.permissions.ADDONS_REVIEW) expected = [ ('Tools', '#'), ('Submit a New Add-on', reverse('devhub.submit.agreement')), ('Submit a New Theme', reverse('devhub.submit.agreement')), ('Developer Hub', reverse('devhub.index')), ('Manage API Keys', reverse('devhub.api_key')), ('Reviewer Tools', reverse('reviewers.dashboard')), ] check_links(expected, pq(r.content)('#aux-nav .tools a'), verify=False)
def test_tools_editor(self): self.login('editor') r = self.client.get(self.url, follow=True) request = r.context['request'] assert not request.user.is_developer assert acl.action_allowed(request, 'Addons', 'Review') expected = [ ('Tools', '#'), ('Submit a New Add-on', reverse('devhub.submit.1')), ('Submit a New Theme', reverse('devhub.themes.submit')), ('Developer Hub', reverse('devhub.index')), ('Manage API Keys', reverse('devhub.api_key')), ('Editor Tools', reverse('editors.home')), ] check_links(expected, pq(r.content)('#aux-nav .tools a'))
def test_tools_admin(self): self.login('admin') r = self.client.get(self.url, follow=True) request = r.context['request'] assert not request.user.is_developer assert acl.action_allowed(request, 'Addons', 'Review') assert acl.action_allowed(request, 'Localizer', '%') assert acl.action_allowed(request, 'Admin', '%') expected = [ ('Tools', '#'), ('Submit a New Add-on', reverse('devhub.submit.agreement')), ('Submit a New Theme', reverse('devhub.themes.submit')), ('Developer Hub', reverse('devhub.index')), ('Manage API Keys', reverse('devhub.api_key')), ('Reviewer Tools', reverse('editors.home')), ('Admin Tools', reverse('zadmin.home')), ] check_links(expected, pq(r.content)('#aux-nav .tools a'), verify=False)
def test_tools_developer_and_editor(self): # Make them a developer. user = self.login('editor', get=True) AddonUser.objects.create(user=user, addon=Addon.objects.all()[0]) r = self.client.get(self.url, follow=True) request = r.context['request'] eq_(request.user.is_developer, True) eq_(acl.action_allowed(request, 'Addons', 'Review'), True) expected = [ ('Tools', '#'), ('Manage My Submissions', reverse('devhub.addons')), ('Submit a New Add-on', reverse('devhub.submit.1')), ('Submit a New Theme', reverse('devhub.themes.submit')), ('Developer Hub', reverse('devhub.index')), ('Manage API Keys', reverse('devhub.api_key')), ('Editor Tools', reverse('editors.home')), ] check_links(expected, pq(r.content)('#aux-nav .tools a'))
def test_tools_developer(self): # Make them a developer. user = self.login('regular', get=True) AddonUser.objects.create(user=user, addon=Addon.objects.all()[0]) group = Group.objects.create(name='Staff', rules='Admin:Tools') GroupUser.objects.create(group=group, user=user) r = self.client.get(self.url, follow=True) assert r.context['request'].user.is_developer expected = [ ('Tools', '#'), ('Manage My Submissions', reverse('devhub.addons')), ('Submit a New Add-on', reverse('devhub.submit.agreement')), ('Submit a New Theme', reverse('devhub.submit.agreement')), ('Developer Hub', reverse('devhub.index')), ('Manage API Keys', reverse('devhub.api_key')), ] check_links(expected, pq(r.content)('#aux-nav .tools a'), verify=False)
def test_tools_developer(self): # Make them a developer. user = self.login("regular", get=True) AddonUser.objects.create(user=user, addon=Addon.objects.all()[0]) group = Group.objects.create(name="Staff", rules="AdminTools:View") GroupUser.objects.create(group=group, user=user) r = self.client.get(self.url, follow=True) assert r.context["request"].user.is_developer expected = [ ("Tools", "#"), ("Manage My Submissions", reverse("devhub.addons")), ("Submit a New Add-on", reverse("devhub.submit.agreement")), ("Submit a New Theme", reverse("devhub.themes.submit")), ("Developer Hub", reverse("devhub.index")), ("Manage API Keys", reverse("devhub.api_key")), ] check_links(expected, pq(r.content)("#aux-nav .tools a"), verify=False)
def test_tools_developer_and_editor(self): # Make them a developer. user = self.login('editor', get=True) AddonUser.objects.create(user=user, addon=Addon.objects.all()[0]) r = self.client.get(self.url, follow=True) request = r.context['request'] assert request.user.is_developer assert acl.action_allowed(request, 'Addons', 'Review') expected = [ ('Tools', '#'), ('Manage My Submissions', reverse('devhub.addons')), ('Submit a New Add-on', reverse('devhub.submit.1')), ('Submit a New Theme', reverse('devhub.themes.submit')), ('Developer Hub', reverse('devhub.index')), ('Manage API Keys', reverse('devhub.api_key')), ('Editor Tools', reverse('editors.home')), ] check_links(expected, pq(r.content)('#aux-nav .tools a'))
def test_tools_developer(self): # Make them a developer. user = self.login('regular', get=True) AddonUser.objects.create(user=user, addon=Addon.objects.all()[0]) group = Group.objects.create(name='Staff', rules='AdminTools:View') GroupUser.objects.create(group=group, user=user) r = self.client.get(self.url, follow=True) eq_(r.context['request'].user.is_developer, True) expected = [ ('Tools', '#'), ('Manage My Submissions', reverse('devhub.addons')), ('Submit a New Add-on', reverse('devhub.submit.1')), ('Submit a New Theme', reverse('devhub.themes.submit')), ('Developer Hub', reverse('devhub.index')), ('Manage API Keys', reverse('devhub.api_key')), ] check_links(expected, pq(r.content)('#aux-nav .tools a'))
def test_tools_developer_and_editor(self): # Make them a developer. user = self.login("editor", get=True) AddonUser.objects.create(user=user, addon=Addon.objects.all()[0]) r = self.client.get(self.url, follow=True) request = r.context["request"] assert request.user.is_developer assert acl.action_allowed(request, "Addons", "Review") expected = [ ("Tools", "#"), ("Manage My Submissions", reverse("devhub.addons")), ("Submit a New Add-on", reverse("devhub.submit.agreement")), ("Submit a New Theme", reverse("devhub.themes.submit")), ("Developer Hub", reverse("devhub.index")), ("Manage API Keys", reverse("devhub.api_key")), ("Editor Tools", reverse("editors.home")), ] check_links(expected, pq(r.content)("#aux-nav .tools a"), verify=False)