Merge lp:~al-maisan/launchpad/partner-expiry-535030 into lp:launchpad

Proposed by Muharem Hrnjadovic
Status: Merged
Approved by: Jeroen T. Vermeulen
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~al-maisan/launchpad/partner-expiry-535030
Merge into: lp:launchpad
Diff against target: 432 lines (+127/-106)
3 files modified
cronscripts/expire-archive-files.py (+3/-3)
lib/lp/soyuz/scripts/expire_archive_files.py (+21/-15)
lib/lp/soyuz/scripts/tests/test_expire_archive_files.py (+103/-88)
To merge this branch: bzr merge lp:~al-maisan/launchpad/partner-expiry-535030
Reviewer Review Type Date Requested Status
Jeroen T. Vermeulen (community) code Approve
Review via email: mp+20990@code.launchpad.net

Description of the change

Hello there!

This branch revises the former PPA source/binary expiration script to include
partner archives as well.

Most of the changes are due to the refactoring of the test code making it
possible to "reuse" the majority of the original tests.

Tests to run:

    bin/test -vv test_expire_archive_files

No "make lint" issues.

To post a comment you must log in.
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Looks good.

We discussed a few minor changes in IRC:

 * Use a dict for parameter substitution in those big queries; less brittle as the code continues to evolve.

 * Use the "common tests" class as a mixin rather than a fully-functional base class. That way you don't need to tell the test loader not to run it on its own.

