← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~jtv/launchpad/test-cruft-archiveuploader into lp:launchpad/devel

 

Jeroen T. Vermeulen has proposed merging lp:~jtv/launchpad/test-cruft-archiveuploader into lp:launchpad/devel.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers): code


Removes test boilerplate that we no longer need from archiveuploader, and fixes lint in affected tests.
-- 
https://code.launchpad.net/~jtv/launchpad/test-cruft-archiveuploader/+merge/30197
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/launchpad/test-cruft-archiveuploader into lp:launchpad/devel.
=== modified file 'lib/lp/archiveuploader/tests/test_buildduploads.py'
--- lib/lp/archiveuploader/tests/test_buildduploads.py	2010-05-19 15:39:52 +0000
+++ lib/lp/archiveuploader/tests/test_buildduploads.py	2010-07-18 00:33:43 +0000
@@ -1,12 +1,10 @@
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2010 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Test buildd uploads use-cases."""
 
 __metaclass__ = type
 
-import unittest
-
 from lp.archiveuploader.tests.test_securityuploads import (
     TestStagedBinaryUploadBase)
 from lp.archiveuploader.uploadprocessor import UploadProcessor
@@ -33,7 +31,8 @@
      * 'lib/lp/archiveuploader/tests/data/suite/foo_1.0-1/'
      * 'lib/lp/archiveuploader/tests/data/suite/foo_1.0-1_binary/'
 
-    This class allows uploads to ubuntu/breezy in i386 & powerpc architectures.
+    This class allows uploads to ubuntu/breezy in i386 & powerpc
+    architectures.
     """
     name = 'foo'
     version = '1.0-1'
@@ -124,7 +123,3 @@
             u'powerpc build of foo 1.0-1 in ubuntu breezy RELEASE',
             build_used.title)
         self.assertEqual('FULLYBUILT', build_used.status.name)
-
-
-def test_suite():
-    return unittest.TestLoader().loadTestsFromName(__name__)

=== modified file 'lib/lp/archiveuploader/tests/test_dscfile.py'
--- lib/lp/archiveuploader/tests/test_dscfile.py	2010-06-25 21:35:15 +0000
+++ lib/lp/archiveuploader/tests/test_dscfile.py	2010-07-18 00:33:43 +0000
@@ -6,7 +6,6 @@
 __metaclass__ = type
 
 import os
