Merge lp:~jtv/launchpad/test-cruft-soyuz into lp:launchpad

Proposed by Jeroen T. Vermeulen
Status: Merged
Approved by: Robert Collins
Approved revision: no longer in the source branch.
Merged at revision: 11184
Proposed branch: lp:~jtv/launchpad/test-cruft-soyuz
Merge into: lp:launchpad
Diff against target: 1781 lines (+173/-350)
38 files modified
lib/lp/soyuz/browser/tests/test_archive_packages.py (+0/-5)
lib/lp/soyuz/browser/tests/test_breadcrumbs.py (+5/-8)
lib/lp/soyuz/browser/tests/test_distrosourcepackagerelease.py (+0/-6)
lib/lp/soyuz/browser/tests/test_queue.py (+0/-5)
lib/lp/soyuz/browser/tests/test_sourcepackagerelease.py (+0/-5)
lib/lp/soyuz/browser/tests/test_sourceslistentries.py (+2/-6)
lib/lp/soyuz/scripts/tests/test_archivecruftchecker.py (+5/-11)
lib/lp/soyuz/scripts/tests/test_buildd_cronscripts.py (+5/-9)
lib/lp/soyuz/scripts/tests/test_changeoverride.py (+1/-5)
lib/lp/soyuz/scripts/tests/test_chrootmanager.py (+2/-6)
lib/lp/soyuz/scripts/tests/test_copypackage.py (+4/-9)
lib/lp/soyuz/scripts/tests/test_expire_archive_files.py (+4/-8)
lib/lp/soyuz/scripts/tests/test_gina.py (+1/-2)
lib/lp/soyuz/scripts/tests/test_lpquerydistro.py (+3/-7)
lib/lp/soyuz/scripts/tests/test_obsoletedistroseries.py (+7/-10)
lib/lp/soyuz/scripts/tests/test_overrides_checker.py (+3/-8)
lib/lp/soyuz/scripts/tests/test_populatearchive.py (+14/-19)
lib/lp/soyuz/scripts/tests/test_ppa_apache_log_parser.py (+0/-5)
lib/lp/soyuz/scripts/tests/test_ppakeygenerator.py (+16/-37)
lib/lp/soyuz/scripts/tests/test_ppareport.py (+16/-31)
lib/lp/soyuz/scripts/tests/test_processdeathrow.py (+2/-6)
lib/lp/soyuz/scripts/tests/test_processpendingpackagediffs.py (+1/-7)
lib/lp/soyuz/scripts/tests/test_processupload.py (+7/-11)
lib/lp/soyuz/tests/test_archive.py (+21/-24)
lib/lp/soyuz/tests/test_archive_agent.py (+0/-1)
lib/lp/soyuz/tests/test_archive_privacy.py (+0/-1)
lib/lp/soyuz/tests/test_archive_subscriptions.py (+1/-8)
lib/lp/soyuz/tests/test_archivearch.py (+3/-8)
lib/lp/soyuz/tests/test_binarypackagebuild.py (+3/-10)
lib/lp/soyuz/tests/test_distroseriesbinarypackage.py (+0/-5)
lib/lp/soyuz/tests/test_hasbuildrecords.py (+7/-7)
lib/lp/soyuz/tests/test_packagediff.py (+0/-5)
lib/lp/soyuz/tests/test_packageupload.py (+1/-6)
lib/lp/soyuz/tests/test_publish_archive_indexes.py (+9/-9)
lib/lp/soyuz/tests/test_publishing.py (+11/-14)
lib/lp/soyuz/tests/test_publishing_models.py (+3/-8)
lib/lp/soyuz/tests/test_publishing_top_level_api.py (+13/-18)
lib/lp/testing/faketransaction.py (+3/-0)
To merge this branch: bzr merge lp:~jtv/launchpad/test-cruft-soyuz
Reviewer Review Type Date Requested Status
Leonard Richardson (community) code Approve
Review via email: mp+30407@code.launchpad.net

Commit message

Soyuz test cruft.

Description of the change

= Soyuz test cruft =

This gives the Soyuz tests some much-needed love. Tough love, but still. To give an impression of how much it was needed, the branch is vastly oversized, for which I apologize with few regrets.

You'll find 3 types of changes here:

1. Removed boilerplate.

Unit tests used to need some boilerplate at the end that is not dead wood.

2. Lint fixes.

As every true Launchpad engineer would, I ran "make lint" over the changes and cleaned up a few problems. This is the majority of the diff.

3. Reuse fake classes from lp.testing.

I substituted FakeMethod and FakeTransaction for ad-hoc equivalents I found in the tests. I extended FakeTransaction with a commit count to satisfy one of the use cases.

To test:
{{{
./bin/test -vvc -m lp.soyuz
}}}

Set apart some time for this.

Jeroen

To post a comment you must log in.
Revision history for this message
Leonard Richardson (leonardr) wrote :

