← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stevenk/launchpad/archive-validate-stringfix into lp:launchpad

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/archive-validate-stringfix into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)


This branch changes the error returned by validatePPA() if the person is in fact a team.
-- 
https://code.launchpad.net/~stevenk/launchpad/archive-validate-stringfix/+merge/43496
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/archive-validate-stringfix into lp:launchpad.
=== modified file 'lib/lp/soyuz/model/archive.py'
--- lib/lp/soyuz/model/archive.py	2010-12-09 11:03:53 +0000
+++ lib/lp/soyuz/model/archive.py	2010-12-13 06:51:15 +0000
@@ -1733,7 +1733,11 @@
         except NoSuchPPA:
             return None
         else:
-            return "You already have a PPA named '%s'." % proposed_name
+            text = "You already have a PPA named '%s'." % proposed_name
+            if person.isTeam():
+                text = "%s already has a PPA named '%s'." % (
+                    person.displayname, proposed_name)
+            return text
 
     def getPockets(self):
         """See `IArchive`."""

=== modified file 'lib/lp/soyuz/tests/test_archive.py'
--- lib/lp/soyuz/tests/test_archive.py	2010-12-09 11:03:53 +0000
+++ lib/lp/soyuz/tests/test_archive.py	2010-12-13 06:51:15 +0000
@@ -23,6 +23,7 @@
     )
 from lp.app.errors import NotFoundError
 from lp.buildmaster.enums import BuildStatus
+from lp.registry.interfaces.person import TeamSubscriptionPolicy
 from lp.registry.interfaces.pocket import PackagePublishingPocket
 from lp.registry.interfaces.series import SeriesStatus
 from lp.services.job.interfaces.job import JobStatus
@@ -1446,6 +1447,13 @@
         self.assertEqual("You already have a PPA named 'ppa'.",
             Archive.validatePPA(ppa.owner, 'ppa'))
 
+    def test_two_ppas_with_team(self):
+        team = self.factory.makeTeam(
+            subscription_policy=TeamSubscriptionPolicy.MODERATED)
+        ppa = self.factory.makeArchive(owner=team, name='ppa')
+        self.assertEqual("%s already has a PPA named 'ppa'." % (
+            team.displayname), Archive.validatePPA(team, 'ppa'))
+
     def test_valid_ppa(self):
         ppa_owner = self.factory.makePerson()
         self.assertEqual(None, Archive.validatePPA(ppa_owner, None))