-import unittest
 
 from canonical.testing.layers import LaunchpadZopelessLayer
 from lp.archiveuploader.dscfile import (
@@ -90,7 +89,6 @@
         self.assertEqual(self.dsc_file.changelog_path,
                          self.changelog_dest)
 
-
     def testOversizedFile(self):
         """Test that a file larger than 10MiB will fail.
 
@@ -131,7 +129,3 @@
             list(dsc_file.unpackAndCheckSource())
         finally:
             os.chmod(tempdir, 0755)
-
-
-def test_suite():
-    return unittest.TestLoader().loadTestsFromName(__name__)

=== modified file 'lib/lp/archiveuploader/tests/test_permission.py'
--- lib/lp/archiveuploader/tests/test_permission.py	2010-05-11 14:09:44 +0000
+++ lib/lp/archiveuploader/tests/test_permission.py	2010-07-18 00:33:43 +0000
@@ -1,12 +1,10 @@
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2010 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for the permissions for uploading to an archive."""
 
 __metaclass__ = type
 
-import unittest
-
 from zope.component import getUtility
 from zope.security.proxy import removeSecurityProxy
 
@@ -27,7 +25,7 @@
         # By default, a person cannot upload to any component of an archive.
         archive = self.factory.makeArchive()
         person = self.factory.makePerson()
-        self.assertEqual(set(), 
+        self.assertEqual(set(),
             set(archive.getComponentsForUploader(person)))
 
     def test_components_for_person_with_permissions(self):
@@ -242,7 +240,3 @@
         component = self.factory.makeComponent()
         self.assertCannotUpload(u"%s is disabled." % (archive.displayname),
             archive.owner, spn, archive, component)
-
-
-def test_suite():
-    return unittest.TestLoader().loadTestsFromName(__name__)

=== modified file 'lib/lp/archiveuploader/tests/test_ppauploadprocessor.py'
--- lib/lp/archiveuploader/tests/test_ppauploadprocessor.py	2010-05-19 15:39:52 +0000
+++ lib/lp/archiveuploader/tests/test_ppauploadprocessor.py	2010-07-18 00:33:43 +0000
@@ -2,7 +2,7 @@
 # NOTE: The first line above must stay first; do not move the copyright
 # notice to the top.  See http://www.python.org/dev/peps/pep-0263/.
 #
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2010 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Functional tests for uploadprocessor.py."""
@@ -12,7 +12,6 @@
 from email import message_from_string
 import os
 import shutil
-import unittest
 
 import transaction
 from zope.component import getUtility
@@ -99,7 +98,7 @@
         queue_size = len(stub.test_emails)
         messages = "\n".join(m for f, t, m in stub.test_emails)
         self.assertEqual(
-            queue_size, 1,'Unexpected number of emails sent: %s\n%s'
+            queue_size, 1, 'Unexpected number of emails sent: %s\n%s'
             % (queue_size, messages))
 
         from_addr, to_addrs, raw_msg = stub.test_emails.pop()
@@ -1084,7 +1083,6 @@
             "File bar_1.0.orig.tar.gz already exists in unicode PPA name: "
             "áří" in body)
 
-
     def testPPAConflictingOrigFiles(self):
         """When available, the official 'orig.tar.gz' restricts PPA uploads.
 
@@ -1348,9 +1346,3 @@
         size = self.name16.archive.binaries_size
         self.assertEqual(size, 36,
             "binaries_size returns %d, expected 36" % size)
-
-
-def test_suite():
-    return unittest.TestLoader().loadTestsFromName(__name__)
-
-

=== modified file 'lib/lp/archiveuploader/tests/test_recipeuploads.py'
--- lib/lp/archiveuploader/tests/test_recipeuploads.py	2010-05-28 03:32:41 +0000
+++ lib/lp/archiveuploader/tests/test_recipeuploads.py	2010-07-18 00:33:43 +0000
@@ -6,7 +6,6 @@
 __metaclass__ = type
 
 import os
-import unittest
 
 from storm.store import Store
 from zope.component import getUtility
@@ -21,6 +20,7 @@
 
 
 class TestSourcePackageRecipeBuildUploads(TestUploadProcessorBase):
+
     def setUp(self):
         super(TestSourcePackageRecipeBuildUploads, self).setUp()
 
@@ -69,7 +69,3 @@
         self.assertEqual(spr, self.build.source_package_release)
         self.assertEqual(BuildStatus.FULLYBUILT, self.build.buildstate)
         self.assertEqual(True, self.build.verifySuccessfulUpload())
-
-
-def test_suite():
-    return unittest.TestLoader().loadTestsFromName(__name__)

=== modified file 'lib/lp/archiveuploader/tests/test_securityuploads.py'
--- lib/lp/archiveuploader/tests/test_securityuploads.py	2010-05-19 15:39:52 +0000
+++ lib/lp/archiveuploader/tests/test_securityuploads.py	2010-07-18 00:33:43 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2010 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Test security uploads use-cases."""
@@ -6,7 +6,6 @@
 __metaclass__ = type
 
 import os
-import unittest
 
 from zope.component import getUtility
 
@@ -60,7 +59,7 @@
         """Setup environment for staged binaries upload via security policy.
 
         1. Setup queue directory and other basic attributes
-        2. Override policy options to get security policy and to not send emails
+        2. Override policy options to get security policy and not send emails
         3. Setup a common UploadProcessor with the overridden options
         4. Store number of build present before issuing any upload
         5. Upload the source package via security policy
@@ -262,10 +261,4 @@
 
         self.assertLogContains(
             "UploadError: Attempt to upload binaries specifying build %d, "
-            "where they don't fit.\n" % (build_candidate.id,))
-
-
-def test_suite():
-    return unittest.TestLoader().loadTestsFromName(__name__)
-
-
+            "where they don't fit.\n" % (build_candidate.id, ))

=== modified file 'lib/lp/archiveuploader/tests/test_signedfiles.py'
--- lib/lp/archiveuploader/tests/test_signedfiles.py	2010-04-27 19:48:39 +0000
+++ lib/lp/archiveuploader/tests/test_signedfiles.py	2010-07-18 00:33:43 +0000
@@ -1,14 +1,12 @@
 #!/usr/bin/python
 #
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2010 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 # arch-tag: f815ad2f-cd34-4399-81a1-c226a949e6b5
 
 import unittest
 import sys
-import os
-import shutil
 from lp.archiveuploader.tests import datadir
 
 
@@ -35,7 +33,7 @@
         from lp.archiveuploader.GPGV import TaintedFileNameError
         self.assertRaises(TaintedFileNameError, verify_signed_file, "*", [])
         self.assertRaises(TaintedFileNameError,
-                          verify_signed_file, "foo", [], "*" )
+                          verify_signed_file, "foo", [], "*")
 
     def testCheckExpiredSignedChanges(self):
         """lp.archiveuploader.GPGV.verify_signed_file should raise
@@ -103,12 +101,14 @@
         except NoPublicKeyError, err:
             self.assertEquals(err.key, '3AD3DF3EF2D2C028')
 
+
 def test_suite():
     suite = unittest.TestSuite()
     loader = unittest.TestLoader()
     suite.addTest(loader.loadTestsFromTestCase(TestSignedFiles))
     return suite
 
+
 def main(argv):
     suite = test_suite()
     runner = unittest.TextTestRunner(verbosity=2)
@@ -116,6 +116,6 @@
         return 1
     return 0
 
+
 if __name__ == '__main__':
     sys.exit(main(sys.argv))
-

=== modified file 'lib/lp/archiveuploader/tests/test_tagfiles.py'
--- lib/lp/archiveuploader/tests/test_tagfiles.py	2010-04-27 19:48:39 +0000
+++ lib/lp/archiveuploader/tests/test_tagfiles.py	2010-07-18 00:33:43 +0000
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 #
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2010 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 # arch-tag: 52e0c871-49a3-4186-beb8-9817d02d5465
@@ -12,6 +12,7 @@
 from lp.archiveuploader.tagfiles import (
     parse_tagfile, TagFile, TagFileParseError)
 
+
 class Testtagfiles(unittest.TestCase):
 
     def testTagFileOnSingular(self):
@@ -182,7 +183,3 @@
         self.assertEqual(
             expected_text,
             self.parse_tagfile_version['description'])
-
-def test_suite():
-    return unittest.TestLoader().loadTestsFromName(__name__)
-

=== modified file 'lib/lp/archiveuploader/tests/test_uploadprocessor.py'
--- lib/lp/archiveuploader/tests/test_uploadprocessor.py	2010-06-28 16:57:01 +0000
+++ lib/lp/archiveuploader/tests/test_uploadprocessor.py	2010-07-18 00:33:43 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2010 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Functional tests for uploadprocessor.py."""
@@ -16,7 +16,6 @@
 from StringIO import StringIO
 import tempfile
 import traceback