Jeroen

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== renamed file 'cronscripts/expire-ppa-files.py' => 'cronscripts/expire-archive-files.py'
--- cronscripts/expire-ppa-files.py 2010-01-20 10:32:32 +0000
+++ cronscripts/expire-archive-files.py 2010-03-10 12:10:46 +0000
@@ -12,11 +12,11 @@
12import _pythonpath12import _pythonpath
1313
14from canonical.config import config14from canonical.config import config
15from lp.soyuz.scripts.expire_ppa_binaries import PPABinaryExpirer15from lp.soyuz.scripts.expire_archive_files import ArchiveExpirer
1616
1717
18if __name__ == '__main__':18if __name__ == '__main__':
19 script = PPABinaryExpirer(19 script = ArchiveExpirer(
20 'expire-ppa-files', dbuser=config.binaryfile_expire.dbuser)20 'expire-archive-files', dbuser=config.binaryfile_expire.dbuser)
21 script.lock_and_run()21 script.lock_and_run()
2222
2323
=== renamed file 'lib/lp/soyuz/scripts/expire_ppa_binaries.py' => 'lib/lp/soyuz/scripts/expire_archive_files.py'
--- lib/lp/soyuz/scripts/expire_ppa_binaries.py 2010-01-31 19:36:27 +0000
+++ lib/lp/soyuz/scripts/expire_archive_files.py 2010-03-10 12:10:46 +0000
@@ -34,7 +34,7 @@
34""".split()34""".split()
3535
3636
37class PPABinaryExpirer(LaunchpadCronScript):37class ArchiveExpirer(LaunchpadCronScript):
38 """Helper class for expiring old PPA binaries.38 """Helper class for expiring old PPA binaries.
3939
40 Any PPA binary older than 30 days that is superseded or deleted40 Any PPA binary older than 30 days that is superseded or deleted
@@ -60,6 +60,7 @@
60 from lp.soyuz.interfaces.archive import ArchivePurpose60 from lp.soyuz.interfaces.archive import ArchivePurpose
6161
62 stay_of_execution = '%d days' % num_days62 stay_of_execution = '%d days' % num_days
63 archive_types = (ArchivePurpose.PPA, ArchivePurpose.PARTNER)
6364
64 # The subquery here has to repeat the checks for privacy and65 # The subquery here has to repeat the checks for privacy and
65 # blacklisting on *other* publications that are also done in66 # blacklisting on *other* publications that are also done in
@@ -79,7 +80,7 @@
79 AND spph.dateremoved < (80 AND spph.dateremoved < (
80 CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - interval %s)81 CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - interval %s)
81 AND spph.archive = archive.id82 AND spph.archive = archive.id
82 AND archive.purpose = %s83 AND archive.purpose IN %s
83 AND lfa.expires IS NULL84 AND lfa.expires IS NULL
84 EXCEPT85 EXCEPT
85 SELECT sprf.libraryfile86 SELECT sprf.libraryfile
@@ -95,15 +96,15 @@
95 AND spph.archive = a.id96 AND spph.archive = a.id
96 AND p.id = a.owner97 AND p.id = a.owner
97 AND (98 AND (
98 p.name IN %s99 (p.name IN %s AND a.purpose = %s)
99 OR a.private IS TRUE100 OR a.private IS TRUE
100 OR a.purpose != %s101 OR a.purpose NOT IN %s
101 OR dateremoved >102 OR dateremoved >
102 CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - interval %s103 CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - interval %s
103 OR dateremoved IS NULL);104 OR dateremoved IS NULL);
104 """ % sqlvalues(105 """ % sqlvalues(
105 stay_of_execution, ArchivePurpose.PPA, self.blacklist,106 stay_of_execution, archive_types, self.blacklist,
106 ArchivePurpose.PPA, stay_of_execution))107 ArchivePurpose.PPA, archive_types, stay_of_execution))
107108
108 lfa_ids = results.get_all()109 lfa_ids = results.get_all()
109 return lfa_ids110 return lfa_ids
@@ -114,6 +115,7 @@
114 from lp.soyuz.interfaces.archive import ArchivePurpose115 from lp.soyuz.interfaces.archive import ArchivePurpose
115116
116 stay_of_execution = '%d days' % num_days117 stay_of_execution = '%d days' % num_days
118 archive_types = (ArchivePurpose.PPA, ArchivePurpose.PARTNER)
117119
118 # The subquery here has to repeat the checks for privacy and120 # The subquery here has to repeat the checks for privacy and
119 # blacklisting on *other* publications that are also done in121 # blacklisting on *other* publications that are also done in
@@ -131,9 +133,10 @@
131 AND bpr.id = bpf.binarypackagerelease133 AND bpr.id = bpf.binarypackagerelease
132 AND bpph.binarypackagerelease = bpr.id134 AND bpph.binarypackagerelease = bpr.id
133 AND bpph.dateremoved < (135 AND bpph.dateremoved < (
134 CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - interval %s)136 CURRENT_TIMESTAMP AT TIME ZONE 'UTC' -
137 interval %(stay_of_execution)s)
135 AND bpph.archive = archive.id138 AND bpph.archive = archive.id
136 AND archive.purpose = %s139 AND archive.purpose IN %(archive_types)s
137 AND lfa.expires IS NULL140 AND lfa.expires IS NULL
138 EXCEPT141 EXCEPT
139 SELECT bpf.libraryfile142 SELECT bpf.libraryfile
@@ -149,15 +152,18 @@
149 AND bpph.archive = a.id152 AND bpph.archive = a.id
150 AND p.id = a.owner153 AND p.id = a.owner
151 AND (154 AND (
152 p.name IN %s155 (p.name IN %(blacklist)s AND a.purpose = %(ppa)s)
153 OR a.private IS TRUE156 OR a.private IS TRUE
154 OR a.purpose != %s157 OR a.purpose NOT IN %(archive_types)s
155 OR dateremoved >158 OR dateremoved > (
156 CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - interval %s159 CURRENT_TIMESTAMP AT TIME ZONE 'UTC' -
157 OR dateremoved IS NULL);160 interval %(stay_of_execution)s)
161 OR dateremoved IS NULL)
158 """ % sqlvalues(162 """ % sqlvalues(
159 stay_of_execution, ArchivePurpose.PPA, self.blacklist,163 stay_of_execution=stay_of_execution,
160 ArchivePurpose.PPA, stay_of_execution))164 archive_types=archive_types,
165 blacklist=self.blacklist,
166 ppa=ArchivePurpose.PPA))
161167
162 lfa_ids = results.get_all()168 lfa_ids = results.get_all()
163 return lfa_ids169 return lfa_ids
164170
=== renamed file 'lib/lp/soyuz/scripts/tests/test_expire_ppa_bins.py' => 'lib/lp/soyuz/scripts/tests/test_expire_archive_files.py'
--- lib/lp/soyuz/scripts/tests/test_expire_ppa_bins.py 2010-02-27 20:20:03 +0000
+++ lib/lp/soyuz/scripts/tests/test_expire_archive_files.py 2010-03-10 12:10:46 +0000
@@ -1,12 +1,10 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009 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-ppa-binaries.py script. """4"""Test the expire-archive-files.py script. """
55
6from datetime import datetime, timedelta
6import pytz7import pytz
7
8from datetime import datetime, timedelta
9
10import unittest8import unittest
119
12from zope.component import getUtility10from zope.component import getUtility
@@ -15,35 +13,20 @@
15from canonical.launchpad.scripts import QuietFakeLogger13from canonical.launchpad.scripts import QuietFakeLogger
16from canonical.testing.layers import LaunchpadZopelessLayer14from canonical.testing.layers import LaunchpadZopelessLayer
17from lp.registry.interfaces.distribution import IDistributionSet15from lp.registry.interfaces.distribution import IDistributionSet
18from lp.registry.interfaces.person import IPersonSet16from lp.soyuz.interfaces.archive import ArchivePurpose
19from lp.soyuz.scripts.expire_ppa_binaries import PPABinaryExpirer17from lp.soyuz.scripts.expire_archive_files import ArchiveExpirer
20from lp.soyuz.tests.test_publishing import SoyuzTestPublisher18from lp.soyuz.tests.test_publishing import SoyuzTestPublisher
21from lp.testing import TestCaseWithFactory19from lp.testing import TestCaseWithFactory
2220
2321
24class TestPPABinaryExpiry(TestCaseWithFactory):22class ArchiveExpiryTestBase(TestCaseWithFactory):
25 """Test the expire-ppa-binaries.py script."""23 """base class for the expire-archive-files.py script tests."""
26
27 layer = LaunchpadZopelessLayer24 layer = LaunchpadZopelessLayer
28 dbuser = config.binaryfile_expire.dbuser25 dbuser = config.binaryfile_expire.dbuser
2926
30 # We need to test several cases are handled properly:
31 # - publications with no "dateremoved" are not expired
32 # - publications with dateremoved <= 30 days ago are not expired
33 # - publications with dateremoved > 30 days ago are expired
34 # - publications with dateremoved > 30 days ago but refer to a
35 # binary published elsewhere with no dateremoved are not
36 # expired
37 # - publications with dateremoved > 30 days ago but refer to a
38 # binary published elsewhere with dateremoved <= 30 days ago
39 # are not expired
40 # - publications with dateremoved > 30 days ago but refer to a
41 # binary published elsewhere with dateremoved > 30 days ago
42 # are expired.
43
44 def setUp(self):27 def setUp(self):
45 """Set up some test publications."""28 """Set up some test publications."""
46 super(TestPPABinaryExpiry, self).setUp()29 super(ArchiveExpiryTestBase, self).setUp()
47 # Configure the test publisher.30 # Configure the test publisher.
48 self.layer.switchDbUser("launchpad")31 self.layer.switchDbUser("launchpad")
49 self.stp = SoyuzTestPublisher()32 self.stp = SoyuzTestPublisher()
@@ -54,16 +37,12 @@
54 self.under_threshold_date = self.now - timedelta(days=29)37 self.under_threshold_date = self.now - timedelta(days=29)
55 self.over_threshold_date = self.now - timedelta(days=31)38 self.over_threshold_date = self.now - timedelta(days=31)
5639
57 # Prepare two PPAs for the tests to use.
58 self.ppa = self.factory.makeArchive()
59 self.ppa2 = self.factory.makeArchive()
60
61 def getScript(self, test_args=None):40 def getScript(self, test_args=None):
62 """Return a PPABinaryExpirer instance."""41 """Return a ArchiveExpirer instance."""
63 if test_args is None:42 if test_args is None:
64 test_args = []43 test_args = []
65 test_args.extend(['--expire-after', '30'])44 test_args.extend(['--expire-after', '30'])
66 script = PPABinaryExpirer("test expirer", test_args=test_args)45 script = ArchiveExpirer("test expirer", test_args=test_args)
67 script.logger = QuietFakeLogger()46 script.logger = QuietFakeLogger()
68 script.txn = self.layer.txn47 script.txn = self.layer.txn
69 return script48 return script
@@ -75,6 +54,24 @@
75 self.layer.switchDbUser(self.dbuser)54 self.layer.switchDbUser(self.dbuser)
76 script.main()55 script.main()
7756
57 def _setUpExpirablePublications(self, archive=None):
58 """Helper to set up two publications that are both expirable."""
59 if archive is None:
60 archive = self.archive
61 pkg5 = self.stp.getPubSource(
62 sourcename="pkg5", architecturehintlist="i386", archive=archive,
63 dateremoved=self.over_threshold_date)
64 other_source = pkg5.copyTo(
65 pkg5.distroseries, pkg5.pocket, self.archive2)
66 other_source.dateremoved = self.over_threshold_date
67 [pub] = self.stp.getPubBinaries(
68 pub_source=pkg5, dateremoved=self.over_threshold_date,
69 archive=archive)
70 [other_binary] = pub.copyTo(
71 pub.distroarchseries.distroseries, pub.pocket, self.archive2)
72 other_binary.dateremoved = self.over_threshold_date
73 return pkg5, pub
74
78 def assertBinaryExpired(self, publication):75 def assertBinaryExpired(self, publication):
79 self.assertNotEqual(76 self.assertNotEqual(
80 publication.binarypackagerelease.files[0].libraryfile.expires,77 publication.binarypackagerelease.files[0].libraryfile.expires,
@@ -99,13 +96,19 @@
99 None,96 None,
100 "lfa.expires should be None, but it's not.")97 "lfa.expires should be None, but it's not.")
10198
99
100class ArchiveExpiryCommonTests(object):
101 """Common source/binary expiration test cases.
102
103 These will be shared irrespective of archive type (ppa/partner).
104 """
102 def testNoExpirationWithNoDateremoved(self):105 def testNoExpirationWithNoDateremoved(self):
103 """Test that no expiring happens if no dateremoved set."""106 """Test that no expiring happens if no dateremoved set."""
104 pkg1 = self.stp.getPubSource(107 pkg1 = self.stp.getPubSource(
105 sourcename="pkg1", architecturehintlist="i386", archive=self.ppa,108 sourcename="pkg1", architecturehintlist="i386",
106 dateremoved=None)109 archive=self.archive, dateremoved=None)
107 [pub] = self.stp.getPubBinaries(110 [pub] = self.stp.getPubBinaries(
108 pub_source=pkg1, dateremoved=None, archive=self.ppa)111 pub_source=pkg1, dateremoved=None, archive=self.archive)
109112
110 self.runScript()113 self.runScript()
111 self.assertSourceNotExpired(pkg1)114 self.assertSourceNotExpired(pkg1)
@@ -114,11 +117,11 @@
114 def testNoExpirationWithDateUnderThreshold(self):117 def testNoExpirationWithDateUnderThreshold(self):
115 """Test no expiring if dateremoved too recent."""118 """Test no expiring if dateremoved too recent."""
116 pkg2 = self.stp.getPubSource(119 pkg2 = self.stp.getPubSource(
117 sourcename="pkg2", architecturehintlist="i386", archive=self.ppa,120 sourcename="pkg2", architecturehintlist="i386",
118 dateremoved=self.under_threshold_date)121 archive=self.archive, dateremoved=self.under_threshold_date)
119 [pub] = self.stp.getPubBinaries(122 [pub] = self.stp.getPubBinaries(
120 pub_source=pkg2, dateremoved=self.under_threshold_date,123 pub_source=pkg2, dateremoved=self.under_threshold_date,
121 archive=self.ppa)124 archive=self.archive)
122125
123 self.runScript()126 self.runScript()
124 self.assertSourceNotExpired(pkg2)127 self.assertSourceNotExpired(pkg2)
@@ -127,11 +130,11 @@
127 def testExpirationWithDateOverThreshold(self):130 def testExpirationWithDateOverThreshold(self):
128 """Test expiring works if dateremoved old enough."""131 """Test expiring works if dateremoved old enough."""
129 pkg3 = self.stp.getPubSource(132 pkg3 = self.stp.getPubSource(
130 sourcename="pkg3", architecturehintlist="i386", archive=self.ppa,133 sourcename="pkg3", architecturehintlist="i386",
131 dateremoved=self.over_threshold_date)134 archive=self.archive, dateremoved=self.over_threshold_date)
132 [pub] = self.stp.getPubBinaries(135 [pub] = self.stp.getPubBinaries(
133 pub_source=pkg3, dateremoved=self.over_threshold_date,136 pub_source=pkg3, dateremoved=self.over_threshold_date,
134 archive=self.ppa)137 archive=self.archive)
135138
136 self.runScript()139 self.runScript()
137 self.assertSourceExpired(pkg3)140 self.assertSourceExpired(pkg3)
@@ -140,16 +143,16 @@
140 def testNoExpirationWithDateOverThresholdAndOtherValidPublication(self):143 def testNoExpirationWithDateOverThresholdAndOtherValidPublication(self):
141 """Test no expiry if dateremoved old enough but other publication."""144 """Test no expiry if dateremoved old enough but other publication."""
142 pkg4 = self.stp.getPubSource(145 pkg4 = self.stp.getPubSource(
143 sourcename="pkg4", architecturehintlist="i386", archive=self.ppa,146 sourcename="pkg4", architecturehintlist="i386",
144 dateremoved=self.over_threshold_date)147 archive=self.archive, dateremoved=self.over_threshold_date)
145 other_source = pkg4.copyTo(148 other_source = pkg4.copyTo(
146 pkg4.distroseries, pkg4.pocket, self.ppa2)149 pkg4.distroseries, pkg4.pocket, self.archive2)
147 other_source.dateremoved = None150 other_source.dateremoved = None
148 [pub] = self.stp.getPubBinaries(151 [pub] = self.stp.getPubBinaries(
149 pub_source=pkg4, dateremoved=self.over_threshold_date,152 pub_source=pkg4, dateremoved=self.over_threshold_date,
150 archive=self.ppa)153 archive=self.archive)
151 [other_binary] = pub.copyTo(154 [other_binary] = pub.copyTo(
152 pub.distroarchseries.distroseries, pub.pocket, self.ppa2)155 pub.distroarchseries.distroseries, pub.pocket, self.archive2)
153 other_binary.dateremoved = None156 other_binary.dateremoved = None
154157
155 self.runScript()158 self.runScript()
@@ -163,40 +166,22 @@
163 not over date threshold.166 not over date threshold.
164 """167 """
165 pkg5 = self.stp.getPubSource(168 pkg5 = self.stp.getPubSource(
166 sourcename="pkg5", architecturehintlist="i386", archive=self.ppa,169 sourcename="pkg5", architecturehintlist="i386",
167 dateremoved=self.over_threshold_date)170 archive=self.archive, dateremoved=self.over_threshold_date)
168 other_source = pkg5.copyTo(171 other_source = pkg5.copyTo(
169 pkg5.distroseries, pkg5.pocket, self.ppa2)172 pkg5.distroseries, pkg5.pocket, self.archive2)
170 other_source.dateremoved = self.under_threshold_date173 other_source.dateremoved = self.under_threshold_date
171 [pub] = self.stp.getPubBinaries(174 [pub] = self.stp.getPubBinaries(
172 pub_source=pkg5, dateremoved=self.over_threshold_date,175 pub_source=pkg5, dateremoved=self.over_threshold_date,
173 archive=self.ppa)176 archive=self.archive)
174 [other_binary] = pub.copyTo(177 [other_binary] = pub.copyTo(
175 pub.distroarchseries.distroseries, pub.pocket, self.ppa2)178 pub.distroarchseries.distroseries, pub.pocket, self.archive2)
176 other_binary.dateremoved = self.under_threshold_date179 other_binary.dateremoved = self.under_threshold_date
177180
178 self.runScript()181 self.runScript()
179 self.assertSourceNotExpired(pkg5)182 self.assertSourceNotExpired(pkg5)
180 self.assertBinaryNotExpired(pub)183 self.assertBinaryNotExpired(pub)
181184
182 def _setUpExpirablePublications(self, archive=None):
183 """Helper to set up two publications that are both expirable."""
184 if archive is None:
185 archive = self.ppa
186 pkg5 = self.stp.getPubSource(
187 sourcename="pkg5", architecturehintlist="i386", archive=archive,
188 dateremoved=self.over_threshold_date)
189 other_source = pkg5.copyTo(
190 pkg5.distroseries, pkg5.pocket, self.ppa2)
191 other_source.dateremoved = self.over_threshold_date
192 [pub] = self.stp.getPubBinaries(
193 pub_source=pkg5, dateremoved=self.over_threshold_date,
194 archive=archive)
195 [other_binary] = pub.copyTo(
196 pub.distroarchseries.distroseries, pub.pocket, self.ppa2)
197 other_binary.dateremoved = self.over_threshold_date
198 return pkg5, pub
199
200 def testNoExpirationWithDateOverThresholdAndOtherPubOverThreshold(self):185 def testNoExpirationWithDateOverThresholdAndOtherPubOverThreshold(self):
201 """Test expiring works.186 """Test expiring works.
202187
@@ -208,26 +193,6 @@
208 self.assertSourceExpired(source)193 self.assertSourceExpired(source)
209 self.assertBinaryExpired(binary)194 self.assertBinaryExpired(binary)
210195
211 def testBlacklistingWorks(self):
212 """Test that blacklisted PPAs are not expired."""
213 source, binary = self._setUpExpirablePublications(archive=self.ppa)
214 script = self.getScript()
215 script.blacklist = [self.ppa.owner.name, ]
216 self.layer.txn.commit()
217 self.layer.switchDbUser(self.dbuser)
218 script.main()
219 self.assertSourceNotExpired(source)
220 self.assertBinaryNotExpired(binary)
221
222 def testPrivatePPAsNotExpired(self):
223 """Test that private PPAs are not expired."""
224 self.ppa.private = True
225 self.ppa.buildd_secret = "foo"
226 source, binary = self._setUpExpirablePublications()
227 self.runScript()
228 self.assertSourceNotExpired(source)
229 self.assertBinaryNotExpired(binary)
230
231 def testDryRun(self):196 def testDryRun(self):
232 """Test that when dryrun is specified, nothing is expired."""197 """Test that when dryrun is specified, nothing is expired."""
233 source, binary = self._setUpExpirablePublications()198 source, binary = self._setUpExpirablePublications()
@@ -240,7 +205,7 @@
240 self.assertSourceNotExpired(source)205 self.assertSourceNotExpired(source)
241 self.assertBinaryNotExpired(binary)206 self.assertBinaryNotExpired(binary)
242207
243 def testDoesNotAffectNonPPA(self):208 def testDoesNotAffectPrimary(self):
244 """Test that expiry does not happen for non-PPA publications."""209 """Test that expiry does not happen for non-PPA publications."""
245 ubuntu_archive = getUtility(IDistributionSet)['ubuntu'].main_archive210 ubuntu_archive = getUtility(IDistributionSet)['ubuntu'].main_archive
246 source, binary = self._setUpExpirablePublications(ubuntu_archive)211 source, binary = self._setUpExpirablePublications(ubuntu_archive)
@@ -249,5 +214,55 @@
249 self.assertBinaryNotExpired(binary)214 self.assertBinaryNotExpired(binary)
250215
251216
217class TestPPAExpiry(ArchiveExpiryTestBase, ArchiveExpiryCommonTests):
218 """Test the expire-archive-files.py script.
219
220 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 expiry
222 based on a "black list" or on the fact that PPA is private).
223 """
224
225 def setUp(self):
226 """Set up some test publications."""
227 super(TestPPAExpiry, self).setUp()
228 # Prepare two PPAs for the tests to use.
229 self.archive = self.factory.makeArchive()
230 self.archive2 = self.factory.makeArchive()
231
232 def testBlacklistingWorks(self):
233 """Test that blacklisted PPAs are not expired."""
234 source, binary = self._setUpExpirablePublications(
235 archive=self.archive)
236 script = self.getScript()
237 script.blacklist = [self.archive.owner.name, ]
238 self.layer.txn.commit()
239 self.layer.switchDbUser(self.dbuser)
240 script.main()
241 self.assertSourceNotExpired(source)
242 self.assertBinaryNotExpired(binary)
243
244 def testPrivatePPAsNotExpired(self):
245 """Test that private PPAs are not expired."""
246 self.archive.private = True
247 self.archive.buildd_secret = "foo"
248 source, binary = self._setUpExpirablePublications()
249 self.runScript()
250 self.assertSourceNotExpired(source)
251 self.assertBinaryNotExpired(binary)
252
253
254class TestPartnerExpiry(ArchiveExpiryTestBase, ArchiveExpiryCommonTests):
255 """Test the expire-archive-files.py script on partner archives."""
256
257 def setUp(self):
258 """Set up the partner archives under test."""
259 super(TestPartnerExpiry, self).setUp()
260 # Prepare two partner archives for the tests to use.
261 self.archive = self.factory.makeArchive(
262 purpose=ArchivePurpose.PARTNER)
263 self.archive2 = self.factory.makeArchive(
264 purpose=ArchivePurpose.PARTNER)
265
266
252def test_suite():267def test_suite():
253 return unittest.TestLoader().loadTestsFromName(__name__)268 return unittest.TestLoader().loadTestsFromName(__name__)