1
# Copyright 2011 Canonical Ltd. This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
4
"""Tests for the translations views on a distroseries."""
8
from zope.security.interfaces import Unauthorized
10
from canonical.launchpad.webapp import canonical_url
11
from canonical.testing.layers import LaunchpadFunctionalLayer
12
from lp.testing import (
16
from lp.testing.views import create_initialized_view
19
class TestDistributionSettingsView(TestCaseWithFactory):
20
"""Test distribution settings (+configure-translations) view."""
22
layer = LaunchpadFunctionalLayer
24
def test_only_translation_fields(self):
25
# No fields other than translation fields are shown
26
# in the distribution translation settings form view.
27
distribution = self.factory.makeDistribution()
28
view = create_initialized_view(
29
distribution, '+configure-translations', rootsite='translations')
30
self.assertContentEqual(
31
["translations_usage",
34
"translationpermission",
38
def test_unprivileged_users(self):
39
# Unprivileged users cannot access distribution translation settings
40
# page Distribution:+configure-translations.
41
unprivileged = self.factory.makePerson()
42
distribution = self.factory.makeDistribution()
43
browser = self.getUserBrowser(user=unprivileged)
44
url = canonical_url(distribution, view_name='+configure-translations',
45
rootsite='translations')
46
self.assertRaises(Unauthorized, browser.open, url)
48
def test_translation_group_owner(self):
49
# Translation group owner for a particular distribution has
50
# launchpad.TranslationsAdmin privileges on it, meaning they
51
# can access Distribution:+configure-translations page.
52
group = self.factory.makeTranslationGroup()
53
distribution = self.factory.makeDistribution()
54
with person_logged_in(distribution.owner):
55
distribution.translationgroup = group
56
browser = self.getUserBrowser(user=group.owner)
57
url = canonical_url(distribution, view_name='+configure-translations',
58
rootsite='translations')
59
# No "Unauthorized" exception is thrown.
62
def test_distribution_owner(self):
63
# Distribution owner of a particular distribution has
64
# launchpad.TranslationsAdmin privileges on it, meaning they
65
# can access Distribution:+configure-translations page.
66
distribution = self.factory.makeDistribution()
67
browser = self.getUserBrowser(user=distribution.owner)
68
url = canonical_url(distribution, view_name='+configure-translations',
69
rootsite='translations')
70
# No "Unauthorized" exception is thrown.