-import unittest
 
 from email import message_from_string
 
@@ -74,6 +73,7 @@
 
 class MockLogger:
     """Pass as a log object. Record debug calls for later checking."""
+
     def __init__(self):
         self.lines = []
 
@@ -453,7 +453,7 @@
             shutil.rmtree(testdir)
 
     def testMoveProcessUploadFailed(self):
-        """moveProcessedUpload should move if the result was not successful."""
+        """moveProcessedUpload moves if the result was not successful."""
         testdir = tempfile.mkdtemp()
         try:
             # Create an upload, a .distro and a target to move it to.
@@ -476,7 +476,7 @@
             shutil.rmtree(testdir)
 
     def testRemoveUpload(self):
-        """RemoveUpload should remove the upload directory and .distro file."""
+        """RemoveUpload removes the upload directory and .distro file."""
         testdir = tempfile.mkdtemp()
         try:
             # Create an upload, a .distro and a target to move it to.
@@ -736,10 +736,10 @@
         to the same filename in the archive.
 
         Such situation happens when a source gets copied to another suite in
-        the same archive. The binary rebuild will have the same (name, version)
-        of the original binary and will certainly have a different content
-        (at least, the ar-compressed timestamps) making it impossible to be
-        published in the archive.
+        the same archive. The binary rebuild will have the same
+        (name, version) of the original binary and will certainly have a
+        different content (at least, the ar-compressed timestamps) making it
+        impossible to be published in the archive.
         """
         uploadprocessor = self.setupBreezyAndGetUploadProcessor()
 
@@ -1220,8 +1220,7 @@
 
         # Check that the sourceful upload to the copy archive is rejected.
         contents = [
-            "Invalid upload path (1/ubuntu) for this policy (insecure)"
-            ]
+            "Invalid upload path (1/ubuntu) for this policy (insecure)"]
         self.assertEmail(contents=contents, recipients=[])
 
     # Uploads that are new should have the component overridden
@@ -1531,7 +1530,7 @@
             distroseries=self.ubuntu['grumpy'])
         self.layer.txn.commit()
 
-        foo_ps.add((bar_package,))
+        foo_ps.add((bar_package, ))
         ap_set.newPackagesetUploader(
             self.ubuntu.main_archive, uploader, foo_ps)
 
@@ -1558,7 +1557,7 @@
         breezy_ps = ps_set.new(
             u'foo-pkg-set-breezy', u'Packages that require special care.',
             uploader, distroseries=self.breezy)
-        breezy_ps.add((bar_package,))
+        breezy_ps.add((bar_package, ))
         ap_set.newPackagesetUploader(
             self.ubuntu.main_archive, uploader, breezy_ps)
         # The uploader now does have a package set based upload permission
@@ -1798,7 +1797,7 @@
         should both have the PGP signature removed.
         """
         uploadprocessor = self.setupBreezyAndGetUploadProcessor(
-	    policy='insecure')
+        policy='insecure')
         upload_dir = self.queueUpload("bar_1.0-1")
         self.processUpload(uploadprocessor, upload_dir)
         # ACCEPT the upload
