← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stevenk/launchpad/move-archive-privacy-tests into lp:launchpad/devel

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/move-archive-privacy-tests into lp:launchpad/devel.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)


This branch moves the archive privacy tests from test_archive.py into the slightly more specific test_archive_privacy.txt, and fixes one lint issue with test_archive.py as a drive-by.
-- 
https://code.launchpad.net/~stevenk/launchpad/move-archive-privacy-tests/+merge/32738
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/move-archive-privacy-tests into lp:launchpad/devel.
=== modified file 'lib/lp/soyuz/tests/test_archive.py'
--- lib/lp/soyuz/tests/test_archive.py	2010-08-05 13:23:52 +0000
+++ lib/lp/soyuz/tests/test_archive.py	2010-08-16 09:12:39 +0000
@@ -25,10 +25,9 @@
 from lp.services.job.interfaces.job import JobStatus
 from lp.soyuz.interfaces.archive import (
     ArchiveDisabled, ArchivePurpose, ArchiveStatus,
-    CannotRestrictArchitectures, CannotSwitchPrivacy, CannotUploadToPocket,
-    CannotUploadToPPA, IArchiveSet, InsufficientUploadRights,
-    InvalidPocketForPartnerArchive, InvalidPocketForPPA, NoRightsForArchive,
-    NoRightsForComponent)
+    CannotRestrictArchitectures, CannotUploadToPocket, CannotUploadToPPA,
+    IArchiveSet, InsufficientUploadRights, InvalidPocketForPartnerArchive,
+    InvalidPocketForPPA, NoRightsForArchive, NoRightsForComponent)
 from lp.services.worlddata.interfaces.country import ICountrySet
 from lp.soyuz.interfaces.archivearch import IArchiveArchSet
 from lp.soyuz.interfaces.archivepermission import IArchivePermissionSet
@@ -502,8 +501,7 @@
                 archive, person, sourcepackagename,
                 distroseries=distroseries, component=component,
                 pocket=pocket, strict_component=strict_component),
-            reason
-            )
+            reason)
 
     def test_checkUpload_partner_invalid_pocket(self):
         # Partner archives only have release and proposed pockets
@@ -978,52 +976,6 @@
         self.assertEqual(token.archive_url, url)
 
 
-class TestArchivePrivacySwitching(TestCaseWithFactory):
-
-    layer = LaunchpadZopelessLayer
-
-    def setUp(self):
-        """Create a public and a private PPA."""
-        super(TestArchivePrivacySwitching, self).setUp()
-        self.public_ppa = self.factory.makeArchive()
-        self.private_ppa = self.factory.makeArchive()
-        self.private_ppa.buildd_secret = 'blah'
-        self.private_ppa.private = True
-
-    def make_ppa_private(self, ppa):
-        """Helper method to privatise a ppa."""
-        ppa.private = True
-        ppa.buildd_secret = "secret"
-
-    def make_ppa_public(self, ppa):
-        """Helper method to make a PPA public (and use for assertRaises)."""
-        ppa.private = False
-        ppa.buildd_secret = ''
-
-    def test_switch_privacy_no_pubs_succeeds(self):
-        # Changing the privacy is fine if there are no publishing
-        # records.
-        self.make_ppa_private(self.public_ppa)
-        self.assertTrue(self.public_ppa.private)
-
-        self.private_ppa.private = False
-        self.assertFalse(self.private_ppa.private)
-
-    def test_switch_privacy_with_pubs_fails(self):
-        # Changing the privacy is not possible when the archive already
-        # has published sources.
-        publisher = SoyuzTestPublisher()
-        publisher.prepareBreezyAutotest()
-        publisher.getPubSource(archive=self.public_ppa)
-        publisher.getPubSource(archive=self.private_ppa)
-
-        self.assertRaises(
-            CannotSwitchPrivacy, self.make_ppa_private, self.public_ppa)
-
-        self.assertRaises(
-            CannotSwitchPrivacy, self.make_ppa_public, self.private_ppa)
-
-
 class TestGetBinaryPackageRelease(TestCaseWithFactory):
     """Ensure that getBinaryPackageRelease works as expected."""
 

=== modified file 'lib/lp/soyuz/tests/test_archive_privacy.py'
--- lib/lp/soyuz/tests/test_archive_privacy.py	2010-07-20 12:06:36 +0000
+++ lib/lp/soyuz/tests/test_archive_privacy.py	2010-08-16 09:12:39 +0000
@@ -5,9 +5,11 @@
 
 from zope.component import getUtility
 from zope.security.interfaces import Unauthorized
-from lp.soyuz.interfaces.archive import IArchiveSet
+from lp.soyuz.interfaces.archive import CannotSwitchPrivacy, IArchiveSet
+from lp.soyuz.tests.test_publishing import SoyuzTestPublisher
 
-from canonical.testing import LaunchpadFunctionalLayer
+from canonical.testing import (
+    LaunchpadFunctionalLayer, LaunchpadZopelessLayer)
 from lp.testing import login, login_person, TestCaseWithFactory
 
 
@@ -37,3 +39,49 @@
         login_person(self.joe)
         p3a = getUtility(IArchiveSet).get(self.private_ppa.id)
         self.assertEqual(self._getDescription(p3a), "Foo")
+
+
+class TestArchivePrivacySwitching(TestCaseWithFactory):
+
+    layer = LaunchpadZopelessLayer
+
+    def setUp(self):
+        """Create a public and a private PPA."""
+        super(TestArchivePrivacySwitching, self).setUp()
+        self.public_ppa = self.factory.makeArchive()
+        self.private_ppa = self.factory.makeArchive()
+        self.private_ppa.buildd_secret = 'blah'
+        self.private_ppa.private = True
+
+    def make_ppa_private(self, ppa):
+        """Helper method to privatise a ppa."""
+        ppa.private = True
+        ppa.buildd_secret = "secret"
+
+    def make_ppa_public(self, ppa):
+        """Helper method to make a PPA public (and use for assertRaises)."""
+        ppa.private = False
+        ppa.buildd_secret = ''
+
+    def test_switch_privacy_no_pubs_succeeds(self):
+        # Changing the privacy is fine if there are no publishing
+        # records.
+        self.make_ppa_private(self.public_ppa)
+        self.assertTrue(self.public_ppa.private)
+
+        self.private_ppa.private = False
+        self.assertFalse(self.private_ppa.private)
+
+    def test_switch_privacy_with_pubs_fails(self):
+        # Changing the privacy is not possible when the archive already
+        # has published sources.
+        publisher = SoyuzTestPublisher()
+        publisher.prepareBreezyAutotest()
+        publisher.getPubSource(archive=self.public_ppa)
+        publisher.getPubSource(archive=self.private_ppa)
+
+        self.assertRaises(
+            CannotSwitchPrivacy, self.make_ppa_private, self.public_ppa)
+
+        self.assertRaises(
+            CannotSwitchPrivacy, self.make_ppa_public, self.private_ppa)