+1

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/soyuz/browser/tests/test_archive_packages.py'
--- lib/lp/soyuz/browser/tests/test_archive_packages.py 2010-06-24 14:16:42 +0000
+++ lib/lp/soyuz/browser/tests/test_archive_packages.py 2010-07-21 07:48:48 +0000
@@ -12,8 +12,6 @@
12 'test_suite',12 'test_suite',
13 ]13 ]
1414
15import unittest
16
17from zope.security.interfaces import Unauthorized15from zope.security.interfaces import Unauthorized
1816
19from canonical.testing import LaunchpadFunctionalLayer17from canonical.testing import LaunchpadFunctionalLayer
@@ -96,6 +94,3 @@
96 view = create_initialized_view(self.ppa, "+index")94 view = create_initialized_view(self.ppa, "+index")
97 menu = ArchiveNavigationMenu(view)95 menu = ArchiveNavigationMenu(view)
98 self.assertTrue(menu.packages().enabled)96 self.assertTrue(menu.packages().enabled)
99
100def test_suite():
101 return unittest.TestLoader().loadTestsFromName(__name__)
10297
=== modified file 'lib/lp/soyuz/browser/tests/test_breadcrumbs.py'
--- lib/lp/soyuz/browser/tests/test_breadcrumbs.py 2010-04-28 10:26:58 +0000
+++ lib/lp/soyuz/browser/tests/test_breadcrumbs.py 2010-07-21 07:48:48 +0000
@@ -1,10 +1,8 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4__metaclass__ = type4__metaclass__ = type
55
6import unittest
7
8from zope.component import getUtility6from zope.component import getUtility
97
10from canonical.launchpad.webapp.publisher import canonical_url8from canonical.launchpad.webapp.publisher import canonical_url
@@ -65,9 +63,8 @@
6563
66 def test_personal_archive_subscription(self):64 def test_personal_archive_subscription(self):
67 subscription_url = canonical_url(self.personal_archive_subscription)65 subscription_url = canonical_url(self.personal_archive_subscription)
68 crumbs = self.getBreadcrumbsForObject(self.personal_archive_subscription)66 crumbs = self.getBreadcrumbsForObject(
67 self.personal_archive_subscription)
69 self.assertEquals(subscription_url, crumbs[-1].url)68 self.assertEquals(subscription_url, crumbs[-1].url)
70 self.assertEquals("Access to %s" % self.ppa.displayname, crumbs[-1].text)69 self.assertEquals(
7170 "Access to %s" % self.ppa.displayname, crumbs[-1].text)
72def test_suite():
73 return unittest.TestLoader().loadTestsFromName(__name__)
7471
=== modified file 'lib/lp/soyuz/browser/tests/test_distrosourcepackagerelease.py'
--- lib/lp/soyuz/browser/tests/test_distrosourcepackagerelease.py 2010-07-06 11:52:17 +0000
+++ lib/lp/soyuz/browser/tests/test_distrosourcepackagerelease.py 2010-07-21 07:48:48 +0000
@@ -7,8 +7,6 @@
77
8__metaclass__ = type8__metaclass__ = type
99
10import unittest
11
12from zope.security.proxy import removeSecurityProxy10from zope.security.proxy import removeSecurityProxy
1311
14from canonical.testing import LaunchpadFunctionalLayer12from canonical.testing import LaunchpadFunctionalLayer
@@ -49,7 +47,3 @@
49 view = create_initialized_view(self.dspr, "+index")47 view = create_initialized_view(self.dspr, "+index")
50 html = view.__call__()48 html = view.__call__()
51 self.failUnless('test_file.dsc (deleted)' in html)49 self.failUnless('test_file.dsc (deleted)' in html)
52
53
54def test_suite():
55 return unittest.TestLoader().loadTestsFromName(__name__)
5650
=== modified file 'lib/lp/soyuz/browser/tests/test_queue.py'
--- lib/lp/soyuz/browser/tests/test_queue.py 2010-03-09 15:33:12 +0000
+++ lib/lp/soyuz/browser/tests/test_queue.py 2010-07-21 07:48:48 +0000
@@ -10,7 +10,6 @@
10 ]10 ]
1111
12import transaction12import transaction
13import unittest
14from zope.component import getUtility, queryMultiAdapter13from zope.component import getUtility, queryMultiAdapter
1514
16from canonical.launchpad.webapp.servers import LaunchpadTestRequest15from canonical.launchpad.webapp.servers import LaunchpadTestRequest
@@ -185,7 +184,3 @@
185 self.assertEquals(184 self.assertEquals(
186 'NEW',185 'NEW',
187 getUtility(IPackageUploadSet).get(package_upload_id).status.name)186 getUtility(IPackageUploadSet).get(package_upload_id).status.name)
188
189def test_suite():
190 return unittest.TestLoader().loadTestsFromName(__name__)
191
192187
=== modified file 'lib/lp/soyuz/browser/tests/test_sourcepackagerelease.py'
--- lib/lp/soyuz/browser/tests/test_sourcepackagerelease.py 2010-07-02 17:51:33 +0000
+++ lib/lp/soyuz/browser/tests/test_sourcepackagerelease.py 2010-07-21 07:48:48 +0000
@@ -11,8 +11,6 @@
11 'test_suite',11 'test_suite',
12 ]12 ]
1313
14import unittest
15
16from zope.security.proxy import removeSecurityProxy14from zope.security.proxy import removeSecurityProxy
1715
18from canonical.testing import (16from canonical.testing import (
@@ -109,6 +107,3 @@
109 view = create_initialized_view(107 view = create_initialized_view(
110 self.source_package_release, '+copyright')108 self.source_package_release, '+copyright')
111 self.assertEqual(expected, view.highlighted_copyright)109 self.assertEqual(expected, view.highlighted_copyright)
112
113def test_suite():
114 return unittest.TestLoader().loadTestsFromName(__name__)
115110
=== modified file 'lib/lp/soyuz/browser/tests/test_sourceslistentries.py'
--- lib/lp/soyuz/browser/tests/test_sourceslistentries.py 2009-09-07 14:54:34 +0000
+++ lib/lp/soyuz/browser/tests/test_sourceslistentries.py 2010-07-21 07:48:48 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4# pylint: disable-msg=F04014# pylint: disable-msg=F0401
@@ -13,8 +13,6 @@
13 'test_suite',13 'test_suite',
14 ]14 ]
1515
16import unittest
17
18from lp.testing import TestCaseWithFactory16from lp.testing import TestCaseWithFactory
1917
20from canonical.launchpad.webapp.servers import LaunchpadTestRequest18from canonical.launchpad.webapp.servers import LaunchpadTestRequest
@@ -23,6 +21,7 @@
23from lp.soyuz.browser.sourceslist import (21from lp.soyuz.browser.sourceslist import (
24 SourcesListEntries, SourcesListEntriesView)22 SourcesListEntries, SourcesListEntriesView)
2523
24
26class TestDefaultSelectedSeries(TestCaseWithFactory):25class TestDefaultSelectedSeries(TestCaseWithFactory):
27 """Ensure that default selected series set from user-agent."""26 """Ensure that default selected series set from user-agent."""
2827
@@ -166,6 +165,3 @@
166 # When there is only one distro series it should always be the165 # When there is only one distro series it should always be the
167 # default.166 # default.
168 self.failUnless(self.view.default_series == self.series[0])167 self.failUnless(self.view.default_series == self.series[0])
169
170def test_suite():
171 return unittest.TestLoader().loadTestsFromName(__name__)
172168
=== modified file 'lib/lp/soyuz/scripts/tests/test_archivecruftchecker.py'
--- lib/lp/soyuz/scripts/tests/test_archivecruftchecker.py 2009-08-28 06:39:38 +0000
+++ lib/lp/soyuz/scripts/tests/test_archivecruftchecker.py 2010-07-21 07:48:48 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""ArchiveCruftChecker tests.4"""ArchiveCruftChecker tests.
@@ -25,6 +25,7 @@
25from canonical.launchpad.scripts.logger import QuietFakeLogger25from canonical.launchpad.scripts.logger import QuietFakeLogger
26from canonical.testing import LaunchpadZopelessLayer26from canonical.testing import LaunchpadZopelessLayer
2727
28
28# XXX cprov 2006-05-15: {create, remove}TestArchive functions should be29# XXX cprov 2006-05-15: {create, remove}TestArchive functions should be
29# moved to the publisher test domain as soon as we have it.30# moved to the publisher test domain as soon as we have it.
30def createTestArchive():31def createTestArchive():
@@ -60,7 +61,6 @@
60 """Clean up test environment and remove the test archive."""61 """Clean up test environment and remove the test archive."""
61 removeTestArchive()62 removeTestArchive()
6263
63
64 def testInitializeSuccess(self):64 def testInitializeSuccess(self):
65 """Test ArchiveCruftChecker initialization process.65 """Test ArchiveCruftChecker initialization process.
6666
@@ -86,8 +86,7 @@
86 # based on the given 'archive_path'.86 # based on the given 'archive_path'.
87 self.assertEqual(87 self.assertEqual(
88 checker.dist_archive,88 checker.dist_archive,
89 '/var/tmp/archive/ubuntutest/dists/breezy-autotest'89 '/var/tmp/archive/ubuntutest/dists/breezy-autotest')
90 )
9190
92 # The 'components' dictionary contains all components selected91 # The 'components' dictionary contains all components selected
93 # for the given distroseries organized as:92 # for the given distroseries organized as:
@@ -111,7 +110,7 @@
111 'restricted',110 'restricted',
112 'restricted/debian-installer',111 'restricted/debian-installer',
113 'universe',112 'universe',
114 'universe/debian-installer'113 'universe/debian-installer',
115 ]114 ]
116 self.assertEqual(sorted(checker.components_and_di), expected)115 self.assertEqual(sorted(checker.components_and_di), expected)
117116
@@ -125,8 +124,7 @@
125124
126 self.assertEqual(125 self.assertEqual(
127 checker.dist_archive,126 checker.dist_archive,
128 '/var/tmp/archive/ubuntutest/dists/breezy-autotest-security'127 '/var/tmp/archive/ubuntutest/dists/breezy-autotest-security')
129 )
130128
131 def testInitializeFailure(self):129 def testInitializeFailure(self):
132 """ArchiveCruftCheck initialization failures.130 """ArchiveCruftCheck initialization failures.
@@ -149,7 +147,3 @@
149 self.log, distribution_name='ubuntu', suite='breezy-autotest',147 self.log, distribution_name='ubuntu', suite='breezy-autotest',
150 archive_path=self.archive_path)148 archive_path=self.archive_path)
151 self.assertRaises(ArchiveCruftCheckerError, checker.initialize)149 self.assertRaises(ArchiveCruftCheckerError, checker.initialize)
152
153
154def test_suite():
155 return unittest.TestLoader().loadTestsFromName(__name__)
156150
=== modified file 'lib/lp/soyuz/scripts/tests/test_buildd_cronscripts.py'
--- lib/lp/soyuz/scripts/tests/test_buildd_cronscripts.py 2010-05-20 14:28:51 +0000
+++ lib/lp/soyuz/scripts/tests/test_buildd_cronscripts.py 2010-07-21 07:48:48 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""cronscripts/buildd-* tests."""4"""cronscripts/buildd-* tests."""
@@ -149,12 +149,12 @@
149 qb = self.getQueueBuilder(distribution='boing')149 qb = self.getQueueBuilder(distribution='boing')
150 self.assertRaises(LaunchpadScriptFailure, qb.calculateDistroseries)150 self.assertRaises(LaunchpadScriptFailure, qb.calculateDistroseries)
151151
152 qb = self.getQueueBuilder(suites=('hoary-test',))152 qb = self.getQueueBuilder(suites=('hoary-test', ))
153 self.assertRaises(LaunchpadScriptFailure, qb.calculateDistroseries)153 self.assertRaises(LaunchpadScriptFailure, qb.calculateDistroseries)
154154
155 # A single valid suite argument results in a list with one155 # A single valid suite argument results in a list with one
156 # distroseries (pockets are completely ignored).156 # distroseries (pockets are completely ignored).
157 qb = self.getQueueBuilder(suites=('warty-security',))157 qb = self.getQueueBuilder(suites=('warty-security', ))
158 self.assertEqual(158 self.assertEqual(
159 ['warty'],159 ['warty'],
160 [distroseries.name160 [distroseries.name
@@ -179,7 +179,7 @@
179 # Restricting the build creation to another distroseries179 # Restricting the build creation to another distroseries
180 # does not create any builds.180 # does not create any builds.
181 source = self.getSourceWithoutBuilds()181 source = self.getSourceWithoutBuilds()
182 queue_builder = self.getQueueBuilder(suites=('warty',))182 queue_builder = self.getQueueBuilder(suites=('warty', ))
183 queue_builder.main()183 queue_builder.main()
184 self.assertEqual(0, len(source.getBuilds()))184 self.assertEqual(0, len(source.getBuilds()))
185185
@@ -187,7 +187,7 @@
187 # A build is created when queue-builder is restricted to the187 # A build is created when queue-builder is restricted to the
188 # distroseries where the testing source is published188 # distroseries where the testing source is published
189 source = self.getSourceWithoutBuilds()189 source = self.getSourceWithoutBuilds()
190 queue_builder = self.getQueueBuilder(suites=('hoary',))190 queue_builder = self.getQueueBuilder(suites=('hoary', ))
191 queue_builder.main()191 queue_builder.main()
192 self.assertEqual(1, len(source.getBuilds()))192 self.assertEqual(1, len(source.getBuilds()))
193193
@@ -303,7 +303,3 @@
303 self.getPendingBuilds().count())303 self.getPendingBuilds().count())
304 self.assertEqual(depwait_build.status.name, 'NEEDSBUILD')304 self.assertEqual(depwait_build.status.name, 'NEEDSBUILD')
305 self.assertEqual(depwait_build.buildqueue_record.lastscore, 1755)305 self.assertEqual(depwait_build.buildqueue_record.lastscore, 1755)
306
307
308def test_suite():
309 return unittest.TestLoader().loadTestsFromName(__name__)
310306
=== modified file 'lib/lp/soyuz/scripts/tests/test_changeoverride.py'
--- lib/lp/soyuz/scripts/tests/test_changeoverride.py 2009-08-28 07:34:44 +0000
+++ lib/lp/soyuz/scripts/tests/test_changeoverride.py 2010-07-21 07:48:48 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""`ChangeOverride` script class tests."""4"""`ChangeOverride` script class tests."""
@@ -517,7 +517,3 @@
517 SoyuzScriptError, changer.processBinaryChange, 'biscuit')517 SoyuzScriptError, changer.processBinaryChange, 'biscuit')
518 self.assertRaises(518 self.assertRaises(
519 SoyuzScriptError, changer.processChildrenChange, 'cookie')519 SoyuzScriptError, changer.processChildrenChange, 'cookie')
520
521
522def test_suite():
523 return unittest.TestLoader().loadTestsFromName(__name__)
524520
=== modified file 'lib/lp/soyuz/scripts/tests/test_chrootmanager.py'
--- lib/lp/soyuz/scripts/tests/test_chrootmanager.py 2009-06-25 04:06:00 +0000
+++ lib/lp/soyuz/scripts/tests/test_chrootmanager.py 2010-07-21 07:48:48 +0000
@@ -1,11 +1,11 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""ChrootManager facilities tests."""4"""ChrootManager facilities tests."""
55
6__metaclass__ = type6__metaclass__ = type
77
8from unittest import TestCase, TestLoader8from unittest import TestCase
9import os9import os
10import re10import re
11import tempfile11import tempfile
@@ -157,7 +157,3 @@
157157
158 self.assertRaises(158 self.assertRaises(
159 ChrootManagerError, chroot_manager.add)159 ChrootManagerError, chroot_manager.add)
160
161
162def test_suite():
163 return TestLoader().loadTestsFromName(__name__)
164160
=== modified file 'lib/lp/soyuz/scripts/tests/test_copypackage.py'
--- lib/lp/soyuz/scripts/tests/test_copypackage.py 2010-05-26 08:54:17 +0000
+++ lib/lp/soyuz/scripts/tests/test_copypackage.py 2010-07-21 07:48:48 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4__metaclass__ = type4__metaclass__ = type
@@ -1352,8 +1352,7 @@
1352 self.assertEqual(1352 self.assertEqual(
1353 sorted(copied_ids), sorted(pending_ids),1353 sorted(copied_ids), sorted(pending_ids),
1354 "The copy did not succeed.\nExpected IDs: %s\nFound IDs: %s" % (1354 "The copy did not succeed.\nExpected IDs: %s\nFound IDs: %s" % (
1355 sorted(copied_ids), sorted(pending_ids))1355 sorted(copied_ids), sorted(pending_ids)))
1356 )
13571356
1358 def testCopyBetweenDistroSeries(self):1357 def testCopyBetweenDistroSeries(self):
1359 """Check the copy operation between distroseries."""1358 """Check the copy operation between distroseries."""
@@ -2275,7 +2274,7 @@
2275 "--ppa", "joe",2274 "--ppa", "joe",
2276 "--ppa-name", "ppa",2275 "--ppa-name", "ppa",
2277 "-s", "%s" % ppa_source.distroseries.name + "-security",2276 "-s", "%s" % ppa_source.distroseries.name + "-security",
2278 "foo"2277 "foo",
2279 ]2278 ]
22802279
2281 script = UnembargoSecurityPackage(2280 script = UnembargoSecurityPackage(
@@ -2324,7 +2323,7 @@
2324 test_args = [2323 test_args = [
2325 "--ppa", "cprov",2324 "--ppa", "cprov",
2326 "-s", "warty-backports",2325 "-s", "warty-backports",
2327 "foo"2326 "foo",
2328 ]2327 ]
23292328
2330 script = UnembargoSecurityPackage(2329 script = UnembargoSecurityPackage(
@@ -2641,7 +2640,3 @@
2641 None,2640 None,
2642 checker.checkCopy(test2_source, warty,2641 checker.checkCopy(test2_source, warty,
2643 PackagePublishingPocket.RELEASE))2642 PackagePublishingPocket.RELEASE))
2644
2645
2646def test_suite():
2647 return unittest.TestLoader().loadTestsFromName(__name__)
26482643
=== modified file 'lib/lp/soyuz/scripts/tests/test_expire_archive_files.py'
--- lib/lp/soyuz/scripts/tests/test_expire_archive_files.py 2010-03-10 11:13:55 +0000
+++ lib/lp/soyuz/scripts/tests/test_expire_archive_files.py 2010-07-21 07:48:48 +0000
@@ -1,11 +1,10 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Test the expire-archive-files.py script. """4"""Test the expire-archive-files.py script. """
55
6from datetime import datetime, timedelta6from datetime import datetime, timedelta
7import pytz7import pytz
8import unittest
98
10from zope.component import getUtility9from zope.component import getUtility
1110
@@ -99,9 +98,10 @@
9998
100class ArchiveExpiryCommonTests(object):99class ArchiveExpiryCommonTests(object):
101 """Common source/binary expiration test cases.100 """Common source/binary expiration test cases.
102 101
103 These will be shared irrespective of archive type (ppa/partner).102 These will be shared irrespective of archive type (ppa/partner).
104 """103 """
104
105 def testNoExpirationWithNoDateremoved(self):105 def testNoExpirationWithNoDateremoved(self):
106 """Test that no expiring happens if no dateremoved set."""106 """Test that no expiring happens if no dateremoved set."""
107 pkg1 = self.stp.getPubSource(107 pkg1 = self.stp.getPubSource(
@@ -216,7 +216,7 @@
216216
217class TestPPAExpiry(ArchiveExpiryTestBase, ArchiveExpiryCommonTests):217class TestPPAExpiry(ArchiveExpiryTestBase, ArchiveExpiryCommonTests):
218 """Test the expire-archive-files.py script.218 """Test the expire-archive-files.py script.
219 219
220 Here we make use of the common test cases defined in the base class but220 Here we make use of the common test cases defined in the base class but
221 also add tests specific to PPAs (excluding particular PPAs from expiry221 also add tests specific to PPAs (excluding particular PPAs from expiry
222 based on a "black list" or on the fact that PPA is private).222 based on a "black list" or on the fact that PPA is private).
@@ -262,7 +262,3 @@
262 purpose=ArchivePurpose.PARTNER)262 purpose=ArchivePurpose.PARTNER)
263 self.archive2 = self.factory.makeArchive(263 self.archive2 = self.factory.makeArchive(
264 purpose=ArchivePurpose.PARTNER)264 purpose=ArchivePurpose.PARTNER)
265
266
267def test_suite():
268 return unittest.TestLoader().loadTestsFromName(__name__)
269265
=== modified file 'lib/lp/soyuz/scripts/tests/test_gina.py'
--- lib/lp/soyuz/scripts/tests/test_gina.py 2010-07-14 14:11:15 +0000
+++ lib/lp/soyuz/scripts/tests/test_gina.py 2010-07-21 07:48:48 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4import unittest4import unittest
@@ -12,4 +12,3 @@
12 suite = unittest.TestSuite()12 suite = unittest.TestSuite()
13 suite.addTest(DocTestSuite(lp.soyuz.scripts.gina.handlers))13 suite.addTest(DocTestSuite(lp.soyuz.scripts.gina.handlers))
14 return suite14 return suite
15
1615
=== modified file 'lib/lp/soyuz/scripts/tests/test_lpquerydistro.py'
--- lib/lp/soyuz/scripts/tests/test_lpquerydistro.py 2009-12-13 11:55:40 +0000
+++ lib/lp/soyuz/scripts/tests/test_lpquerydistro.py 2010-07-21 07:48:48 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4__metaclass__ = type4__metaclass__ = type
@@ -65,7 +65,7 @@
65 Check that:65 Check that:
66 * return code is ONE,66 * return code is ONE,
67 * standard output is empty67 * standard output is empty
68 * standard error contains the additional information about the failure.68 * standard error contains additional information about the failure.
69 """69 """
70 returncode, out, err = self.runLpQueryDistro(70 returncode, out, err = self.runLpQueryDistro(
71 extra_args=[])71 extra_args=[])
@@ -103,7 +103,7 @@
103 Check if:103 Check if:
104 * return code is ONE,104 * return code is ONE,
105 * standard output is empty105 * standard output is empty
106 * standard error contains the additional information about the failure.106 * standard error contains additional information about the failure.
107 """107 """
108 returncode, out, err = self.runLpQueryDistro(108 returncode, out, err = self.runLpQueryDistro(
109 extra_args=['-s', 'hoary', 'current'])109 extra_args=['-s', 'hoary', 'current'])
@@ -257,7 +257,3 @@
257 self.assertEqual(helper.nominated_arch_indep, 'i386')257 self.assertEqual(helper.nominated_arch_indep, 'i386')
258 self.assertEqual(helper.pocket_suffixes,258 self.assertEqual(helper.pocket_suffixes,
259 '-backports -proposed -security -updates')259 '-backports -proposed -security -updates')
260
261
262def test_suite():
263 return unittest.TestLoader().loadTestsFromName(__name__)
264260
=== modified file 'lib/lp/soyuz/scripts/tests/test_obsoletedistroseries.py'
--- lib/lp/soyuz/scripts/tests/test_obsoletedistroseries.py 2010-01-31 19:36:27 +0000
+++ lib/lp/soyuz/scripts/tests/test_obsoletedistroseries.py 2010-07-21 07:48:48 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4__metaclass__ = type4__metaclass__ = type
@@ -21,6 +21,7 @@
21from lp.registry.interfaces.distribution import IDistributionSet21from lp.registry.interfaces.distribution import IDistributionSet
22from lp.registry.interfaces.series import SeriesStatus22from lp.registry.interfaces.series import SeriesStatus
23from lp.soyuz.interfaces.publishing import PackagePublishingStatus23from lp.soyuz.interfaces.publishing import PackagePublishingStatus
24from lp.testing.fakemethod import FakeMethod
24from canonical.testing import LaunchpadZopelessLayer25from canonical.testing import LaunchpadZopelessLayer
2526
2627
@@ -82,8 +83,10 @@
82 Allow tests to use a set of default options and pass an83 Allow tests to use a set of default options and pass an
83 inactive logger to ObsoleteDistroseries.84 inactive logger to ObsoleteDistroseries.
84 """85 """
85 test_args = ['-s', suite,86 test_args = [
86 '-d', distribution,]87 '-s', suite,
88 '-d', distribution,
89 ]
8790
88 if confirm_all:91 if confirm_all:
89 test_args.append('-y')92 test_args.append('-y')
@@ -92,9 +95,7 @@
92 name='obsolete-distroseries', test_args=test_args)95 name='obsolete-distroseries', test_args=test_args)
93 # Swallow all log messages.96 # Swallow all log messages.
94 obsoleter.logger = FakeLogger()97 obsoleter.logger = FakeLogger()
95 def message(self, prefix, *stuff, **kw):98 obsoleter.logger.message = FakeMethod()
96 pass
97 obsoleter.logger.message = message
98 obsoleter.setupLocation()99 obsoleter.setupLocation()
99 return obsoleter100 return obsoleter
100101
@@ -208,7 +209,3 @@
208 binary = BinaryPackagePublishingHistory.get(id)209 binary = BinaryPackagePublishingHistory.get(id)
209 self.assertTrue(210 self.assertTrue(
210 binary.status != PackagePublishingStatus.OBSOLETE)211 binary.status != PackagePublishingStatus.OBSOLETE)
211
212
213def test_suite():
214 return unittest.TestLoader().loadTestsFromName(__name__)
215212
=== modified file 'lib/lp/soyuz/scripts/tests/test_overrides_checker.py'
--- lib/lp/soyuz/scripts/tests/test_overrides_checker.py 2009-06-25 04:06:00 +0000
+++ lib/lp/soyuz/scripts/tests/test_overrides_checker.py 2010-07-21 07:48:48 +0000
@@ -1,11 +1,11 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""archive-override-check tool base class tests."""4"""archive-override-check tool base class tests."""
55
6__metaclass__ = type6__metaclass__ = type
77
8from unittest import TestCase, TestLoader8from unittest import TestCase
9from lp.soyuz.scripts.ftpmaster import (9from lp.soyuz.scripts.ftpmaster import (
10 PubBinaryDetails, PubSourceChecker, PubBinaryContent)10 PubBinaryDetails, PubSourceChecker, PubBinaryContent)
1111
@@ -29,7 +29,7 @@
29 1, len(self.binary_details.priorities['foo-dev']))29 1, len(self.binary_details.priorities['foo-dev']))
30 # not correct value was set yet30 # not correct value was set yet
31 self.assertEqual(31 self.assertEqual(
32 False, self.binary_details.correct_priorities.has_key('foo-dev'))32 False, 'foo-dev' in self.binary_details.correct_priorities)
33 # set correct values33 # set correct values
34 self.binary_details.setCorrectValues()34 self.binary_details.setCorrectValues()
35 # now we have the correct value in place35 # now we have the correct value in place
@@ -151,7 +151,6 @@
151 "\t\tW: Priority mismatch: EXTRA != REQUIRED",151 "\t\tW: Priority mismatch: EXTRA != REQUIRED",
152 checker.renderReport())152 checker.renderReport())
153153
154
155 def test_multi_binary_priority_success(self):154 def test_multi_binary_priority_success(self):
156 """Probe multiple binaries with correct priorities.155 """Probe multiple binaries with correct priorities.
157156
@@ -169,7 +168,3 @@
169 checker.check()168 checker.check()
170169
171 self.assertEqual(None, checker.renderReport())170 self.assertEqual(None, checker.renderReport())
172
173
174def test_suite():
175 return TestLoader().loadTestsFromName(__name__)
176171
=== modified file 'lib/lp/soyuz/scripts/tests/test_populatearchive.py'
--- lib/lp/soyuz/scripts/tests/test_populatearchive.py 2010-07-15 21:30:26 +0000
+++ lib/lp/soyuz/scripts/tests/test_populatearchive.py 2010-07-21 07:48:48 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4__metaclass__ = type4__metaclass__ = type
@@ -8,7 +8,6 @@
8import subprocess8import subprocess
9import sys9import sys
10import time10import time
11import unittest
1211
13from zope.component import getUtility12from zope.component import getUtility
14from zope.security.proxy import removeSecurityProxy13from zope.security.proxy import removeSecurityProxy
@@ -29,6 +28,7 @@
29from lp.soyuz.scripts.populate_archive import ArchivePopulator28from lp.soyuz.scripts.populate_archive import ArchivePopulator
30from lp.soyuz.tests.test_publishing import SoyuzTestPublisher29from lp.soyuz.tests.test_publishing import SoyuzTestPublisher
31from lp.testing import TestCaseWithFactory30from lp.testing import TestCaseWithFactory
31from lp.testing.faketransaction import FakeTransaction
3232
3333
34def get_spn(build):34def get_spn(build):
@@ -179,11 +179,6 @@
179 the script179 the script
180 :param output_substr: this must be part of the script's output180 :param output_substr: this must be part of the script's output
181 """181 """
182 class FakeZopeTransactionManager:
183 def commit(self):
184 pass
185 def begin(self):
186 pass
187182
188 if copy_archive_name is None:183 if copy_archive_name is None:
189 now = int(time.time())184 now = int(time.time())
@@ -211,7 +206,7 @@
211 script_args = [206 script_args = [
212 '--from-distribution', distro_name, '--from-suite', suite,207 '--from-distribution', distro_name, '--from-suite', suite,
213 '--to-distribution', distro_name, '--to-suite', suite,208 '--to-distribution', distro_name, '--to-suite', suite,
214 '--to-archive', archive_name, '--to-user', user209 '--to-archive', archive_name, '--to-user', user,
215 ]210 ]
216211
217 # Empty reason string indicates that the '--reason' command line212 # Empty reason string indicates that the '--reason' command line
@@ -233,7 +228,7 @@
233 test_args=script_args)228 test_args=script_args)
234229
235 script.logger = BufferLogger()230 script.logger = BufferLogger()
236 script.txn = FakeZopeTransactionManager()231 script.txn = FakeTransaction()
237232
238 if exception_type is not None:233 if exception_type is not None:
239 self.assertRaisesWithContent(234 self.assertRaisesWithContent(
@@ -393,9 +388,10 @@
393 # The set of packages that were superseded in the target archive.388 # The set of packages that were superseded in the target archive.
394 obsolete=set(['alsa-utils 1.0.9a-4ubuntu1 in hoary']),389 obsolete=set(['alsa-utils 1.0.9a-4ubuntu1 in hoary']),
395 # The set of packages that are new/fresher in the source archive.390 # The set of packages that are new/fresher in the source archive.
396 new=set(['alsa-utils 2.0 in hoary',391 new=set([
397 'new-in-second-round 1.0 in hoary'])392 'alsa-utils 2.0 in hoary',
398 )393 'new-in-second-round 1.0 in hoary',
394 ]))
399395
400 # Now populate a 3rd copy archive from the first ubuntu/hoary396 # Now populate a 3rd copy archive from the first ubuntu/hoary
401 # snapshot.397 # snapshot.
@@ -423,9 +419,10 @@
423 # The set of packages that were superseded in the target archive.419 # The set of packages that were superseded in the target archive.
424 obsolete=set(['alsa-utils 1.0.9a-4ubuntu1 in hoary']),420 obsolete=set(['alsa-utils 1.0.9a-4ubuntu1 in hoary']),
425 # The set of packages that are new/fresher in the source archive.421 # The set of packages that are new/fresher in the source archive.
426 new=set(['alsa-utils 2.0 in hoary',422 new=set([
427 'new-in-second-round 1.0 in hoary'])423 'alsa-utils 2.0 in hoary',
428 )424 'new-in-second-round 1.0 in hoary',
425 ]))
429426
430 def testUnknownOriginArchive(self):427 def testUnknownOriginArchive(self):
431 """Try copy archive population with a unknown origin archive.428 """Try copy archive population with a unknown origin archive.
@@ -558,6 +555,7 @@
558555
559 def testBuildsPendingAndSuspended(self):556 def testBuildsPendingAndSuspended(self):
560 """All builds in the new copy archive are pending and suspended."""557 """All builds in the new copy archive are pending and suspended."""
558
561 def build_in_wrong_state(build):559 def build_in_wrong_state(build):
562 """True if the given build is not (pending and suspended)."""560 """True if the given build is not (pending and suspended)."""
563 return not (561 return not (
@@ -584,7 +582,7 @@
584 # - binary build: pending582 # - binary build: pending
585 # - job: suspended583 # - job: suspended
586 builds_in_wrong_state = filter(build_in_wrong_state, builds)584 builds_in_wrong_state = filter(build_in_wrong_state, builds)
587 self.assertEqual (585 self.assertEqual(
588 [], builds_in_wrong_state,586 [], builds_in_wrong_state,
589 "The binary builds generated for the target copy archive "587 "The binary builds generated for the target copy archive "
590 "should all be pending and suspended. However, at least one of "588 "should all be pending and suspended. However, at least one of "
@@ -698,6 +696,3 @@
698 # Make sure the source to be copied are the ones we expect (this696 # Make sure the source to be copied are the ones we expect (this
699 # should break in case of a sample data change/corruption).697 # should break in case of a sample data change/corruption).
700 self.assertEqual(src_names, self.expected_src_names)698 self.assertEqual(src_names, self.expected_src_names)
701
702def test_suite():
703 return unittest.TestLoader().loadTestsFromName(__name__)
704699
=== modified file 'lib/lp/soyuz/scripts/tests/test_ppa_apache_log_parser.py'
--- lib/lp/soyuz/scripts/tests/test_ppa_apache_log_parser.py 2010-03-16 09:52:53 +0000
+++ lib/lp/soyuz/scripts/tests/test_ppa_apache_log_parser.py 2010-07-21 07:48:48 +0000
@@ -3,7 +3,6 @@
33
4from datetime import date4from datetime import date
5import subprocess5import subprocess
6import unittest
76
8from zope.component import getUtility7from zope.component import getUtility
98
@@ -128,7 +127,3 @@
128 [(result.binary_package_release, result.archive, result.day,127 [(result.binary_package_release, result.archive, result.day,
129 result.country, result.count) for result in results],128 result.country, result.count) for result in results],
130 key=lambda r: (r[0].id, r[2], r[3].name if r[3] else None)))129 key=lambda r: (r[0].id, r[2], r[3].name if r[3] else None)))
131
132
133def test_suite():
134 return unittest.TestLoader().loadTestsFromName(__name__)
135130
=== modified file 'lib/lp/soyuz/scripts/tests/test_ppakeygenerator.py'
--- lib/lp/soyuz/scripts/tests/test_ppakeygenerator.py 2009-06-25 04:06:00 +0000
+++ lib/lp/soyuz/scripts/tests/test_ppakeygenerator.py 2010-07-21 07:48:48 +0000
@@ -1,12 +1,10 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""`PPAKeyGenerator` script class tests."""4"""`PPAKeyGenerator` script class tests."""
55
6__metaclass__ = type6__metaclass__ = type
77
8import unittest
9
10from zope.component import getUtility8from zope.component import getUtility
119
12from lp.soyuz.interfaces.archive import IArchiveSet10from lp.soyuz.interfaces.archive import IArchiveSet
@@ -16,32 +14,13 @@
16from lp.services.scripts.base import LaunchpadScriptFailure14from lp.services.scripts.base import LaunchpadScriptFailure
17from lp.soyuz.scripts.ppakeygenerator import PPAKeyGenerator15from lp.soyuz.scripts.ppakeygenerator import PPAKeyGenerator
18from lp.testing import TestCase16from lp.testing import TestCase
17from lp.testing.faketransaction import FakeTransaction
19from canonical.testing import LaunchpadZopelessLayer18from canonical.testing import LaunchpadZopelessLayer
2019
2120
22class TestPPAKeyGenerator(TestCase):21class TestPPAKeyGenerator(TestCase):
23 layer = LaunchpadZopelessLayer22 layer = LaunchpadZopelessLayer
2423
25 def _getFakeZTM(self):
26 """Return an instrumented `ZopeTransactionManager`-like object.
27
28 I does nothing apart counting the number of commits issued.
29
30 The result is stored in the 'number_of_commits'.
31 """
32 self.number_of_commits = 0
33
34 def commit_called():
35 self.number_of_commits += 1
36
37 class FakeZTM:
38 def commit(self):
39 commit_called()
40 def begin(self):
41 pass
42
43 return FakeZTM()
44
45 def _fixArchiveForKeyGeneration(self, archive):24 def _fixArchiveForKeyGeneration(self, archive):
46 """Override the given archive distribution to 'ubuntutest'.25 """Override the given archive distribution to 'ubuntutest'.
4726
@@ -51,12 +30,12 @@
51 ubuntutest = getUtility(IDistributionSet).getByName('ubuntutest')30 ubuntutest = getUtility(IDistributionSet).getByName('ubuntutest')
52 archive.distribution = ubuntutest31 archive.distribution = ubuntutest
5332
54 def _getKeyGenerator(self, ppa_owner_name=None):33 def _getKeyGenerator(self, ppa_owner_name=None, txn=None):
55 """Return a `PPAKeyGenerator` instance.34 """Return a `PPAKeyGenerator` instance.
5635
57 Monkey-patch the script object transaction manager (see36 Monkey-patch the script object with a fake transaction manager
58 `_getFakeZTM`) and also to use a alternative (fake and lighter)37 and also make it use an alternative (fake and lighter) procedure
59 procedure to generate keys for each PPA.38 to generate keys for each PPA.
60 """39 """
61 test_args = []40 test_args = []
6241
@@ -66,7 +45,9 @@
66 key_generator = PPAKeyGenerator(45 key_generator = PPAKeyGenerator(
67 name='ppa-generate-keys', test_args=test_args)46 name='ppa-generate-keys', test_args=test_args)
6847
69 key_generator.txn = self._getFakeZTM()48 if txn is None:
49 txn = FakeTransaction()
50 key_generator.txn = txn
7051
71 def fake_key_generation(archive):52 def fake_key_generation(archive):
72 a_key = getUtility(IGPGKeySet).get(1)53 a_key = getUtility(IGPGKeySet).get(1)
@@ -102,7 +83,7 @@
102 self.assertRaisesWithContent(83 self.assertRaisesWithContent(
103 LaunchpadScriptFailure,84 LaunchpadScriptFailure,
104 ("PPA for Celso Providelo already has a signing_key (%s)" %85 ("PPA for Celso Providelo already has a signing_key (%s)" %
105 cprov.archive.signing_key.fingerprint) ,86 cprov.archive.signing_key.fingerprint),
106 key_generator.main)87 key_generator.main)
10788
108 def testGenerateKeyForASinglePPA(self):89 def testGenerateKeyForASinglePPA(self):
@@ -116,11 +97,12 @@
11697
117 self.assertTrue(cprov.archive.signing_key is None)98 self.assertTrue(cprov.archive.signing_key is None)
11899
119 key_generator = self._getKeyGenerator(ppa_owner_name='cprov')100 txn = FakeTransaction()
101 key_generator = self._getKeyGenerator(ppa_owner_name='cprov', txn=txn)
120 key_generator.main()102 key_generator.main()
121103
122 self.assertTrue(cprov.archive.signing_key is not None)104 self.assertTrue(cprov.archive.signing_key is not None)
123 self.assertEquals(self.number_of_commits, 1)105 self.assertEquals(txn.commit_count, 1)
124106
125 def testGenerateKeyForAllPPA(self):107 def testGenerateKeyForAllPPA(self):
126 """Signing key generation for all PPAs.108 """Signing key generation for all PPAs.
@@ -134,14 +116,11 @@
134 self._fixArchiveForKeyGeneration(archive)116 self._fixArchiveForKeyGeneration(archive)
135 self.assertTrue(archive.signing_key is None)117 self.assertTrue(archive.signing_key is None)
136118
137 key_generator = self._getKeyGenerator()119 txn = FakeTransaction()
120 key_generator = self._getKeyGenerator(txn=txn)
138 key_generator.main()121 key_generator.main()
139122
140 for archive in archives:123 for archive in archives:
141 self.assertTrue(archive.signing_key is not None)124 self.assertTrue(archive.signing_key is not None)
142125
143 self.assertEquals(self.number_of_commits, len(archives))126 self.assertEquals(txn.commit_count, len(archives))
144
145
146def test_suite():
147 return unittest.TestLoader().loadTestsFromName(__name__)
148127
=== modified file 'lib/lp/soyuz/scripts/tests/test_ppareport.py'
--- lib/lp/soyuz/scripts/tests/test_ppareport.py 2009-08-13 19:03:36 +0000
+++ lib/lp/soyuz/scripts/tests/test_ppareport.py 2010-07-21 07:48:48 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Tests for `PPAReportScript.` """4"""Tests for `PPAReportScript.` """
@@ -16,6 +16,7 @@
16from canonical.testing import LaunchpadZopelessLayer16from canonical.testing import LaunchpadZopelessLayer
17from lp.services.scripts.base import LaunchpadScriptFailure17from lp.services.scripts.base import LaunchpadScriptFailure
18from lp.soyuz.scripts.ppareport import PPAReportScript18from lp.soyuz.scripts.ppareport import PPAReportScript
19from lp.testing.fakemethod import FakeMethod
1920
2021
21class TestPPAReport(unittest.TestCase):22class TestPPAReport(unittest.TestCase):
@@ -68,13 +69,12 @@
68 # Override the output handlers if no 'output' option was passed69 # Override the output handlers if no 'output' option was passed
69 # via command-line.70 # via command-line.
70 if output is None:71 if output is None:
72
71 def set_test_output():73 def set_test_output():
72 reporter.output = StringIO()74 reporter.output = StringIO()
73 reporter.setOutput = set_test_output75 reporter.setOutput = set_test_output
7476
75 def close_test_output():77 reporter.closeOutput = FakeMethod()
76 pass
77 reporter.closeOutput = close_test_output
7878
79 return reporter79 return reporter
8080
@@ -137,8 +137,7 @@
137 reporter.output.getvalue().splitlines(), [137 reporter.output.getvalue().splitlines(), [
138 '= PPAs over 80.00% of their quota =',138 '= PPAs over 80.00% of their quota =',
139 '',139 '',
140 ]140 ])
141 )
142141
143 # Quota threshold can be specified.142 # Quota threshold can be specified.
144 reporter = self.getReporter(quota_threshold=.01)143 reporter = self.getReporter(quota_threshold=.01)
@@ -150,8 +149,7 @@
150 'http://launchpad.dev/~cprov/+archive/ppa | 1024 | 9',149 'http://launchpad.dev/~cprov/+archive/ppa | 1024 | 9',
151 'http://launchpad.dev/~mark/+archive/ppa | 1024 | 9',150 'http://launchpad.dev/~mark/+archive/ppa | 1024 | 9',
152 '',151 '',
153 ]152 ])
154 )
155153
156 def testUserEmails(self):154 def testUserEmails(self):
157 # UserEmails report lists user name, user displayname and user155 # UserEmails report lists user name, user displayname and user
@@ -166,8 +164,7 @@
166 'cprov | Celso Providelo | celso.providelo@canonical.com',164 'cprov | Celso Providelo | celso.providelo@canonical.com',
167 'mark | Mark Shuttleworth | mark@example.com',165 'mark | Mark Shuttleworth | mark@example.com',
168 '',166 '',
169 ]167 ])
170 )
171168
172 # UserEmails report can be generated for a single PPA.169 # UserEmails report can be generated for a single PPA.
173 reporter = self.getReporter(ppa_owner='cprov')170 reporter = self.getReporter(ppa_owner='cprov')
@@ -178,8 +175,7 @@
178 '= PPA user emails =',175 '= PPA user emails =',
179 'cprov | Celso Providelo | celso.providelo@canonical.com',176 'cprov | Celso Providelo | celso.providelo@canonical.com',
180 '',177 '',
181 ]178 ])
182 )
183179
184 def testOrphanRepos(self):180 def testOrphanRepos(self):
185 # OrphanRepos report lists all directories in the PPA root that181 # OrphanRepos report lists all directories in the PPA root that
@@ -192,8 +188,7 @@
192 reporter.output.getvalue().splitlines(), [188 reporter.output.getvalue().splitlines(), [
193 '= Orphan PPA repositories =',189 '= Orphan PPA repositories =',
194 '',190 '',
195 ]191 ])
196 )
197 # We create a 'orphan' repository.192 # We create a 'orphan' repository.
198 orphan_repo = os.path.join(193 orphan_repo = os.path.join(
199 config.personalpackagearchive.root, 'orphan')194 config.personalpackagearchive.root, 'orphan')
@@ -208,8 +203,7 @@
208 '= Orphan PPA repositories =',203 '= Orphan PPA repositories =',
209 '/var/tmp/ppa.test/orphan',204 '/var/tmp/ppa.test/orphan',
210 '',205 '',
211 ]206 ])
212 )
213 # Remove the orphan directory.207 # Remove the orphan directory.
214 shutil.rmtree(orphan_repo)208 shutil.rmtree(orphan_repo)
215209
@@ -226,8 +220,7 @@
226 '/var/tmp/ppa.test/cprov',220 '/var/tmp/ppa.test/cprov',
227 '/var/tmp/ppa.test/mark',221 '/var/tmp/ppa.test/mark',
228 '',222 '',
229 ]223 ])
230 )
231 # We create both active PPA repositories.224 # We create both active PPA repositories.
232 owner_names = [ppa.owner.name for ppa in reporter.ppas]225 owner_names = [ppa.owner.name for ppa in reporter.ppas]
233 created_repos = []226 created_repos = []
@@ -245,8 +238,7 @@
245 reporter.output.getvalue().splitlines(), [238 reporter.output.getvalue().splitlines(), [
246 '= Missing PPA repositories =',239 '= Missing PPA repositories =',
247 '',240 '',
248 ]241 ])
249 )
250242
251 # Remove the created repositories.243 # Remove the created repositories.
252 for repo_path in created_repos:244 for repo_path in created_repos:
@@ -261,13 +253,12 @@
261 gen_missing_repos=True, output=output_path)253 gen_missing_repos=True, output=output_path)
262 reporter.main()254 reporter.main()
263 self.assertEquals(255 self.assertEquals(
264 open(output_path).read().splitlines(),[256 open(output_path).read().splitlines(), [
265 '= Missing PPA repositories =',257 '= Missing PPA repositories =',
266 '/var/tmp/ppa.test/cprov',258 '/var/tmp/ppa.test/cprov',
267 '/var/tmp/ppa.test/mark',259 '/var/tmp/ppa.test/mark',
268 '',260 '',
269 ]261 ])
270 )
271 # Remove the report file.262 # Remove the report file.
272 os.remove(output_path)263 os.remove(output_path)
273264
@@ -288,8 +279,7 @@
288 '/var/tmp/ppa.test/cprov',279 '/var/tmp/ppa.test/cprov',
289 '/var/tmp/ppa.test/mark',280 '/var/tmp/ppa.test/mark',
290 '',281 '',
291 ]282 ])
292 )
293 # Another run for generating user emails report283 # Another run for generating user emails report
294 reporter = self.getReporter(gen_user_emails=True)284 reporter = self.getReporter(gen_user_emails=True)
295 reporter.main()285 reporter.main()
@@ -299,9 +289,4 @@
299 'cprov | Celso Providelo | celso.providelo@canonical.com',289 'cprov | Celso Providelo | celso.providelo@canonical.com',
300 'mark | Mark Shuttleworth | mark@example.com',290 'mark | Mark Shuttleworth | mark@example.com',
301 '',291 '',
302 ]292 ])
303 )
304
305
306def test_suite():
307 return unittest.TestLoader().loadTestsFromName(__name__)
308293
=== modified file 'lib/lp/soyuz/scripts/tests/test_processdeathrow.py'
--- lib/lp/soyuz/scripts/tests/test_processdeathrow.py 2009-11-15 19:52:54 +0000
+++ lib/lp/soyuz/scripts/tests/test_processdeathrow.py 2010-07-21 07:48:48 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Functional tests for process-death-row.py script.4"""Functional tests for process-death-row.py script.
@@ -17,7 +17,7 @@
17import subprocess17import subprocess
18import sys18import sys
19from tempfile import mkdtemp19from tempfile import mkdtemp
20from unittest import TestCase, TestLoader20from unittest import TestCase
2121
22from zope.component import getUtility22from zope.component import getUtility
23from zope.security.proxy import removeSecurityProxy23from zope.security.proxy import removeSecurityProxy
@@ -204,7 +204,3 @@
204 self.probePublishingStatus(204 self.probePublishingStatus(
205 self.ppa_pubrec_ids, PackagePublishingStatus.SUPERSEDED)205 self.ppa_pubrec_ids, PackagePublishingStatus.SUPERSEDED)
206 self.probeRemoved(self.ppa_pubrec_ids)206 self.probeRemoved(self.ppa_pubrec_ids)
207
208
209def test_suite():
210 return TestLoader().loadTestsFromName(__name__)
211207
=== modified file 'lib/lp/soyuz/scripts/tests/test_processpendingpackagediffs.py'
--- lib/lp/soyuz/scripts/tests/test_processpendingpackagediffs.py 2010-02-04 17:08:01 +0000
+++ lib/lp/soyuz/scripts/tests/test_processpendingpackagediffs.py 2010-07-21 07:48:48 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4__metaclass__ = type4__metaclass__ = type
@@ -6,9 +6,6 @@
6import os6import os
7import subprocess7import subprocess
8import sys8import sys
9import unittest
10
11from zope.component import getUtility
129
13from canonical.config import config10from canonical.config import config
14from canonical.launchpad.scripts import QuietFakeLogger11from canonical.launchpad.scripts import QuietFakeLogger
@@ -107,6 +104,3 @@
107 # The next run process the remaining one.104 # The next run process the remaining one.
108 diff_processor.main()105 diff_processor.main()
109 self.assertEqual(self.getPendingDiffs().count(), 0)106 self.assertEqual(self.getPendingDiffs().count(), 0)
110
111def test_suite():
112 return unittest.TestLoader().loadTestsFromName(__name__)
113107
=== modified file 'lib/lp/soyuz/scripts/tests/test_processupload.py'
--- lib/lp/soyuz/scripts/tests/test_processupload.py 2010-04-23 22:47:35 +0000
+++ lib/lp/soyuz/scripts/tests/test_processupload.py 2010-07-21 07:48:48 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4__metaclass__ = type4__metaclass__ = type
@@ -58,7 +58,7 @@
58 # No scriptactivity should exist before it's run.58 # No scriptactivity should exist before it's run.
59 activity = getUtility(59 activity = getUtility(
60 IScriptActivitySet).getLastActivity('process-upload')60 IScriptActivitySet).getLastActivity('process-upload')
61 self.assertTrue(activity is None, "'activity' should be None")61 self.assertTrue(activity is None, "'activity' should be None")
6262
63 returncode, out, err = self.runProcessUpload()63 returncode, out, err = self.runProcessUpload()
64 self.assertEqual(0, returncode)64 self.assertEqual(0, returncode)
@@ -86,20 +86,16 @@
86 locker.acquire()86 locker.acquire()
8787
88 returncode, out, err = self.runProcessUpload(88 returncode, out, err = self.runProcessUpload(
89 extra_args=['-C', 'insecure']89 extra_args=['-C', 'insecure'])
90 )
9190
92 # the process-upload call terminated with ERROR and91 # the process-upload call terminated with ERROR and
93 # proper log message92 # proper log message
94 self.assertEqual(1, returncode)93 self.assertEqual(1, returncode)
95 self.assertEqual(94 self.assertEqual([
96 ['INFO Creating lockfile: /var/lock/process-upload-insecure.lock',95 ('INFO Creating lockfile: '
97 'DEBUG Lockfile /var/lock/process-upload-insecure.lock in use'96 '/var/lock/process-upload-insecure.lock'),
97 'DEBUG Lockfile /var/lock/process-upload-insecure.lock in use',
98 ], err.splitlines())98 ], err.splitlines())
9999
100 # release the locally acquired lockfile100 # release the locally acquired lockfile
101 locker.release()101 locker.release()
102
103
104def test_suite():
105 return unittest.TestLoader().loadTestsFromName(__name__)
106102
=== modified file 'lib/lp/soyuz/tests/test_archive.py'
--- lib/lp/soyuz/tests/test_archive.py 2010-07-18 00:56:16 +0000
+++ lib/lp/soyuz/tests/test_archive.py 2010-07-21 07:48:48 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Test Archive features."""4"""Test Archive features."""
@@ -8,6 +8,7 @@
88
9import pytz9import pytz
10import transaction10import transaction
11
11from zope.component import getUtility12from zope.component import getUtility
12from zope.security.interfaces import Unauthorized13from zope.security.interfaces import Unauthorized
13from zope.security.proxy import removeSecurityProxy14from zope.security.proxy import removeSecurityProxy
@@ -64,7 +65,7 @@
64 # upload dates.65 # upload dates.
65 self.gedit_nightly_src_hist = self.publisher.getPubSource(66 self.gedit_nightly_src_hist = self.publisher.getPubSource(
66 sourcename="gedit", archive=self.archives['gedit-nightly'],67 sourcename="gedit", archive=self.archives['gedit-nightly'],
67 date_uploaded=datetime(2010, 12 ,1, tzinfo=pytz.UTC),68 date_uploaded=datetime(2010, 12, 1, tzinfo=pytz.UTC),
68 status=PackagePublishingStatus.PUBLISHED)69 status=PackagePublishingStatus.PUBLISHED)
69 self.gedit_beta_src_hist = self.publisher.getPubSource(70 self.gedit_beta_src_hist = self.publisher.getPubSource(
70 sourcename="gedit", archive=self.archives['gedit-beta'],71 sourcename="gedit", archive=self.archives['gedit-beta'],
@@ -110,8 +111,7 @@
110 "Expected publication from %s but was instead "111 "Expected publication from %s but was instead "
111 "from %s." % (112 "from %s." % (
112 self.archives['gedit-beta'].displayname,113 self.archives['gedit-beta'].displayname,
113 results[0].archive.displayname114 results[0].archive.displayname))
114 ))
115115
116 def testReturnsOnlyPublishedPublications(self):116 def testReturnsOnlyPublishedPublications(self):
117 # Publications that are not published will not be returned.117 # Publications that are not published will not be returned.
@@ -136,14 +136,12 @@
136 archive=self.archives['ubuntu-main'],136 archive=self.archives['ubuntu-main'],
137 distroseries=warty,137 distroseries=warty,
138 date_uploaded=datetime(2010, 12, 30, tzinfo=pytz.UTC),138 date_uploaded=datetime(2010, 12, 30, tzinfo=pytz.UTC),
139 status=PackagePublishingStatus.PUBLISHED,139 status=PackagePublishingStatus.PUBLISHED)
140 )
141140
142 # Only the 3 results for ubuntutest are returned when requested:141 # Only the 3 results for ubuntutest are returned when requested:
143 results = self.archive_set.getPublicationsInArchives(142 results = self.archive_set.getPublicationsInArchives(
144 self.gedit_name, self.archives.values(),143 self.gedit_name, self.archives.values(),
145 distribution=self.distribution144 distribution=self.distribution)
146 )
147 num_results = results.count()145 num_results = results.count()
148 self.assertEquals(3, num_results, "Expected 3 publications but "146 self.assertEquals(3, num_results, "Expected 3 publications but "
149 "got %s" % num_results)147 "got %s" % num_results)
@@ -152,8 +150,7 @@
152 # one we created:150 # one we created:
153 results = self.archive_set.getPublicationsInArchives(151 results = self.archive_set.getPublicationsInArchives(
154 self.gedit_name, self.archives.values(),152 self.gedit_name, self.archives.values(),
155 distribution=ubuntu153 distribution=ubuntu)
156 )
157 num_results = results.count()154 num_results = results.count()
158 self.assertEquals(1, num_results, "Expected 1 publication but "155 self.assertEquals(1, num_results, "Expected 1 publication but "
159 "got %s" % num_results)156 "got %s" % num_results)
@@ -578,13 +575,13 @@
578575
579576
580class TestArchiveCanUpload(TestCaseWithFactory):577class TestArchiveCanUpload(TestCaseWithFactory):
581 """Test the various methods that verify whether uploads are allowed to 578 """Test the various methods that verify whether uploads are allowed to
582 happen."""579 happen."""
583580
584 layer = LaunchpadZopelessLayer581 layer = LaunchpadZopelessLayer
585582
586 def test_checkArchivePermission_by_PPA_owner(self):583 def test_checkArchivePermission_by_PPA_owner(self):
587 # Uploading to a PPA should be allowed for a user that is the owner 584 # Uploading to a PPA should be allowed for a user that is the owner
588 owner = self.factory.makePerson(name="somebody")585 owner = self.factory.makePerson(name="somebody")
589 archive = self.factory.makeArchive(owner=owner)586 archive = self.factory.makeArchive(owner=owner)
590 self.assertEquals(True, archive.checkArchivePermission(owner))587 self.assertEquals(True, archive.checkArchivePermission(owner))
@@ -595,12 +592,12 @@
595 def test_checkArchivePermission_distro_archive(self):592 def test_checkArchivePermission_distro_archive(self):
596 # Regular users can not upload to ubuntu593 # Regular users can not upload to ubuntu
597 ubuntu = getUtility(IDistributionSet).getByName('ubuntu')594 ubuntu = getUtility(IDistributionSet).getByName('ubuntu')
598 archive = self.factory.makeArchive(purpose=ArchivePurpose.PRIMARY, 595 archive = self.factory.makeArchive(purpose=ArchivePurpose.PRIMARY,
599 distribution=ubuntu)596 distribution=ubuntu)
600 main = getUtility(IComponentSet)["main"]597 main = getUtility(IComponentSet)["main"]
601 # A regular user doesn't have access598 # A regular user doesn't have access
602 somebody = self.factory.makePerson(name="somebody")599 somebody = self.factory.makePerson(name="somebody")
603 self.assertEquals(False, 600 self.assertEquals(False,
604 archive.checkArchivePermission(somebody, main))601 archive.checkArchivePermission(somebody, main))
605 # An ubuntu core developer does have access602 # An ubuntu core developer does have access
606 kamion = getUtility(IPersonSet).getByName('kamion')603 kamion = getUtility(IPersonSet).getByName('kamion')
@@ -609,7 +606,7 @@
609 def test_checkArchivePermission_ppa(self):606 def test_checkArchivePermission_ppa(self):
610 ubuntu = getUtility(IDistributionSet).getByName('ubuntu')607 ubuntu = getUtility(IDistributionSet).getByName('ubuntu')
611 owner = self.factory.makePerson(name="eigenaar")608 owner = self.factory.makePerson(name="eigenaar")
612 archive = self.factory.makeArchive(purpose=ArchivePurpose.PPA, 609 archive = self.factory.makeArchive(purpose=ArchivePurpose.PPA,
613 distribution=ubuntu,610 distribution=ubuntu,
614 owner=owner)611 owner=owner)
615 somebody = self.factory.makePerson(name="somebody")612 somebody = self.factory.makePerson(name="somebody")
@@ -621,17 +618,17 @@
621 def test_checkUpload_partner_invalid_pocket(self):618 def test_checkUpload_partner_invalid_pocket(self):
622 # Partner archives only have release and proposed pockets619 # Partner archives only have release and proposed pockets
623 archive = self.factory.makeArchive(purpose=ArchivePurpose.PARTNER)620 archive = self.factory.makeArchive(purpose=ArchivePurpose.PARTNER)
624 self.assertIsInstance(archive.checkUpload(self.factory.makePerson(), 621 self.assertIsInstance(archive.checkUpload(self.factory.makePerson(),
625 self.factory.makeDistroSeries(),622 self.factory.makeDistroSeries(),
626 self.factory.makeSourcePackageName(),623 self.factory.makeSourcePackageName(),
627 self.factory.makeComponent(),624 self.factory.makeComponent(),
628 PackagePublishingPocket.UPDATES),625 PackagePublishingPocket.UPDATES),
629 InvalidPocketForPartnerArchive)626 InvalidPocketForPartnerArchive)
630 627
631 def test_checkUpload_ppa_invalid_pocket(self):628 def test_checkUpload_ppa_invalid_pocket(self):
632 # PPA archives only have release pockets629 # PPA archives only have release pockets
633 archive = self.factory.makeArchive(purpose=ArchivePurpose.PPA)630 archive = self.factory.makeArchive(purpose=ArchivePurpose.PPA)
634 self.assertIsInstance(archive.checkUpload(self.factory.makePerson(), 631 self.assertIsInstance(archive.checkUpload(self.factory.makePerson(),
635 self.factory.makeDistroSeries(),632 self.factory.makeDistroSeries(),
636 self.factory.makeSourcePackageName(),633 self.factory.makeSourcePackageName(),
637 self.factory.makeComponent(),634 self.factory.makeComponent(),
@@ -756,7 +753,7 @@
756 self.arm = getUtility(IProcessorFamilySet).getByName('arm')753 self.arm = getUtility(IProcessorFamilySet).getByName('arm')
757754
758 def test_main_archive_can_use_restricted(self):755 def test_main_archive_can_use_restricted(self):
759 # Main archives for distributions can always use restricted 756 # Main archives for distributions can always use restricted
760 # architectures.757 # architectures.
761 distro = self.factory.makeDistribution()758 distro = self.factory.makeDistribution()
762 self.assertContentEqual([self.arm],759 self.assertContentEqual([self.arm],
@@ -767,8 +764,10 @@
767 distro = self.factory.makeDistribution()764 distro = self.factory.makeDistribution()
768 # Restricting to all restricted architectures is fine765 # Restricting to all restricted architectures is fine
769 distro.main_archive.enabled_restricted_families = [self.arm]766 distro.main_archive.enabled_restricted_families = [self.arm]
767
770 def restrict():768 def restrict():
771 distro.main_archive.enabled_restricted_families = []769 distro.main_archive.enabled_restricted_families = []
770
772 self.assertRaises(CannotRestrictArchitectures, restrict)771 self.assertRaises(CannotRestrictArchitectures, restrict)
773772
774 def test_default(self):773 def test_default(self):
@@ -803,7 +802,8 @@
803 self.assertEquals(1, allowed_restricted_families.count())802 self.assertEquals(1, allowed_restricted_families.count())
804 self.assertEquals(self.arm,803 self.assertEquals(self.arm,
805 allowed_restricted_families[0].processorfamily)804 allowed_restricted_families[0].processorfamily)
806 self.assertEquals([self.arm], self.archive.enabled_restricted_families)805 self.assertEquals(
806 [self.arm], self.archive.enabled_restricted_families)
807 self.archive.enabled_restricted_families = []807 self.archive.enabled_restricted_families = []
808 self.assertEquals(0,808 self.assertEquals(0,
809 self.archive_arch_set.getByArchive(809 self.archive_arch_set.getByArchive(
@@ -836,6 +836,7 @@
836 token = self.private_ppa.getAuthToken(self.joe)836 token = self.private_ppa.getAuthToken(self.joe)
837 self.assertEqual(token.archive_url, url)837 self.assertEqual(token.archive_url, url)
838838
839
839class TestArchivePrivacySwitching(TestCaseWithFactory):840class TestArchivePrivacySwitching(TestCaseWithFactory):
840841
841 layer = LaunchpadZopelessLayer842 layer = LaunchpadZopelessLayer
@@ -1235,7 +1236,3 @@
1235 component=getUtility(IComponentSet)['universe'])1236 component=getUtility(IComponentSet)['universe'])
1236 self.assertDep('i386', 'foo-main', [main_bins[0]])1237 self.assertDep('i386', 'foo-main', [main_bins[0]])
1237 self.assertDep('i386', 'foo-universe', [universe_bins[0]])1238 self.assertDep('i386', 'foo-universe', [universe_bins[0]])
1238
1239
1240def test_suite():
1241 return unittest.TestLoader().loadTestsFromName(__name__)
12421239
=== modified file 'lib/lp/soyuz/tests/test_archive_agent.py'
--- lib/lp/soyuz/tests/test_archive_agent.py 2010-07-13 10:57:31 +0000
+++ lib/lp/soyuz/tests/test_archive_agent.py 2010-07-21 07:48:48 +0000
@@ -60,4 +60,3 @@
60 url = self.ppa.archive_url.split('http://')[1]60 url = self.ppa.archive_url.split('http://')[1]
61 new_url = "http://joe:%s@%s" % (authtoken, url)61 new_url = "http://joe:%s@%s" % (authtoken, url)
62 self.assertEqual(sources, new_url)62 self.assertEqual(sources, new_url)
63
6463
=== modified file 'lib/lp/soyuz/tests/test_archive_privacy.py'
--- lib/lp/soyuz/tests/test_archive_privacy.py 2010-06-21 10:02:54 +0000
+++ lib/lp/soyuz/tests/test_archive_privacy.py 2010-07-21 07:48:48 +0000
@@ -37,4 +37,3 @@
37 login_person(self.joe)37 login_person(self.joe)
38 p3a = getUtility(IArchiveSet).get(self.private_ppa.id)38 p3a = getUtility(IArchiveSet).get(self.private_ppa.id)
39 self.assertEqual(self._getDescription(p3a), "Foo")39 self.assertEqual(self._getDescription(p3a), "Foo")
40
4140
=== modified file 'lib/lp/soyuz/tests/test_archive_subscriptions.py'
--- lib/lp/soyuz/tests/test_archive_subscriptions.py 2010-06-28 14:39:35 +0000
+++ lib/lp/soyuz/tests/test_archive_subscriptions.py 2010-07-21 07:48:48 +0000
@@ -1,10 +1,8 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Test Archive features."""4"""Test Archive features."""
55
6import unittest
7
8from zope.security.interfaces import Unauthorized6from zope.security.interfaces import Unauthorized
97
10from canonical.testing import DatabaseFunctionalLayer8from canonical.testing import DatabaseFunctionalLayer
@@ -36,7 +34,6 @@
36 # a private team's PPA after they have been given a subscription.34 # a private team's PPA after they have been given a subscription.
37 # This is essentially allowing access for the subscriber to see35 # This is essentially allowing access for the subscriber to see
38 # the private team.36 # the private team.
39
40 def get_name():37 def get_name():
41 return self.archive.owner.name38 return self.archive.owner.name
4239
@@ -51,7 +48,3 @@
51 # When a subscription exists, it's fine.48 # When a subscription exists, it's fine.
52 login_person(self.subscriber)49 login_person(self.subscriber)
53 self.assertEqual(self.archive.owner.name, "subscribertest")50 self.assertEqual(self.archive.owner.name, "subscribertest")
54
55
56def test_suite():
57 return unittest.TestLoader().loadTestsFromName(__name__)
5851
=== modified file 'lib/lp/soyuz/tests/test_archivearch.py'
--- lib/lp/soyuz/tests/test_archivearch.py 2010-07-05 11:00:54 +0000
+++ lib/lp/soyuz/tests/test_archivearch.py 2010-07-21 07:48:48 +0000
@@ -3,8 +3,6 @@
33
4"""Test ArchiveArch features."""4"""Test ArchiveArch features."""
55
6import unittest
7
8from zope.component import getUtility6from zope.component import getUtility
97
10from canonical.testing import LaunchpadZopelessLayer8from canonical.testing import LaunchpadZopelessLayer
@@ -16,6 +14,7 @@
16from lp.soyuz.interfaces.archivearch import IArchiveArchSet14from lp.soyuz.interfaces.archivearch import IArchiveArchSet
17from lp.soyuz.interfaces.processor import IProcessorFamilySet15from lp.soyuz.interfaces.processor import IProcessorFamilySet
1816
17
19class TestArchiveArch(TestCaseWithFactory):18class TestArchiveArch(TestCaseWithFactory):
2019
21 layer = LaunchpadZopelessLayer20 layer = LaunchpadZopelessLayer
@@ -53,7 +52,7 @@
53 results = dict(52 results = dict(
54 (row[0].name, row[1] is not None) for row in result_set)53 (row[0].name, row[1] is not None) for row in result_set)
55 self.assertEquals(54 self.assertEquals(
56 {'arm' : False, 'cell-proc' : True, 'omap' : False},55 {'arm': False, 'cell-proc': True, 'omap': False},
57 results)56 results)
5857
59 def test_getRestrictedFamilies_archive_only(self):58 def test_getRestrictedFamilies_archive_only(self):
@@ -66,7 +65,7 @@
66 results = dict(65 results = dict(
67 (row[0].name, row[1] is not None) for row in result_set)66 (row[0].name, row[1] is not None) for row in result_set)
68 self.assertEquals(67 self.assertEquals(
69 {'arm' : False, 'cell-proc' : True, 'omap' : False},68 {'arm': False, 'cell-proc': True, 'omap': False},
70 results)69 results)
7170
72 def test_getByArchive_no_other_archives(self):71 def test_getByArchive_no_other_archives(self):
@@ -78,7 +77,3 @@
78 self.assertEquals(1, len(result_set))77 self.assertEquals(1, len(result_set))
79 self.assertEquals(self.ppa, result_set[0].archive)78 self.assertEquals(self.ppa, result_set[0].archive)
80 self.assertEquals(self.cell_proc, result_set[0].processorfamily)79 self.assertEquals(self.cell_proc, result_set[0].processorfamily)
81
82
83def test_suite():
84 return unittest.TestLoader().loadTestsFromName(__name__)
8580
=== modified file 'lib/lp/soyuz/tests/test_binarypackagebuild.py'
--- lib/lp/soyuz/tests/test_binarypackagebuild.py 2010-07-18 00:56:16 +0000
+++ lib/lp/soyuz/tests/test_binarypackagebuild.py 2010-07-21 07:48:48 +0000
@@ -1,11 +1,10 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Test Build features."""4"""Test Build features."""
55
6from datetime import datetime, timedelta6from datetime import datetime, timedelta
7import pytz7import pytz
8import unittest
98
10from storm.store import Store9from storm.store import Store
11from zope.component import getUtility10from zope.component import getUtility
@@ -91,7 +90,6 @@
91 previous_build.date_started = None90 previous_build.date_started = None
92 self.assertEqual(60, self.build.estimateDuration().seconds)91 self.assertEqual(60, self.build.estimateDuration().seconds)
9392
94
95 def addFakeBuildLog(self):93 def addFakeBuildLog(self):
96 lfa = self.factory.makeLibraryFileAlias('mybuildlog.txt')94 lfa = self.factory.makeLibraryFileAlias('mybuildlog.txt')
97 removeSecurityProxy(self.build).log = lfa95 removeSecurityProxy(self.build).log = lfa
@@ -161,8 +159,8 @@
161 def _setupSimpleDepwaitContext(self):159 def _setupSimpleDepwaitContext(self):
162 """Use `SoyuzTestPublisher` to setup a simple depwait context.160 """Use `SoyuzTestPublisher` to setup a simple depwait context.
163161
164 Return an `IBinaryPackageBuild` in MANUALDEWAIT state and depending on a162 Return an `IBinaryPackageBuild` in MANUALDEWAIT state and depending
165 binary that exists and is reachable.163 on a binary that exists and is reachable.
166 """164 """
167 self.publisher = SoyuzTestPublisher()165 self.publisher = SoyuzTestPublisher()
168 self.publisher.prepareBreezyAutotest()166 self.publisher.prepareBreezyAutotest()
@@ -221,7 +219,6 @@
221 BinaryPackageBuild.id == depwait_build_id).count(),219 BinaryPackageBuild.id == depwait_build_id).count(),
222 1)220 1)
223221
224
225 def testUpdateDependenciesWorks(self):222 def testUpdateDependenciesWorks(self):
226 # Calling `IBinaryPackageBuild.updateDependencies` makes the build223 # Calling `IBinaryPackageBuild.updateDependencies` makes the build
227 # record ready for dispatch.224 # record ready for dispatch.
@@ -464,7 +461,3 @@
464class TestHandleStatusForBinaryPackageBuild(461class TestHandleStatusForBinaryPackageBuild(
465 MakeBinaryPackageBuildMixin, TestHandleStatusMixin, TestCaseWithFactory):462 MakeBinaryPackageBuildMixin, TestHandleStatusMixin, TestCaseWithFactory):
466 """IBuildBase.handleStatus works with binary builds."""463 """IBuildBase.handleStatus works with binary builds."""
467
468
469def test_suite():
470 return unittest.TestLoader().loadTestsFromName(__name__)
471464
=== modified file 'lib/lp/soyuz/tests/test_distroseriesbinarypackage.py'
--- lib/lp/soyuz/tests/test_distroseriesbinarypackage.py 2010-05-28 17:28:57 +0000
+++ lib/lp/soyuz/tests/test_distroseriesbinarypackage.py 2010-07-21 07:48:48 +0000
@@ -9,7 +9,6 @@
9 'test_suite',9 'test_suite',
10 ]10 ]
1111
12import unittest
13import transaction12import transaction
1413
15from lp.soyuz.model.distroseriesbinarypackage import (14from lp.soyuz.model.distroseriesbinarypackage import (
@@ -63,7 +62,3 @@
6362
64 self.failUnlessEqual(63 self.failUnlessEqual(
65 'Foo is the best', self.distroseries_binary_package.summary)64 'Foo is the best', self.distroseries_binary_package.summary)
66
67
68def test_suite():
69 return unittest.TestLoader().loadTestsFromName(__name__)
7065
=== modified file 'lib/lp/soyuz/tests/test_hasbuildrecords.py'
--- lib/lp/soyuz/tests/test_hasbuildrecords.py 2010-06-17 09:53:24 +0000
+++ lib/lp/soyuz/tests/test_hasbuildrecords.py 2010-07-21 07:48:48 +0000
@@ -1,10 +1,8 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Test implementations of the IHasBuildRecords interface."""4"""Test implementations of the IHasBuildRecords interface."""
55
6import unittest
7
8from zope.component import getUtility6from zope.component import getUtility
9from zope.security.proxy import removeSecurityProxy7from zope.security.proxy import removeSecurityProxy
108
@@ -67,6 +65,7 @@
6765
68class TestDistroSeriesHasBuildRecords(TestHasBuildRecordsInterface):66class TestDistroSeriesHasBuildRecords(TestHasBuildRecordsInterface):
69 """Test the DistroSeries implementation of IHasBuildRecords."""67 """Test the DistroSeries implementation of IHasBuildRecords."""
68
70 def setUp(self):69 def setUp(self):
71 super(TestDistroSeriesHasBuildRecords, self).setUp()70 super(TestDistroSeriesHasBuildRecords, self).setUp()
7271
@@ -75,6 +74,7 @@
7574
76class TestDistroArchSeriesHasBuildRecords(TestHasBuildRecordsInterface):75class TestDistroArchSeriesHasBuildRecords(TestHasBuildRecordsInterface):
77 """Test the DistroArchSeries implementation of IHasBuildRecords."""76 """Test the DistroArchSeries implementation of IHasBuildRecords."""
77
78 def setUp(self):78 def setUp(self):
79 super(TestDistroArchSeriesHasBuildRecords, self).setUp()79 super(TestDistroArchSeriesHasBuildRecords, self).setUp()
8080
@@ -83,6 +83,7 @@
8383
84class TestArchiveHasBuildRecords(TestHasBuildRecordsInterface):84class TestArchiveHasBuildRecords(TestHasBuildRecordsInterface):
85 """Test the Archive implementation of IHasBuildRecords."""85 """Test the Archive implementation of IHasBuildRecords."""
86
86 def setUp(self):87 def setUp(self):
87 super(TestArchiveHasBuildRecords, self).setUp()88 super(TestArchiveHasBuildRecords, self).setUp()
8889
@@ -117,6 +118,7 @@
117118
118class TestBuilderHasBuildRecords(TestHasBuildRecordsInterface):119class TestBuilderHasBuildRecords(TestHasBuildRecordsInterface):
119 """Test the Builder implementation of IHasBuildRecords."""120 """Test the Builder implementation of IHasBuildRecords."""
121
120 def setUp(self):122 def setUp(self):
121 super(TestBuilderHasBuildRecords, self).setUp()123 super(TestBuilderHasBuildRecords, self).setUp()
122124
@@ -171,8 +173,10 @@
171 IncompatibleArguments, self.context.getBuildRecords,173 IncompatibleArguments, self.context.getBuildRecords,
172 binary_only=False, name="anything")174 binary_only=False, name="anything")
173175
176
174class TestSourcePackageHasBuildRecords(TestHasBuildRecordsInterface):177class TestSourcePackageHasBuildRecords(TestHasBuildRecordsInterface):
175 """Test the SourcePackage implementation of IHasBuildRecords."""178 """Test the SourcePackage implementation of IHasBuildRecords."""
179
176 def setUp(self):180 def setUp(self):
177 super(TestSourcePackageHasBuildRecords, self).setUp()181 super(TestSourcePackageHasBuildRecords, self).setUp()
178182
@@ -187,7 +191,3 @@
187 for build in self.builds[1:3]:191 for build in self.builds[1:3]:
188 spr = build.source_package_release192 spr = build.source_package_release
189 removeSecurityProxy(spr).sourcepackagename = gedit_name193 removeSecurityProxy(spr).sourcepackagename = gedit_name
190
191
192def test_suite():
193 return unittest.TestLoader().loadTestsFromName(__name__)
194194
=== modified file 'lib/lp/soyuz/tests/test_packagediff.py'
--- lib/lp/soyuz/tests/test_packagediff.py 2010-02-04 17:08:01 +0000
+++ lib/lp/soyuz/tests/test_packagediff.py 2010-07-21 07:48:48 +0000
@@ -6,7 +6,6 @@
6__metaclass__ = type6__metaclass__ = type
77
8from datetime import datetime8from datetime import datetime
9import unittest
109
11from zope.component import getUtility10from zope.component import getUtility
12from zope.security.proxy import removeSecurityProxy11from zope.security.proxy import removeSecurityProxy
@@ -86,7 +85,3 @@
86 diff.performDiff()85 diff.performDiff()
87 # The diff succeeds as expected.86 # The diff succeeds as expected.
88 self.assertEqual(PackageDiffStatus.COMPLETED, diff.status)87 self.assertEqual(PackageDiffStatus.COMPLETED, diff.status)
89
90
91def test_suite():
92 return unittest.TestLoader().loadTestsFromName(__name__)
9388
=== modified file 'lib/lp/soyuz/tests/test_packageupload.py'
--- lib/lp/soyuz/tests/test_packageupload.py 2010-05-10 16:21:10 +0000
+++ lib/lp/soyuz/tests/test_packageupload.py 2010-07-21 07:48:48 +0000
@@ -1,11 +1,10 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Test Build features."""4"""Test Build features."""
55
6import os6import os
7import shutil7import shutil
8import unittest
98
10from zope.component import getUtility9from zope.component import getUtility
1110
@@ -333,7 +332,3 @@
333 # the partner archive.332 # the partner archive.
334 pub = package_upload.realiseUpload()[0]333 pub = package_upload.realiseUpload()[0]
335 self.assertEqual("partner", pub.archive.name)334 self.assertEqual("partner", pub.archive.name)
336
337
338def test_suite():
339 return unittest.TestLoader().loadTestsFromName(__name__)
340335
=== modified file 'lib/lp/soyuz/tests/test_publish_archive_indexes.py'
--- lib/lp/soyuz/tests/test_publish_archive_indexes.py 2009-10-08 08:24:03 +0000
+++ lib/lp/soyuz/tests/test_publish_archive_indexes.py 2010-07-21 07:48:48 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Test native archive index generation for Soyuz."""4"""Test native archive index generation for Soyuz."""
@@ -10,6 +10,7 @@
1010
11from lp.soyuz.tests.test_publishing import TestNativePublishingBase11from lp.soyuz.tests.test_publishing import TestNativePublishingBase
1212
13
13class TestNativeArchiveIndexes(TestNativePublishingBase):14class TestNativeArchiveIndexes(TestNativePublishingBase):
1415
15 def setUp(self):16 def setUp(self):
@@ -57,11 +58,11 @@
57 See also testSourceStanza, it must present something similar for58 See also testSourceStanza, it must present something similar for
58 binary packages.59 binary packages.
59 """60 """
60 pub_binary = self.getPubBinaries(61 pub_binaries = self.getPubBinaries(
61 depends='biscuit', recommends='foo-dev', suggests='pyfoo',62 depends='biscuit', recommends='foo-dev', suggests='pyfoo',
62 conflicts='old-foo', replaces='old-foo', provides='foo-master',63 conflicts='old-foo', replaces='old-foo', provides='foo-master',
63 pre_depends='master-foo', enhances='foo-super', breaks='old-foo'64 pre_depends='master-foo', enhances='foo-super', breaks='old-foo')
64 )[0]65 pub_binary = pub_binaries[0]
65 self.assertEqual(66 self.assertEqual(
66 [u'Package: foo-bin',67 [u'Package: foo-bin',
67 u'Source: foo',68 u'Source: foo',
@@ -135,7 +136,7 @@
135 u' .',136 u' .',
136 u' .',137 u' .',
137 u' .',138 u' .',
138 u' %s' % ('x' * 100)139 u' %s' % ('x' * 100),
139 ],140 ],
140 pub_binary.getIndexStanza().splitlines())141 pub_binary.getIndexStanza().splitlines())
141142
@@ -175,6 +176,7 @@
175 """Tests for ensuring the native archive indexes that we publish176 """Tests for ensuring the native archive indexes that we publish
176 can be parsed correctly by apt_get.ParseTagFiles.177 can be parsed correctly by apt_get.ParseTagFiles.
177 """178 """
179
178 def setUp(self):180 def setUp(self):
179 """Setup global attributes."""181 """Setup global attributes."""
180 TestNativePublishingBase.setUp(self)182 TestNativePublishingBase.setUp(self)
@@ -299,6 +301,7 @@
299301
300302
301class TestIndexStanzaFieldsHelper(unittest.TestCase):303class TestIndexStanzaFieldsHelper(unittest.TestCase):
304
302 def testIndexStanzaFields(self):305 def testIndexStanzaFields(self):
303 """Check how this auxiliary class works...306 """Check how this auxiliary class works...
304307
@@ -307,6 +310,7 @@
307310
308 Provides an method to format the option in a ready-to-use string.311 Provides an method to format the option in a ready-to-use string.
309 """312 """
313 # Avoid circular imports.
310 from lp.soyuz.model.publishing import IndexStanzaFields314 from lp.soyuz.model.publishing import IndexStanzaFields
311315
312 fields = IndexStanzaFields()316 fields = IndexStanzaFields()
@@ -338,7 +342,3 @@
338342
339 self.assertEqual(343 self.assertEqual(
340 ['one: um', 'Files:<no_sep>'], fields.makeOutput().splitlines())344 ['one: um', 'Files:<no_sep>'], fields.makeOutput().splitlines())
341
342
343def test_suite():
344 return unittest.TestLoader().loadTestsFromName(__name__)
345345
=== modified file 'lib/lp/soyuz/tests/test_publishing.py'
--- lib/lp/soyuz/tests/test_publishing.py 2010-07-20 17:32:03 +0000
+++ lib/lp/soyuz/tests/test_publishing.py 2010-07-21 07:48:48 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Test native publication workflow for Soyuz. """4"""Test native publication workflow for Soyuz. """
@@ -44,6 +44,7 @@
44from canonical.launchpad.scripts import FakeLogger44from canonical.launchpad.scripts import FakeLogger
45from lp.testing import TestCaseWithFactory45from lp.testing import TestCaseWithFactory
46from lp.testing.factory import LaunchpadObjectFactory46from lp.testing.factory import LaunchpadObjectFactory
47from lp.testing.fakemethod import FakeMethod
4748
4849
49class SoyuzTestPublisher:50class SoyuzTestPublisher:
@@ -135,7 +136,7 @@
135 changes_file_name="foo_666_source.changes",136 changes_file_name="foo_666_source.changes",
136 changes_file_content="fake changes file content",137 changes_file_content="fake changes file content",
137 upload_status=PackageUploadStatus.DONE):138 upload_status=PackageUploadStatus.DONE):
138 signing_key = self.person.gpg_keys[0]139 signing_key = self.person.gpg_keys[0]
139 package_upload = distroseries.createQueueEntry(140 package_upload = distroseries.createQueueEntry(
140 pocket, changes_file_name, changes_file_content, archive,141 pocket, changes_file_name, changes_file_content, archive,
141 signing_key)142 signing_key)
@@ -472,9 +473,8 @@
472 self.pool_dir = self.config.poolroot473 self.pool_dir = self.config.poolroot
473 self.temp_dir = self.config.temproot474 self.temp_dir = self.config.temproot
474 self.logger = FakeLogger()475 self.logger = FakeLogger()
475 def message(self, prefix, *stuff, **kw):476
476 pass477 self.logger.message = FakeMethod()
477 self.logger.message = message
478 self.disk_pool = DiskPool(self.pool_dir, self.temp_dir, self.logger)478 self.disk_pool = DiskPool(self.pool_dir, self.temp_dir, self.logger)
479479
480 def tearDown(self):480 def tearDown(self):
@@ -600,7 +600,7 @@
600 pub_source.publish(self.disk_pool, self.logger)600 pub_source.publish(self.disk_pool, self.logger)
601 self.layer.commit()601 self.layer.commit()
602 self.assertEqual(602 self.assertEqual(
603 pub_source.status,PackagePublishingStatus.PENDING)603 pub_source.status, PackagePublishingStatus.PENDING)
604 self.assertEqual(open(foo_dsc_path).read().strip(), 'Hello world')604 self.assertEqual(open(foo_dsc_path).read().strip(), 'Hello world')
605605
606 def testPublishingDifferentContents(self):606 def testPublishingDifferentContents(self):
@@ -779,7 +779,7 @@
779 try:779 try:
780 copies = tuple(copied)780 copies = tuple(copied)
781 except TypeError:781 except TypeError:
782 copies = (copied,)782 copies = (copied, )
783783
784 for copy in copies:784 for copy in copies:
785 self.assertEquals(copy.component, pub_record.component)785 self.assertEquals(copy.component, pub_record.component)
@@ -889,7 +889,8 @@
889 """Return a mock source package publishing record for the archive889 """Return a mock source package publishing record for the archive
890 and architecture used in this testcase.890 and architecture used in this testcase.
891891
892 :param architecturehintlist: Architecture hint list (e.g. "i386 amd64")892 :param architecturehintlist: Architecture hint list
893 (e.g. "i386 amd64")
893 """894 """
894 return super(BuildRecordCreationTests, self).getPubSource(895 return super(BuildRecordCreationTests, self).getPubSource(
895 archive=self.archive, distroseries=self.distroseries,896 archive=self.archive, distroseries=self.distroseries,
@@ -929,8 +930,8 @@
929 self.assertEquals(self.sparc_distroarch, builds[0].distro_arch_series)930 self.assertEquals(self.sparc_distroarch, builds[0].distro_arch_series)
930931
931 def test_createMissingBuilds_restricts_explicitlist(self):932 def test_createMissingBuilds_restricts_explicitlist(self):
932 """createMissingBuilds() should limit builds targeted at a933 """createMissingBuilds() limits builds targeted at a variety of
933 variety of architectures architecture to those allowed for the archive.934 architectures architecture to those allowed for the archive.
934 """935 """
935 pubrec = self.getPubSource(architecturehintlist='sparc i386 avr')936 pubrec = self.getPubSource(architecturehintlist='sparc i386 avr')
936 builds = pubrec.createMissingBuilds()937 builds = pubrec.createMissingBuilds()
@@ -1014,7 +1015,3 @@
1014 record = self.publishing_set.getByIdAndArchive(1015 record = self.publishing_set.getByIdAndArchive(
1015 binary_publishing.id, wrong_archive, source=False)1016 binary_publishing.id, wrong_archive, source=False)
1016 self.assertEqual(None, record)1017 self.assertEqual(None, record)
1017
1018
1019def test_suite():
1020 return unittest.TestLoader().loadTestsFromName(__name__)
10211018
=== modified file 'lib/lp/soyuz/tests/test_publishing_models.py'
--- lib/lp/soyuz/tests/test_publishing_models.py 2010-05-05 14:50:42 +0000
+++ lib/lp/soyuz/tests/test_publishing_models.py 2010-07-21 07:48:48 +0000
@@ -1,10 +1,8 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Test model and set utilities used for publishing."""4"""Test model and set utilities used for publishing."""
55
6import unittest
7
8from zope.component import getUtility6from zope.component import getUtility
9from zope.security.proxy import removeSecurityProxy7from zope.security.proxy import removeSecurityProxy
108
@@ -86,9 +84,6 @@
86 self.assertEqual(urls, [84 self.assertEqual(urls, [
87 'http://localhost:58000/94/gedit_666_source.changes',85 'http://localhost:58000/94/gedit_666_source.changes',
88 'http://localhost:58000/96/firefox_666_source.changes',86 'http://localhost:58000/96/firefox_666_source.changes',
89 'http://localhost:58000/98/getting-things-gnome_666_source.changes'87 ('http://localhost:58000/98/'
88 'getting-things-gnome_666_source.changes'),
90 ])89 ])
91
92
93def test_suite():
94 return unittest.TestLoader().loadTestsFromName(__name__)
9590
=== modified file 'lib/lp/soyuz/tests/test_publishing_top_level_api.py'
--- lib/lp/soyuz/tests/test_publishing_top_level_api.py 2009-12-13 11:55:40 +0000
+++ lib/lp/soyuz/tests/test_publishing_top_level_api.py 2010-07-21 07:48:48 +0000
@@ -1,10 +1,8 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Test top-level publication API in Soyuz."""4"""Test top-level publication API in Soyuz."""
55
6from unittest import TestLoader
7
8from lp.soyuz.tests.test_publishing import TestNativePublishingBase6from lp.soyuz.tests.test_publishing import TestNativePublishingBase
97
10from lp.registry.interfaces.series import SeriesStatus8from lp.registry.interfaces.series import SeriesStatus
@@ -118,7 +116,7 @@
118116
119 # source and binary PUBLISHED on disk.117 # source and binary PUBLISHED on disk.
120 foo_dsc = "%s/main/f/foo/foo_666.dsc" % self.pool_dir118 foo_dsc = "%s/main/f/foo/foo_666.dsc" % self.pool_dir
121 self.assertEqual(open(foo_dsc).read().strip(),'Hello')119 self.assertEqual(open(foo_dsc).read().strip(), 'Hello')
122 foo_deb = "%s/main/f/foo/foo-bin_666_all.deb" % self.pool_dir120 foo_deb = "%s/main/f/foo/foo-bin_666_all.deb" % self.pool_dir
123 self.assertEqual(open(foo_deb).read().strip(), 'World')121 self.assertEqual(open(foo_deb).read().strip(), 'World')
124122
@@ -207,8 +205,9 @@
207 def testPublicationLookUpForUnstableDistroSeries(self):205 def testPublicationLookUpForUnstableDistroSeries(self):
208 """Source publishing record lookup for a unstable DistroSeries.206 """Source publishing record lookup for a unstable DistroSeries.
209207
210 Check if the ICanPublishPackages.getPendingPublications() works properly208 Check if the ICanPublishPackages.getPendingPublications() works
211 for a DistroSeries when it is still in development, 'unreleased'.209 properly for a DistroSeries when it is still in development,
210 'unreleased'.
212 """211 """
213 pub_pending_release, pub_published_release, pub_pending_updates = (212 pub_pending_release, pub_published_release, pub_pending_updates = (
214 self._createDefaulSourcePublications())213 self._createDefaulSourcePublications())
@@ -241,9 +240,9 @@
241 def testPublicationLookUpForStableDistroSeries(self):240 def testPublicationLookUpForStableDistroSeries(self):
242 """Source publishing record lookup for a stable/released DistroSeries.241 """Source publishing record lookup for a stable/released DistroSeries.
243242
244 Check if the ICanPublishPackages.getPendingPublications() works properly243 Check if the ICanPublishPackages.getPendingPublications() works
245 for a DistroSeries when it is not in development anymore, i.e.,244 properly for a DistroSeries when it is not in development anymore,
246 'released'.245 i.e., 'released'.
247 """246 """
248 pub_pending_release, pub_published_release, pub_pending_updates = (247 pub_pending_release, pub_published_release, pub_pending_updates = (
249 self._createDefaulSourcePublications())248 self._createDefaulSourcePublications())
@@ -276,8 +275,8 @@
276 def testPublicationLookUpForFrozenDistroSeries(self):275 def testPublicationLookUpForFrozenDistroSeries(self):
277 """Source publishing record lookup for a frozen DistroSeries.276 """Source publishing record lookup for a frozen DistroSeries.
278277
279 Check if the ICanPublishPackages.getPendingPubliations() works properly278 Check if the ICanPublishPackages.getPendingPubliations() works
280 for a DistroSeries when it is in FROZEN state.279 properly for a DistroSeries when it is in FROZEN state.
281 """280 """
282 pub_pending_release, pub_published_release, pub_pending_updates = (281 pub_pending_release, pub_published_release, pub_pending_updates = (
283 self._createDefaulSourcePublications())282 self._createDefaulSourcePublications())
@@ -313,9 +312,9 @@
313 def testPublicationLookUpForUnstableDistroArchSeries(self):312 def testPublicationLookUpForUnstableDistroArchSeries(self):
314 """Binary publishing record lookup for a unstable DistroArchSeries.313 """Binary publishing record lookup for a unstable DistroArchSeries.
315314
316 Check if the ICanPublishPackages.getPendingPublications() works properly315 Check if the ICanPublishPackages.getPendingPublications() works
317 for a DistroArchSeries when it is still in DEVELOPMENT, i.e.,316 properly for a DistroArchSeries when it is still in DEVELOPMENT,
318 'unstable'.317 i.e., 'unstable'.
319 """318 """
320 pub_pending_release, pub_published_release, pub_pending_updates = (319 pub_pending_release, pub_published_release, pub_pending_updates = (
321 self._createDefaulBinaryPublications())320 self._createDefaulBinaryPublications())
@@ -421,7 +420,3 @@
421 self.checkBinaryLookupForPocket(420 self.checkBinaryLookupForPocket(
422 PackagePublishingPocket.RELEASE, is_careful=True,421 PackagePublishingPocket.RELEASE, is_careful=True,
423 expected_result=[pub_published_release, pub_pending_release])422 expected_result=[pub_published_release, pub_pending_release])
424
425
426def test_suite():
427 return TestLoader().loadTestsFromName(__name__)
428423
=== modified file 'lib/lp/testing/faketransaction.py'
--- lib/lp/testing/faketransaction.py 2010-02-23 23:26:15 +0000
+++ lib/lp/testing/faketransaction.py 2010-07-21 07:48:48 +0000
@@ -15,6 +15,8 @@
1515
16 Set `log_calls` to True to enable printing of commits and aborts.16 Set `log_calls` to True to enable printing of commits and aborts.
17 """17 """
18 commit_count = 0
19
18 def __init__(self, log_calls=False):20 def __init__(self, log_calls=False):
19 self.log_calls = log_calls21 self.log_calls = log_calls
2022
@@ -28,6 +30,7 @@
2830
29 def commit(self):31 def commit(self):
30 """Pretend to commit."""32 """Pretend to commit."""
33 self.commit_count += 1
31 self._log("COMMIT")34 self._log("COMMIT")
3235
33 def abort(self):36 def abort(self):