@@ -1813,9 +1812,3 @@
         pubrec.datepublished = UTC_NOW
         queue_item.setDone()
         self.PGPSignatureNotPreserved(archive=self.breezy.main_archive)
-
-
-def test_suite():
-    return unittest.TestLoader().loadTestsFromName(__name__)
-
-

=== modified file 'lib/lp/archiveuploader/tests/test_utils.py'
--- lib/lp/archiveuploader/tests/test_utils.py	2010-04-27 19:48:39 +0000
+++ lib/lp/archiveuploader/tests/test_utils.py	2010-07-18 00:33:43 +0000
@@ -1,13 +1,12 @@
 #!/usr/bin/python
 #
-# Copyright 2009 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2010 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 # arch-tag: 90e6eb79-83a2-47e8-9f8b-3c687079c923
 
 import unittest
 import sys
-import shutil
 
 from lp.registry.interfaces.sourcepackage import SourcePackageFileType
 from lp.soyuz.interfaces.binarypackagerelease import BinaryPackageFileType
@@ -196,7 +195,7 @@
              " <zakame@xxxxxxxxxx (Zak B. Elep)>",
              " <zakame@xxxxxxxxxx (Zak B. Elep)>",
              "",
-             "zakame@xxxxxxxxxx (Zak B. Elep)")
+             "zakame@xxxxxxxxxx (Zak B. Elep)"),
              )
 
         for case in cases:
@@ -222,12 +221,14 @@
             except ParseMaintError:
                 pass
 
+
 def test_suite():
     suite = unittest.TestSuite()
     loader = unittest.TestLoader()
     suite.addTest(loader.loadTestsFromTestCase(TestUtilities))
     return suite
 
+
 def main(argv):
     suite = test_suite()
     runner = unittest.TextTestRunner(verbosity = 2)
@@ -235,6 +236,6 @@
         return 1
     return 0
 
+
 if __name__ == '__main__':
     sys.exit(main(sys.argv))
-