[Launchpad-reviewers] [Merge] lp:~cjwatson/launchpad/translation-import-queue-entry-dsp-vocab into lp:launchpad

2016-09-19 Thread noreply
The proposal to merge 
lp:~cjwatson/launchpad/translation-import-queue-entry-dsp-vocab into 
lp:launchpad has been updated.

Status: Needs review => Merged

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/translation-import-queue-entry-dsp-vocab/+merge/305509
-- 
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.

___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


Re: [Launchpad-reviewers] [Merge] lp:~cjwatson/launchpad/translation-import-queue-entry-dsp-vocab into lp:launchpad

2016-09-19 Thread William Grant
Review: Approve code


-- 
https://code.launchpad.net/~cjwatson/launchpad/translation-import-queue-entry-dsp-vocab/+merge/305509
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.

___
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to : launchpad-reviewers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp


[Launchpad-reviewers] [Merge] lp:~cjwatson/launchpad/translation-import-queue-entry-dsp-vocab into lp:launchpad

2016-09-12 Thread Colin Watson
Colin Watson has proposed merging 
lp:~cjwatson/launchpad/translation-import-queue-entry-dsp-vocab into 
lp:launchpad with lp:~cjwatson/launchpad/potemplate-dsp-vocab as a prerequisite.

Commit message:
Convert TranslationImportQueueEntry:+index to use the DistributionSourcePackage 
picker if the appropriate feature flag is set.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #42298 in Launchpad itself: "package picker lists unpublished (invalid) 
packages"
  https://bugs.launchpad.net/launchpad/+bug/42298

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/translation-import-queue-entry-dsp-vocab/+merge/305509

Convert TranslationImportQueueEntry:+index to use the DistributionSourcePackage 
picker if the appropriate feature flag is set.

I believe this is the last of the view conversions.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
lp:~cjwatson/launchpad/translation-import-queue-entry-dsp-vocab into 
lp:launchpad.
=== modified file 'lib/lp/translations/browser/tests/test_translationimportqueueentry.py'
--- lib/lp/translations/browser/tests/test_translationimportqueueentry.py	2014-02-19 04:01:46 +
+++ lib/lp/translations/browser/tests/test_translationimportqueueentry.py	2016-09-12 17:58:08 +
@@ -1,4 +1,4 @@
-# Copyright 2010 Canonical Ltd.  This software is licensed under the
+# Copyright 2010-2016 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Unit tests for translation import queue views."""
@@ -6,12 +6,18 @@
 from datetime import datetime
 
 from pytz import timezone
+from testscenarios import (
+load_tests_apply_scenarios,
+WithScenarios,
+)
 from zope.component import getUtility
 from zope.security.proxy import removeSecurityProxy
 
 from lp.app.enums import ServiceUsage
+from lp.services.features.testing import FeatureFixture
 from lp.services.webapp import canonical_url
 from lp.testing import (
+celebrity_logged_in,
 TestCase,
 TestCaseWithFactory,
 )
@@ -23,14 +29,23 @@
 )
 
 
-class TestTranslationImportQueueEntryView(TestCaseWithFactory):
+class TestTranslationImportQueueEntryView(WithScenarios, TestCaseWithFactory):
 """Tests for the queue entry review form."""
 
 layer = LaunchpadFunctionalLayer
 
+scenarios = [
+("spn_picker", {"features": {}}),
+("dsp_picker", {
+"features": {u"disclosure.dsp_picker.enabled": u"on"},
+}),
+]
+
 def setUp(self):
 super(TestTranslationImportQueueEntryView, self).setUp(
 'foo@canonical.com')
+if self.features:
+self.useFixture(FeatureFixture(self.features))
 self.queue = getUtility(ITranslationImportQueue)
 self.uploader = self.factory.makePerson()
 
@@ -201,6 +216,32 @@
 
 self.assertEqual(name, view.initial_values['name'])
 
+def test_change_sourcepackage(self):
+# Changing the source package is honoured.
+series = self.factory.makeDistroSeries()
+packagename = self.factory.makeSourcePackageName()
+potemplate = self.factory.makePOTemplate(
+distroseries=series, sourcepackagename=packagename)
+entry = self._makeEntry(
+distroseries=series, sourcepackagename=packagename,
+potemplate=potemplate)
+dsp = self.factory.makeDSPCache(distroseries=series)
+form = {
+'field.file_type': 'POT',
+'field.path': entry.path,
+'field.sourcepackagename': dsp.sourcepackagename.name,
+'field.name': potemplate.name,
+'field.translation_domain': potemplate.translation_domain,
+'field.languagepack': '',
+'field.actions.approve': 'Approve',
+}
+with celebrity_logged_in('rosetta_experts'):
+view = create_initialized_view(entry, '+index', form=form)
+self.assertEqual([], view.errors)
+self.assertEqual(
+dsp.sourcepackagename.name,
+entry.potemplate.sourcepackagename.name)
+
 
 class TestEscapeJSString(TestCase):
 """Test `escape_js_string`."""
@@ -222,3 +263,6 @@
 
 def test_escape_js_string_ampersand(self):
 self.assertEqual('&', escape_js_string('&'))
+
+
+load_tests = load_tests_apply_scenarios

=== modified file 'lib/lp/translations/browser/translationimportqueue.py'
--- lib/lp/translations/browser/translationimportqueue.py	2015-07-08 16:05:11 +
+++ lib/lp/translations/browser/translationimportqueue.py	2016-09-12 17:58:08 +
@@ -1,4 +1,4 @@
-# Copyright 2009-2010 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2016 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Browser views for `ITranslationImportQueue`."""
@@ -15,6 +15,7 @@
 
 import os
 
+from lazr.restful.in