← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/webservice-export-full-langpack into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/webservice-export-full-langpack into lp:launchpad.

Commit message:
Export DistroSeries.language_pack_full_export_requested on the webservice.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1429131 in Launchpad itself: "Export DistroSeries.language_pack_full_export_requested on the webservice"
  https://bugs.launchpad.net/launchpad/+bug/1429131

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/webservice-export-full-langpack/+merge/252111

Export DistroSeries.language_pack_full_export_requested on the webservice, so that Martin Pitt doesn't have to drive the web UI by hand to generate full language packs.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/webservice-export-full-langpack into lp:launchpad.
=== modified file 'lib/lp/registry/interfaces/distroseries.py'
--- lib/lp/registry/interfaces/distroseries.py	2015-01-30 18:24:07 +0000
+++ lib/lp/registry/interfaces/distroseries.py	2015-03-06 13:25:38 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2013 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2015 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Interfaces including and related to IDistroSeries."""
@@ -327,13 +327,13 @@
             language pack update for this distribution series.
             '''), vocabulary='FilteredLanguagePack')
 
-    language_pack_full_export_requested = Bool(
+    language_pack_full_export_requested = exported(Bool(
         title=_('Request a full language pack export'), required=True,
         description=_('''
             Whether next language pack generation will be a full export. This
             information is useful when update packs are too big and want to
             merge all those changes in the base pack.
-            '''))
+            ''')))
 
     last_full_language_pack_exported = Object(
         title=_('Latest exported language pack with all translation files.'),

=== modified file 'lib/lp/registry/tests/test_distroseries.py'
--- lib/lp/registry/tests/test_distroseries.py	2014-11-10 00:53:02 +0000
+++ lib/lp/registry/tests/test_distroseries.py	2015-03-06 13:25:38 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2014 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2015 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for distroseries."""
@@ -10,12 +10,14 @@
     ]
 
 from functools import partial
+import json
 
 from testtools.matchers import Equals
 import transaction
 from zope.component import getUtility
 from zope.security.proxy import removeSecurityProxy
 
+from lp.app.interfaces.launchpad import ILaunchpadCelebrities
 from lp.archivepublisher.indices import (
     build_binary_stanza_fields,
     build_source_stanza_fields,
@@ -24,6 +26,7 @@
 from lp.registry.interfaces.distroseries import IDistroSeriesSet
 from lp.registry.interfaces.pocket import PackagePublishingPocket
 from lp.services.database.interfaces import IStore
+from lp.services.webapp.interfaces import OAuthPermission
 from lp.soyuz.enums import (
     ArchivePurpose,
     PackagePublishingStatus,
@@ -39,7 +42,9 @@
 from lp.soyuz.interfaces.publishing import active_publishing_status
 from lp.soyuz.tests.test_publishing import SoyuzTestPublisher
 from lp.testing import (
+    admin_logged_in,
     ANONYMOUS,
+    api_url,
     login,
     person_logged_in,
     record_two_runs,
@@ -52,6 +57,7 @@
     LaunchpadFunctionalLayer,
     )
 from lp.testing.matchers import HasQueryCount
+from lp.testing.pages import webservice_for_person
 from lp.translations.interfaces.translations import (
     TranslationsBranchImportMode,
     )
@@ -547,6 +553,42 @@
         self.assertThat(recorder2, HasQueryCount(Equals(recorder1.count)))
 
 
+class TestDistroSeriesWebservice(TestCaseWithFactory):
+
+    layer = DatabaseFunctionalLayer
+
+    def test_language_pack_full_export_requested_not_translations_admin(self):
+        # Somebody with only launchpad.TranslationsAdmin cannot request full
+        # language pack exports.
+        distroseries = self.factory.makeDistroSeries()
+        self.assertFalse(distroseries.language_pack_full_export_requested)
+        group = self.factory.makeTranslationGroup()
+        with admin_logged_in():
+            distroseries.distribution.translationgroup = group
+        webservice = webservice_for_person(
+            group.owner, permission=OAuthPermission.WRITE_PRIVATE)
+        response = webservice.patch(
+            api_url(distroseries), "application/json",
+            json.dumps({"language_pack_full_export_requested": True}))
+        self.assertEqual(401, response.status)
+        self.assertFalse(distroseries.language_pack_full_export_requested)
+
+    def test_language_pack_full_export_requested_langpacks_admin(self):
+        # Somebody with launchpad.LanguagePacksAdmin can request full
+        # language pack exports.
+        distroseries = self.factory.makeDistroSeries()
+        self.assertFalse(distroseries.language_pack_full_export_requested)
+        person = self.factory.makePerson(
+            member_of=[getUtility(ILaunchpadCelebrities).rosetta_experts])
+        webservice = webservice_for_person(
+            person, permission=OAuthPermission.WRITE_PRIVATE)
+        response = webservice.patch(
+            api_url(distroseries), "application/json",
+            json.dumps({"language_pack_full_export_requested": True}))
+        self.assertEqual(209, response.status)
+        self.assertTrue(distroseries.language_pack_full_export_requested)
+
+
 class TestDistroSeriesSet(TestCaseWithFactory):
 
     layer = DatabaseFunctionalLayer


Follow ups