13571.3.1
by Jonathan Lange
Actually make the PPA private. |
1 |
# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
|
8687.15.34
by Karl Fogel
Add license header blocks to .py, .zcml, and .pt files that don't have it |
2 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
3 |
||
8971.16.1
by Michael Nelson
Added failing test. |
4 |
"""Test Archive features."""
|
8697.14.1
by Michael Nelson
Committing pre-2a changes to new branch. |
5 |
|
12505.4.1
by Robert Collins
Hopefully fix bug 727560 by permitting a much better query plan for folk querying the primary archive. |
6 |
from datetime import ( |
7 |
date, |
|
8 |
datetime, |
|
9 |
timedelta, |
|
10 |
)
|
|
7675.1146.11
by Raphael Badin
Refactor test to use DocTestMatches. |
11 |
import doctest |
11149.9.1
by William Grant
Replace findDepCandidateByName doctests with unit tests. |
12 |
|
13168.12.32
by Raphael Badin
Apply MP's comments. |
13 |
from testtools.matchers import ( |
14 |
DocTestMatches, |
|
15 |
MatchesRegex, |
|
13466.1.1
by Julian Edwards
Replace loads of assertions with a single MatchesStructure. |
16 |
MatchesStructure, |
13168.12.32
by Raphael Badin
Apply MP's comments. |
17 |
)
|
13137.1.19
by Aaron Bentley
Fix merge error. |
18 |
from testtools.testcase import ExpectedException |
11149.9.1
by William Grant
Replace findDepCandidateByName doctests with unit tests. |
19 |
import transaction |
8697.14.1
by Michael Nelson
Committing pre-2a changes to new branch. |
20 |
from zope.component import getUtility |
7675.724.4
by Julian Edwards
Add zcml for security and tests. |
21 |
from zope.security.interfaces import Unauthorized |
9658.1.3
by William Grant
Add tests. |
22 |
from zope.security.proxy import removeSecurityProxy |
8697.14.1
by Michael Nelson
Committing pre-2a changes to new branch. |
23 |
|
10137.3.15
by Paul Hummer
Cleaned up lint in test_archive |
24 |
from canonical.database.sqlbase import sqlvalues |
10137.3.8
by Paul Hummer
Got the test stubs not erroring. |
25 |
from canonical.launchpad.webapp.interfaces import ( |
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
26 |
DEFAULT_FLAVOR, |
27 |
IStoreSelector, |
|
28 |
MAIN_STORE, |
|
29 |
)
|
|
11666.3.5
by Curtis Hovey
Import layers from canonical.testing.layers. |
30 |
from canonical.testing.layers import ( |
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
31 |
DatabaseFunctionalLayer, |
32 |
LaunchpadZopelessLayer, |
|
33 |
)
|
|
12019.8.2
by William Grant
Replace most of archive-files.txt with unittests in test_archive. The remainder is now build-files.txt. |
34 |
from lp.app.errors import NotFoundError |
13130.1.12
by Curtis Hovey
Sorted imports. |
35 |
from lp.app.interfaces.launchpad import ILaunchpadCelebrities |
11458.1.1
by Jelmer Vernooij
Move enums of buildmaster. |
36 |
from lp.buildmaster.enums import BuildStatus |
12505.4.1
by Robert Collins
Hopefully fix bug 727560 by permitting a much better query plan for folk querying the primary archive. |
37 |
from lp.registry.interfaces.person import ( |
38 |
IPersonSet, |
|
39 |
TeamSubscriptionPolicy, |
|
40 |
)
|
|
10156.2.3
by Jelmer Vernooij
Add some tests for checkUpload, canUpload. |
41 |
from lp.registry.interfaces.pocket import PackagePublishingPocket |
11265.2.6
by James Westby
Add some tests for canUploadSuiteSourcePackage. |
42 |
from lp.registry.interfaces.series import SeriesStatus |
13410.1.28
by Julian Edwards
Add (failing) test. |
43 |
from lp.services.features.testing import FeatureFixture |
10137.3.9
by Paul Hummer
Got tests working |
44 |
from lp.services.job.interfaces.job import JobStatus |
12177.11.6
by William Grant
Turn DistroSeries.components into a cachedproperty, and fix a test to cope. |
45 |
from lp.services.propertycache import clear_property_cache |
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
46 |
from lp.services.worlddata.interfaces.country import ICountrySet |
7675.1146.10
by Raphael Badin
Add complex overlay unit test. |
47 |
from lp.soyuz.adapters.archivedependencies import ( |
48 |
get_sources_list_for_building, |
|
49 |
)
|
|
11411.6.2
by Julian Edwards
Change code imports for ArchivePurpose and ArchiveStatus |
50 |
from lp.soyuz.enums import ( |
12981.1.2
by Raphael Badin
Roll back 12977. |
51 |
ArchivePermissionType, |
11411.6.2
by Julian Edwards
Change code imports for ArchivePurpose and ArchiveStatus |
52 |
ArchivePurpose, |
53 |
ArchiveStatus, |
|
13410.1.12
by Julian Edwards
Fix lint. |
54 |
PackageCopyPolicy, |
11411.6.12
by Julian Edwards
Move PackagePublishingStatus/Priority |
55 |
PackagePublishingStatus, |
13410.1.12
by Julian Edwards
Fix lint. |
56 |
)
|
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
57 |
from lp.soyuz.interfaces.archive import ( |
13137.1.16
by Aaron Bentley
Add tests. |
58 |
ArchiveDependencyError, |
11347.7.2
by Steve Kowalik
Change the imports to use the new agreed style |
59 |
ArchiveDisabled, |
13410.1.3
by Julian Edwards
Move the interface declaration to IArchiveView and implement direct upload |
60 |
CannotCopy, |
11347.7.2
by Steve Kowalik
Change the imports to use the new agreed style |
61 |
CannotRestrictArchitectures, |
62 |
CannotUploadToPocket, |
|
63 |
CannotUploadToPPA, |
|
13410.1.28
by Julian Edwards
Add (failing) test. |
64 |
ForbiddenByFeatureFlag, |
11347.7.2
by Steve Kowalik
Change the imports to use the new agreed style |
65 |
IArchiveSet, |
66 |
InsufficientUploadRights, |
|
67 |
InvalidPocketForPartnerArchive, |
|
68 |
InvalidPocketForPPA, |
|
69 |
NoRightsForArchive, |
|
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
70 |
NoRightsForComponent, |
12505.4.1
by Robert Collins
Hopefully fix bug 727560 by permitting a much better query plan for folk querying the primary archive. |
71 |
VersionRequiresName, |
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
72 |
)
|
7675.561.2
by Michael Nelson
Resolved conflicts |
73 |
from lp.soyuz.interfaces.archivearch import IArchiveArchSet |
11265.2.13
by James Westby
Merge test_permission from archiveuploader in to test_archive. |
74 |
from lp.soyuz.interfaces.archivepermission import IArchivePermissionSet |
7675.590.12
by William Grant
Add Archive.getBinaryPackageRelease, allowing BPR retrieval by name, version, and build DAS arch tag. |
75 |
from lp.soyuz.interfaces.binarypackagename import IBinaryPackageNameSet |
10156.2.13
by Jelmer Vernooij
Fix tests. |
76 |
from lp.soyuz.interfaces.component import IComponentSet |
13410.1.1
by Julian Edwards
Add a test for the yet unwritten copyPackage. |
77 |
from lp.soyuz.interfaces.packagecopyjob import IPlainPackageCopyJobSource |
7675.557.20
by Jelmer Vernooij
Add a check box to archive admin pages to allow/disallow builds on ARM. |
78 |
from lp.soyuz.interfaces.processor import IProcessorFamilySet |
11706.2.5
by Steve Kowalik
* Remove acceptance. |
79 |
from lp.soyuz.model.archive import Archive |
13765.2.1
by Benji York
permissions that are already removed can be removed again |
80 |
from lp.soyuz.model.archivepermission import ( |
81 |
ArchivePermission, |
|
82 |
ArchivePermissionSet, |
|
83 |
)
|
|
7675.583.4
by William Grant
Add and test Archive.updatePackageDownloadCount. |
84 |
from lp.soyuz.model.binarypackagerelease import ( |
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
85 |
BinaryPackageReleaseDownloadCount, |
86 |
)
|
|
7675.884.7
by William Grant
Add getComponentsForSeries tests. |
87 |
from lp.soyuz.model.component import ComponentSelection |
8697.14.1
by Michael Nelson
Committing pre-2a changes to new branch. |
88 |
from lp.soyuz.tests.test_publishing import SoyuzTestPublisher |
11265.2.5
by James Westby
Remove some small uses in the next test class. |
89 |
from lp.testing import ( |
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
90 |
ANONYMOUS, |
12981.1.2
by Raphael Badin
Roll back 12977. |
91 |
celebrity_logged_in, |
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
92 |
login, |
93 |
login_person, |
|
94 |
person_logged_in, |
|
95 |
TestCaseWithFactory, |
|
96 |
)
|
|
7675.767.12
by William Grant
Use lp.testing.sampledata instead of hardcoding sampledata email address. |
97 |
from lp.testing.sampledata import COMMERCIAL_ADMIN_EMAIL |
8697.14.1
by Michael Nelson
Committing pre-2a changes to new branch. |
98 |
|
10137.3.8
by Paul Hummer
Got the test stubs not erroring. |
99 |
|
8697.14.1
by Michael Nelson
Committing pre-2a changes to new branch. |
100 |
class TestGetPublicationsInArchive(TestCaseWithFactory): |
101 |
||
11265.1.2
by James Westby
Move a test class down to DatabaseFunctionalLayer. |
102 |
layer = DatabaseFunctionalLayer |
8697.14.1
by Michael Nelson
Committing pre-2a changes to new branch. |
103 |
|
11265.1.10
by James Westby
First set of tweaks from jml's review. |
104 |
def makeArchivesForOneDistribution(self, count=3): |
11265.1.1
by James Westby
Start the attack on Soyuz sampledata. |
105 |
distribution = self.factory.makeDistribution() |
106 |
archives = [] |
|
11265.1.10
by James Westby
First set of tweaks from jml's review. |
107 |
for i in range(count): |
11265.1.1
by James Westby
Start the attack on Soyuz sampledata. |
108 |
archives.append( |
109 |
self.factory.makeArchive(distribution=distribution)) |
|
110 |
return archives |
|
111 |
||
11265.1.10
by James Westby
First set of tweaks from jml's review. |
112 |
def makeArchivesWithPublications(self, count=3): |
113 |
archives = self.makeArchivesForOneDistribution(count=count) |
|
11265.1.1
by James Westby
Start the attack on Soyuz sampledata. |
114 |
sourcepackagename = self.factory.makeSourcePackageName() |
115 |
for archive in archives: |
|
116 |
self.factory.makeSourcePackagePublishingHistory( |
|
117 |
sourcepackagename=sourcepackagename, archive=archive, |
|
118 |
status=PackagePublishingStatus.PUBLISHED, |
|
119 |
)
|
|
120 |
return archives, sourcepackagename |
|
121 |
||
122 |
def getPublications(self, sourcepackagename, archives, distribution): |
|
123 |
return getUtility(IArchiveSet).getPublicationsInArchives( |
|
124 |
sourcepackagename, archives, distribution=distribution) |
|
8697.14.1
by Michael Nelson
Committing pre-2a changes to new branch. |
125 |
|
11265.1.10
by James Westby
First set of tweaks from jml's review. |
126 |
def test_getPublications_returns_all_published_publications(self): |
8697.14.1
by Michael Nelson
Committing pre-2a changes to new branch. |
127 |
# Returns all currently published publications for archives
|
11265.1.13
by James Westby
Fix some silly errors caused by the tweaks. |
128 |
archives, sourcepackagename = self.makeArchivesWithPublications() |
11265.1.1
by James Westby
Start the attack on Soyuz sampledata. |
129 |
results = self.getPublications( |
130 |
sourcepackagename, archives, archives[0].distribution) |
|
8697.14.1
by Michael Nelson
Committing pre-2a changes to new branch. |
131 |
num_results = results.count() |
11265.1.10
by James Westby
First set of tweaks from jml's review. |
132 |
self.assertEquals(3, num_results) |
8697.14.1
by Michael Nelson
Committing pre-2a changes to new branch. |
133 |
|
11265.1.10
by James Westby
First set of tweaks from jml's review. |
134 |
def test_getPublications_empty_list_of_archives(self): |
8697.14.1
by Michael Nelson
Committing pre-2a changes to new branch. |
135 |
# Passing an empty list of archives will result in an empty
|
136 |
# resultset.
|
|
11265.1.13
by James Westby
Fix some silly errors caused by the tweaks. |
137 |
archives, sourcepackagename = self.makeArchivesWithPublications() |
11265.1.1
by James Westby
Start the attack on Soyuz sampledata. |
138 |
results = self.getPublications( |
139 |
sourcepackagename, [], archives[0].distribution) |
|
11265.1.13
by James Westby
Fix some silly errors caused by the tweaks. |
140 |
self.assertEquals([], list(results)) |
11265.1.10
by James Westby
First set of tweaks from jml's review. |
141 |
|
142 |
def assertPublicationsFromArchives(self, publications, archives): |
|
143 |
self.assertEquals(len(archives), publications.count()) |
|
144 |
for publication, archive in zip(publications, archives): |
|
145 |
self.assertEquals(archive, publication.archive) |
|
146 |
||
147 |
def test_getPublications_returns_only_for_given_archives(self): |
|
8697.14.1
by Michael Nelson
Committing pre-2a changes to new branch. |
148 |
# Returns only publications for the specified archives
|
11265.1.13
by James Westby
Fix some silly errors caused by the tweaks. |
149 |
archives, sourcepackagename = self.makeArchivesWithPublications() |
11265.1.1
by James Westby
Start the attack on Soyuz sampledata. |
150 |
results = self.getPublications( |
151 |
sourcepackagename, [archives[0]], archives[0].distribution) |
|
11265.1.10
by James Westby
First set of tweaks from jml's review. |
152 |
self.assertPublicationsFromArchives(results, [archives[0]]) |
8697.14.1
by Michael Nelson
Committing pre-2a changes to new branch. |
153 |
|
11265.1.10
by James Westby
First set of tweaks from jml's review. |
154 |
def test_getPublications_returns_only_published_publications(self): |
8697.14.1
by Michael Nelson
Committing pre-2a changes to new branch. |
155 |
# Publications that are not published will not be returned.
|
11265.1.1
by James Westby
Start the attack on Soyuz sampledata. |
156 |
archive = self.factory.makeArchive() |
157 |
sourcepackagename = self.factory.makeSourcePackageName() |
|
158 |
self.factory.makeSourcePackagePublishingHistory( |
|
159 |
archive=archive, sourcepackagename=sourcepackagename, |
|
160 |
status=PackagePublishingStatus.PENDING) |
|
161 |
results = self.getPublications( |
|
162 |
sourcepackagename, [archive], archive.distribution) |
|
11265.1.13
by James Westby
Fix some silly errors caused by the tweaks. |
163 |
self.assertEquals([], list(results)) |
8697.14.1
by Michael Nelson
Committing pre-2a changes to new branch. |
164 |
|
11265.1.4
by James Westby
Reuse some more code. |
165 |
def publishSourceInNewArchive(self, sourcepackagename): |
11265.1.1
by James Westby
Start the attack on Soyuz sampledata. |
166 |
distribution = self.factory.makeDistribution() |
167 |
distroseries = self.factory.makeDistroSeries( |
|
168 |
distribution=distribution) |
|
169 |
archive = self.factory.makeArchive(distribution=distribution) |
|
170 |
self.factory.makeSourcePackagePublishingHistory( |
|
171 |
archive=archive, sourcepackagename=sourcepackagename, |
|
172 |
distroseries=distroseries, |
|
173 |
status=PackagePublishingStatus.PUBLISHED) |
|
11265.1.4
by James Westby
Reuse some more code. |
174 |
return archive |
175 |
||
11265.1.10
by James Westby
First set of tweaks from jml's review. |
176 |
def test_getPublications_for_specific_distro(self): |
11265.1.4
by James Westby
Reuse some more code. |
177 |
# Results can be filtered for specific distributions.
|
178 |
sourcepackagename = self.factory.makeSourcePackageName() |
|
179 |
archive = self.publishSourceInNewArchive(sourcepackagename) |
|
180 |
other_archive = self.publishSourceInNewArchive(sourcepackagename) |
|
11265.1.1
by James Westby
Start the attack on Soyuz sampledata. |
181 |
# We don't get the results for other_distribution
|
182 |
results = self.getPublications( |
|
183 |
sourcepackagename, [archive, other_archive], |
|
11265.1.4
by James Westby
Reuse some more code. |
184 |
distribution=archive.distribution) |
11265.1.10
by James Westby
First set of tweaks from jml's review. |
185 |
self.assertPublicationsFromArchives(results, [archive]) |
8697.15.4
by Michael Nelson
Made the distribution arg mandatory on IArchiveSet.getPublicationsInArchives(). |
186 |
|
8919.2.2
by Celso Providelo
Excluding DDEBs from the PPA repository 'binary_size'. |
187 |
|
188 |
class TestArchiveRepositorySize(TestCaseWithFactory): |
|
189 |
||
190 |
layer = LaunchpadZopelessLayer |
|
191 |
||
11265.1.11
by James Westby
Rest of the tweaks from jml's review. |
192 |
def test_empty_ppa_has_zero_binaries_size(self): |
193 |
# An empty PPA has no binaries so has zero binaries_size.
|
|
194 |
ppa = self.factory.makeArchive(purpose=ArchivePurpose.PPA) |
|
195 |
self.assertEquals(0, ppa.binaries_size) |
|
196 |
||
9592.2.2
by Michael Nelson
Ensures that duplicate files are not included in sources_size count. |
197 |
def test_sources_size_on_empty_archive(self): |
198 |
# Zero is returned for an archive without sources.
|
|
11265.1.1
by James Westby
Start the attack on Soyuz sampledata. |
199 |
archive = self.factory.makeArchive() |
11265.1.11
by James Westby
Rest of the tweaks from jml's review. |
200 |
self.assertEquals(0, archive.sources_size) |
201 |
||
202 |
def publishSourceFile(self, archive, library_file): |
|
203 |
"""Publish a source package with the given content to the archive.
|
|
204 |
||
205 |
:param archive: the IArchive to publish to.
|
|
206 |
:param library_file: a LibraryFileAlias for the content of the
|
|
207 |
source file.
|
|
208 |
"""
|
|
11265.1.1
by James Westby
Start the attack on Soyuz sampledata. |
209 |
sourcepackagerelease = self.factory.makeSourcePackageRelease() |
210 |
self.factory.makeSourcePackagePublishingHistory( |
|
211 |
archive=archive, sourcepackagerelease=sourcepackagerelease, |
|
212 |
status=PackagePublishingStatus.PUBLISHED) |
|
213 |
self.factory.makeSourcePackageReleaseFile( |
|
214 |
sourcepackagerelease=sourcepackagerelease, |
|
11265.1.11
by James Westby
Rest of the tweaks from jml's review. |
215 |
library_file=library_file) |
11265.1.1
by James Westby
Start the attack on Soyuz sampledata. |
216 |
|
9592.2.1
by Michael Nelson
Added broken test. |
217 |
def test_sources_size_does_not_count_duplicated_files(self): |
218 |
# If there are multiple copies of the same file name/size
|
|
219 |
# only one will be counted.
|
|
11265.1.1
by James Westby
Start the attack on Soyuz sampledata. |
220 |
archive = self.factory.makeArchive() |
11265.1.11
by James Westby
Rest of the tweaks from jml's review. |
221 |
library_file = self.factory.makeLibraryFileAlias() |
11265.1.13
by James Westby
Fix some silly errors caused by the tweaks. |
222 |
self.publishSourceFile(archive, library_file) |
11265.1.1
by James Westby
Start the attack on Soyuz sampledata. |
223 |
self.assertEquals( |
11265.1.11
by James Westby
Rest of the tweaks from jml's review. |
224 |
library_file.content.filesize, archive.sources_size) |
11265.1.1
by James Westby
Start the attack on Soyuz sampledata. |
225 |
|
11265.1.14
by James Westby
One more mistake in the renamings. |
226 |
self.publishSourceFile(archive, library_file) |
11265.1.1
by James Westby
Start the attack on Soyuz sampledata. |
227 |
self.assertEquals( |
11265.1.11
by James Westby
Rest of the tweaks from jml's review. |
228 |
library_file.content.filesize, archive.sources_size) |
9592.2.1
by Michael Nelson
Added broken test. |
229 |
|
8919.2.2
by Celso Providelo
Excluding DDEBs from the PPA repository 'binary_size'. |
230 |
|
8971.16.1
by Michael Nelson
Added failing test. |
231 |
class TestSeriesWithSources(TestCaseWithFactory): |
232 |
"""Create some sources in different series."""
|
|
8971.16.2
by Michael Nelson
Replaced old implementation with updated storm version that satisfies the tests. |
233 |
|
11265.2.1
by James Westby
More removal of sampledata in the tests. |
234 |
layer = DatabaseFunctionalLayer |
8971.16.1
by Michael Nelson
Added failing test. |
235 |
|
236 |
def test_series_with_sources_returns_all_series(self): |
|
237 |
# Calling series_with_sources returns all series with publishings.
|
|
11265.2.1
by James Westby
More removal of sampledata in the tests. |
238 |
distribution = self.factory.makeDistribution() |
239 |
archive = self.factory.makeArchive(distribution=distribution) |
|
13137.1.17
by Aaron Bentley
Fix lint. |
240 |
self.factory.makeDistroSeries( |
11265.2.11
by James Westby
Fix up some more tests. |
241 |
distribution=distribution, version="0.5") |
11265.2.1
by James Westby
More removal of sampledata in the tests. |
242 |
series_with_sources1 = self.factory.makeDistroSeries( |
11265.2.11
by James Westby
Fix up some more tests. |
243 |
distribution=distribution, version="1") |
11265.2.1
by James Westby
More removal of sampledata in the tests. |
244 |
self.factory.makeSourcePackagePublishingHistory( |
245 |
distroseries=series_with_sources1, archive=archive, |
|
246 |
status=PackagePublishingStatus.PUBLISHED) |
|
247 |
series_with_sources2 = self.factory.makeDistroSeries( |
|
11265.2.11
by James Westby
Fix up some more tests. |
248 |
distribution=distribution, version="2") |
11265.2.1
by James Westby
More removal of sampledata in the tests. |
249 |
self.factory.makeSourcePackagePublishingHistory( |
250 |
distroseries=series_with_sources2, archive=archive, |
|
251 |
status=PackagePublishingStatus.PENDING) |
|
252 |
self.assertEqual( |
|
11265.2.11
by James Westby
Fix up some more tests. |
253 |
[series_with_sources2, series_with_sources1], |
254 |
archive.series_with_sources) |
|
8971.16.1
by Michael Nelson
Added failing test. |
255 |
|
256 |
def test_series_with_sources_ignore_non_published_records(self): |
|
257 |
# If all publishings in a series are deleted or superseded
|
|
258 |
# the series will not be returned.
|
|
11265.2.1
by James Westby
More removal of sampledata in the tests. |
259 |
series = self.factory.makeDistroSeries() |
260 |
archive = self.factory.makeArchive(distribution=series.distribution) |
|
261 |
self.factory.makeSourcePackagePublishingHistory( |
|
262 |
distroseries=series, archive=archive, |
|
263 |
status=PackagePublishingStatus.DELETED) |
|
264 |
self.assertEqual([], archive.series_with_sources) |
|
8971.16.1
by Michael Nelson
Added failing test. |
265 |
|
8971.16.2
by Michael Nelson
Replaced old implementation with updated storm version that satisfies the tests. |
266 |
def test_series_with_sources_ordered_by_version(self): |
267 |
# The returned series are ordered by the distroseries version.
|
|
11265.2.1
by James Westby
More removal of sampledata in the tests. |
268 |
distribution = self.factory.makeDistribution() |
269 |
archive = self.factory.makeArchive(distribution=distribution) |
|
270 |
series1 = self.factory.makeDistroSeries( |
|
271 |
version="1", distribution=distribution) |
|
272 |
series2 = self.factory.makeDistroSeries( |
|
273 |
version="2", distribution=distribution) |
|
274 |
self.factory.makeSourcePackagePublishingHistory( |
|
275 |
distroseries=series1, archive=archive, |
|
276 |
status=PackagePublishingStatus.PUBLISHED) |
|
277 |
self.factory.makeSourcePackagePublishingHistory( |
|
278 |
distroseries=series2, archive=archive, |
|
279 |
status=PackagePublishingStatus.PUBLISHED) |
|
280 |
self.assertEqual([series2, series1], archive.series_with_sources) |
|
281 |
# Change the version such that they should order differently
|
|
282 |
removeSecurityProxy(series2).version = "0.5" |
|
283 |
# ... and check that they do
|
|
284 |
self.assertEqual([series1, series2], archive.series_with_sources) |
|
8971.16.1
by Michael Nelson
Added failing test. |
285 |
|
9461.5.1
by Michael Nelson
Added IArchive.getSourcePackageReleases. |
286 |
|
287 |
class TestGetSourcePackageReleases(TestCaseWithFactory): |
|
288 |
||
11265.2.1
by James Westby
More removal of sampledata in the tests. |
289 |
layer = DatabaseFunctionalLayer |
290 |
||
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
291 |
def createArchiveWithBuilds(self, statuses): |
11265.2.1
by James Westby
More removal of sampledata in the tests. |
292 |
archive = self.factory.makeArchive() |
293 |
sprs = [] |
|
294 |
for status in statuses: |
|
295 |
sourcepackagerelease = self.factory.makeSourcePackageRelease() |
|
296 |
self.factory.makeBinaryPackageBuild( |
|
297 |
source_package_release=sourcepackagerelease, |
|
298 |
archive=archive, status=status) |
|
299 |
sprs.append(sourcepackagerelease) |
|
13137.1.17
by Aaron Bentley
Fix lint. |
300 |
self.factory.makeSourcePackageRelease() |
11265.2.1
by James Westby
More removal of sampledata in the tests. |
301 |
return archive, sprs |
9461.5.1
by Michael Nelson
Added IArchive.getSourcePackageReleases. |
302 |
|
303 |
def test_getSourcePackageReleases_with_no_params(self): |
|
304 |
# With no params all source package releases are returned.
|
|
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
305 |
archive, sprs = self.createArchiveWithBuilds( |
11265.2.1
by James Westby
More removal of sampledata in the tests. |
306 |
[BuildStatus.NEEDSBUILD, BuildStatus.FULLYBUILT]) |
307 |
self.assertContentEqual( |
|
308 |
sprs, archive.getSourcePackageReleases()) |
|
9461.5.1
by Michael Nelson
Added IArchive.getSourcePackageReleases. |
309 |
|
310 |
def test_getSourcePackageReleases_with_buildstatus(self): |
|
311 |
# Results are filtered by the specified buildstatus.
|
|
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
312 |
archive, sprs = self.createArchiveWithBuilds( |
11265.2.1
by James Westby
More removal of sampledata in the tests. |
313 |
[BuildStatus.NEEDSBUILD, BuildStatus.FULLYBUILT]) |
314 |
self.assertContentEqual( |
|
315 |
[sprs[0]], archive.getSourcePackageReleases( |
|
316 |
build_status=BuildStatus.NEEDSBUILD)) |
|
9461.5.1
by Michael Nelson
Added IArchive.getSourcePackageReleases. |
317 |
|
10156.2.16
by Jelmer Vernooij
PEP8 |
318 |
|
9658.1.3
by William Grant
Add tests. |
319 |
class TestCorrespondingDebugArchive(TestCaseWithFactory): |
320 |
||
11265.2.2
by James Westby
Get rid of ubuntutest for something that doesn't need it. |
321 |
layer = DatabaseFunctionalLayer |
9658.1.3
by William Grant
Add tests. |
322 |
|
323 |
def testPrimaryDebugArchiveIsDebug(self): |
|
11265.2.2
by James Westby
Get rid of ubuntutest for something that doesn't need it. |
324 |
distribution = self.factory.makeDistribution() |
325 |
primary = self.factory.makeArchive( |
|
326 |
distribution=distribution, purpose=ArchivePurpose.PRIMARY) |
|
327 |
debug = self.factory.makeArchive( |
|
328 |
distribution=distribution, purpose=ArchivePurpose.DEBUG) |
|
329 |
self.assertEquals(primary.debug_archive, debug) |
|
9658.1.3
by William Grant
Add tests. |
330 |
|
331 |
def testPartnerDebugArchiveIsSelf(self): |
|
11265.2.2
by James Westby
Get rid of ubuntutest for something that doesn't need it. |
332 |
partner = self.factory.makeArchive(purpose=ArchivePurpose.PARTNER) |
333 |
self.assertEquals(partner.debug_archive, partner) |
|
9658.1.3
by William Grant
Add tests. |
334 |
|
335 |
def testCopyDebugArchiveIsSelf(self): |
|
11265.2.2
by James Westby
Get rid of ubuntutest for something that doesn't need it. |
336 |
copy = self.factory.makeArchive(purpose=ArchivePurpose.COPY) |
337 |
self.assertEquals(copy.debug_archive, copy) |
|
9658.1.3
by William Grant
Add tests. |
338 |
|
339 |
def testDebugDebugArchiveIsSelf(self): |
|
11265.2.2
by James Westby
Get rid of ubuntutest for something that doesn't need it. |
340 |
debug = self.factory.makeArchive(purpose=ArchivePurpose.DEBUG) |
341 |
self.assertEquals(debug.debug_archive, debug) |
|
9658.1.3
by William Grant
Add tests. |
342 |
|
343 |
def testPPADebugArchiveIsSelf(self): |
|
11265.2.2
by James Westby
Get rid of ubuntutest for something that doesn't need it. |
344 |
ppa = self.factory.makeArchive(purpose=ArchivePurpose.PPA) |
345 |
self.assertEquals(ppa.debug_archive, ppa) |
|
9658.1.3
by William Grant
Add tests. |
346 |
|
347 |
def testMissingPrimaryDebugArchiveIsNone(self): |
|
11265.2.2
by James Westby
Get rid of ubuntutest for something that doesn't need it. |
348 |
primary = self.factory.makeArchive(purpose=ArchivePurpose.PRIMARY) |
349 |
self.assertIs(primary.debug_archive, None) |
|
9658.1.3
by William Grant
Add tests. |
350 |
|
10137.3.7
by Paul Hummer
Added test stubs |
351 |
|
352 |
class TestArchiveEnableDisable(TestCaseWithFactory): |
|
353 |
"""Test the enable and disable methods of Archive."""
|
|
354 |
||
11265.2.3
by James Westby
Bye bye another needless use of ubuntutest. |
355 |
layer = DatabaseFunctionalLayer |
10137.3.8
by Paul Hummer
Got the test stubs not erroring. |
356 |
|
10137.3.16
by Paul Hummer
Added assertHasBuildJobsWithStatus assertions to enable/disable tests |
357 |
def _getBuildJobsByStatus(self, archive, status): |
358 |
# Return the count for archive build jobs with the given status.
|
|
359 |
query = """ |
|
360 |
SELECT COUNT(Job.id)
|
|
7675.687.73
by Michael Nelson
Updated to get test_archive$ tests working. |
361 |
FROM BinaryPackageBuild, BuildPackageJob, BuildQueue, Job,
|
362 |
PackageBuild, BuildFarmJob
|
|
10137.3.16
by Paul Hummer
Added assertHasBuildJobsWithStatus assertions to enable/disable tests |
363 |
WHERE
|
7675.687.73
by Michael Nelson
Updated to get test_archive$ tests working. |
364 |
BuildPackageJob.build = BinaryPackageBuild.id
|
10137.3.16
by Paul Hummer
Added assertHasBuildJobsWithStatus assertions to enable/disable tests |
365 |
AND BuildPackageJob.job = BuildQueue.job
|
366 |
AND Job.id = BuildQueue.job
|
|
7675.687.73
by Michael Nelson
Updated to get test_archive$ tests working. |
367 |
AND BinaryPackageBuild.package_build = PackageBuild.id
|
368 |
AND PackageBuild.archive = %s |
|
369 |
AND PackageBuild.build_farm_job = BuildFarmJob.id
|
|
370 |
AND BuildFarmJob.status = %s |
|
10137.3.16
by Paul Hummer
Added assertHasBuildJobsWithStatus assertions to enable/disable tests |
371 |
AND Job.status = %s; |
372 |
""" % sqlvalues(archive, BuildStatus.NEEDSBUILD, status) |
|
373 |
||
374 |
store = getUtility(IStoreSelector).get(MAIN_STORE, DEFAULT_FLAVOR) |
|
375 |
return store.execute(query).get_one()[0] |
|
376 |
||
10137.3.13
by Paul Hummer
Cleaned up docstrings and comments |
377 |
def assertNoBuildJobsHaveStatus(self, archive, status): |
378 |
# Check that that the jobs attached to this archive do not have this
|
|
379 |
# status.
|
|
10137.3.16
by Paul Hummer
Added assertHasBuildJobsWithStatus assertions to enable/disable tests |
380 |
self.assertEqual(self._getBuildJobsByStatus(archive, status), 0) |
10137.3.9
by Paul Hummer
Got tests working |
381 |
|
11265.2.3
by James Westby
Bye bye another needless use of ubuntutest. |
382 |
def assertHasBuildJobsWithStatus(self, archive, status, count): |
10137.3.16
by Paul Hummer
Added assertHasBuildJobsWithStatus assertions to enable/disable tests |
383 |
# Check that that there are jobs attached to this archive that have
|
384 |
# the specified status.
|
|
11265.2.3
by James Westby
Bye bye another needless use of ubuntutest. |
385 |
self.assertEqual(self._getBuildJobsByStatus(archive, status), count) |
10137.3.9
by Paul Hummer
Got tests working |
386 |
|
10137.3.7
by Paul Hummer
Added test stubs |
387 |
def test_enableArchive(self): |
10137.3.13
by Paul Hummer
Cleaned up docstrings and comments |
388 |
# Enabling an archive should set all the Archive's suspended builds to
|
10137.3.7
by Paul Hummer
Added test stubs |
389 |
# WAITING.
|
11265.2.3
by James Westby
Bye bye another needless use of ubuntutest. |
390 |
archive = self.factory.makeArchive(enabled=True) |
11583.2.1
by Jonathan Lange
Don't queue the build that's made by makeBinaryPackageBuild. |
391 |
build = self.factory.makeBinaryPackageBuild( |
11265.2.3
by James Westby
Bye bye another needless use of ubuntutest. |
392 |
archive=archive, status=BuildStatus.NEEDSBUILD) |
11583.2.1
by Jonathan Lange
Don't queue the build that's made by makeBinaryPackageBuild. |
393 |
build.queueBuild() |
11265.2.3
by James Westby
Bye bye another needless use of ubuntutest. |
394 |
# disable the archive, as it is currently enabled
|
395 |
removeSecurityProxy(archive).disable() |
|
396 |
self.assertHasBuildJobsWithStatus(archive, JobStatus.SUSPENDED, 1) |
|
397 |
removeSecurityProxy(archive).enable() |
|
398 |
self.assertNoBuildJobsHaveStatus(archive, JobStatus.SUSPENDED) |
|
399 |
self.assertTrue(archive.enabled) |
|
10137.3.9
by Paul Hummer
Got tests working |
400 |
|
10137.3.12
by Paul Hummer
Added tests to make sure the assertions are in place |
401 |
def test_enableArchiveAlreadyEnabled(self): |
402 |
# Enabling an already enabled Archive should raise an AssertionError.
|
|
11265.2.3
by James Westby
Bye bye another needless use of ubuntutest. |
403 |
archive = self.factory.makeArchive(enabled=True) |
404 |
self.assertRaises(AssertionError, removeSecurityProxy(archive).enable) |
|
10137.3.7
by Paul Hummer
Added test stubs |
405 |
|
406 |
def test_disableArchive(self): |
|
10137.3.13
by Paul Hummer
Cleaned up docstrings and comments |
407 |
# Disabling an archive should set all the Archive's pending bulds to
|
408 |
# SUSPENDED.
|
|
11265.2.3
by James Westby
Bye bye another needless use of ubuntutest. |
409 |
archive = self.factory.makeArchive(enabled=True) |
11583.2.1
by Jonathan Lange
Don't queue the build that's made by makeBinaryPackageBuild. |
410 |
build = self.factory.makeBinaryPackageBuild( |
11265.2.3
by James Westby
Bye bye another needless use of ubuntutest. |
411 |
archive=archive, status=BuildStatus.NEEDSBUILD) |
11583.2.1
by Jonathan Lange
Don't queue the build that's made by makeBinaryPackageBuild. |
412 |
build.queueBuild() |
11265.2.3
by James Westby
Bye bye another needless use of ubuntutest. |
413 |
self.assertHasBuildJobsWithStatus(archive, JobStatus.WAITING, 1) |
414 |
removeSecurityProxy(archive).disable() |
|
415 |
self.assertNoBuildJobsHaveStatus(archive, JobStatus.WAITING) |
|
416 |
self.assertFalse(archive.enabled) |
|
10137.3.7
by Paul Hummer
Added test stubs |
417 |
|
10137.3.12
by Paul Hummer
Added tests to make sure the assertions are in place |
418 |
def test_disableArchiveAlreadyDisabled(self): |
10137.3.15
by Paul Hummer
Cleaned up lint in test_archive |
419 |
# Disabling an already disabled Archive should raise an
|
420 |
# AssertionError.
|
|
11265.2.3
by James Westby
Bye bye another needless use of ubuntutest. |
421 |
archive = self.factory.makeArchive(enabled=False) |
422 |
self.assertRaises( |
|
423 |
AssertionError, removeSecurityProxy(archive).disable) |
|
10137.3.12
by Paul Hummer
Added tests to make sure the assertions are in place |
424 |
|
10156.2.16
by Jelmer Vernooij
PEP8 |
425 |
|
10224.10.1
by Michael Nelson
Added failing test, factoring out the relevant code into a private helper method. |
426 |
class TestCollectLatestPublishedSources(TestCaseWithFactory): |
427 |
"""Ensure that the private helper method works as expected."""
|
|
428 |
||
11265.2.4
by James Westby
Remove another use of prepareBreezyAutotest(). |
429 |
layer = DatabaseFunctionalLayer |
430 |
||
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
431 |
def makePublishedSources(self, archive, statuses, versions, names): |
11265.2.4
by James Westby
Remove another use of prepareBreezyAutotest(). |
432 |
for status, version, name in zip(statuses, versions, names): |
433 |
self.factory.makeSourcePackagePublishingHistory( |
|
434 |
sourcepackagename=name, archive=archive, |
|
435 |
version=version, status=status) |
|
10224.10.1
by Michael Nelson
Added failing test, factoring out the relevant code into a private helper method. |
436 |
|
437 |
def test_collectLatestPublishedSources_returns_latest(self): |
|
11265.2.4
by James Westby
Remove another use of prepareBreezyAutotest(). |
438 |
sourcepackagename = self.factory.makeSourcePackageName(name="foo") |
439 |
other_spn = self.factory.makeSourcePackageName(name="bar") |
|
440 |
archive = self.factory.makeArchive() |
|
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
441 |
self.makePublishedSources(archive, |
13137.1.17
by Aaron Bentley
Fix lint. |
442 |
[PackagePublishingStatus.PUBLISHED] * 3, |
11265.2.4
by James Westby
Remove another use of prepareBreezyAutotest(). |
443 |
["1.0", "1.1", "2.0"], |
444 |
[sourcepackagename, sourcepackagename, other_spn]) |
|
445 |
pubs = removeSecurityProxy(archive)._collectLatestPublishedSources( |
|
446 |
archive, ["foo"]) |
|
10224.10.1
by Michael Nelson
Added failing test, factoring out the relevant code into a private helper method. |
447 |
self.assertEqual(1, len(pubs)) |
11265.2.4
by James Westby
Remove another use of prepareBreezyAutotest(). |
448 |
self.assertEqual('1.1', pubs[0].source_package_version) |
10224.10.1
by Michael Nelson
Added failing test, factoring out the relevant code into a private helper method. |
449 |
|
450 |
def test_collectLatestPublishedSources_returns_published_only(self): |
|
451 |
# Set the status of the latest pub to DELETED and ensure that it
|
|
452 |
# is not returned.
|
|
11265.2.4
by James Westby
Remove another use of prepareBreezyAutotest(). |
453 |
sourcepackagename = self.factory.makeSourcePackageName(name="foo") |
454 |
other_spn = self.factory.makeSourcePackageName(name="bar") |
|
455 |
archive = self.factory.makeArchive() |
|
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
456 |
self.makePublishedSources(archive, |
11265.2.4
by James Westby
Remove another use of prepareBreezyAutotest(). |
457 |
[PackagePublishingStatus.PUBLISHED, |
458 |
PackagePublishingStatus.DELETED, |
|
459 |
PackagePublishingStatus.PUBLISHED], |
|
460 |
["1.0", "1.1", "2.0"], |
|
461 |
[sourcepackagename, sourcepackagename, other_spn]) |
|
462 |
pubs = removeSecurityProxy(archive)._collectLatestPublishedSources( |
|
463 |
archive, ["foo"]) |
|
10224.10.1
by Michael Nelson
Added failing test, factoring out the relevant code into a private helper method. |
464 |
self.assertEqual(1, len(pubs)) |
11265.2.4
by James Westby
Remove another use of prepareBreezyAutotest(). |
465 |
self.assertEqual('1.0', pubs[0].source_package_version) |
10137.3.7
by Paul Hummer
Added test stubs |
466 |
|
10156.2.16
by Jelmer Vernooij
PEP8 |
467 |
|
10156.2.3
by Jelmer Vernooij
Add some tests for checkUpload, canUpload. |
468 |
class TestArchiveCanUpload(TestCaseWithFactory): |
11168.3.1
by Jeroen Vermeulen
Test cruft and lint in Soyuz. |
469 |
"""Test the various methods that verify whether uploads are allowed to
|
10156.2.3
by Jelmer Vernooij
Add some tests for checkUpload, canUpload. |
470 |
happen."""
|
471 |
||
11265.2.5
by James Westby
Remove some small uses in the next test class. |
472 |
layer = DatabaseFunctionalLayer |
10156.2.3
by Jelmer Vernooij
Add some tests for checkUpload, canUpload. |
473 |
|
10156.2.10
by Jelmer Vernooij
Rename IArchive.canUpload -> IArchive.checkArchivePermission. |
474 |
def test_checkArchivePermission_by_PPA_owner(self): |
11168.3.1
by Jeroen Vermeulen
Test cruft and lint in Soyuz. |
475 |
# Uploading to a PPA should be allowed for a user that is the owner
|
10156.2.3
by Jelmer Vernooij
Add some tests for checkUpload, canUpload. |
476 |
owner = self.factory.makePerson(name="somebody") |
477 |
archive = self.factory.makeArchive(owner=owner) |
|
10156.2.10
by Jelmer Vernooij
Rename IArchive.canUpload -> IArchive.checkArchivePermission. |
478 |
self.assertEquals(True, archive.checkArchivePermission(owner)) |
10156.2.3
by Jelmer Vernooij
Add some tests for checkUpload, canUpload. |
479 |
someone_unrelated = self.factory.makePerson(name="somebody-unrelated") |
10156.2.10
by Jelmer Vernooij
Rename IArchive.canUpload -> IArchive.checkArchivePermission. |
480 |
self.assertEquals(False, |
481 |
archive.checkArchivePermission(someone_unrelated)) |
|
10156.2.3
by Jelmer Vernooij
Add some tests for checkUpload, canUpload. |
482 |
|
10156.2.13
by Jelmer Vernooij
Fix tests. |
483 |
def test_checkArchivePermission_distro_archive(self): |
10156.2.3
by Jelmer Vernooij
Add some tests for checkUpload, canUpload. |
484 |
# Regular users can not upload to ubuntu
|
11265.2.5
by James Westby
Remove some small uses in the next test class. |
485 |
archive = self.factory.makeArchive(purpose=ArchivePurpose.PRIMARY) |
13730.1.7
by Julian Edwards
re-merge backed-out revision |
486 |
# The factory sets the archive owner the same as the distro owner,
|
487 |
# change that here to ensure the security adapter checks are right.
|
|
488 |
removeSecurityProxy(archive).owner = self.factory.makePerson() |
|
10156.2.13
by Jelmer Vernooij
Fix tests. |
489 |
main = getUtility(IComponentSet)["main"] |
490 |
# A regular user doesn't have access
|
|
11265.2.5
by James Westby
Remove some small uses in the next test class. |
491 |
somebody = self.factory.makePerson() |
11168.3.1
by Jeroen Vermeulen
Test cruft and lint in Soyuz. |
492 |
self.assertEquals(False, |
10156.2.13
by Jelmer Vernooij
Fix tests. |
493 |
archive.checkArchivePermission(somebody, main)) |
494 |
# An ubuntu core developer does have access
|
|
11265.2.5
by James Westby
Remove some small uses in the next test class. |
495 |
coredev = self.factory.makePerson() |
13730.1.7
by Julian Edwards
re-merge backed-out revision |
496 |
with person_logged_in(archive.distribution.owner): |
11265.2.5
by James Westby
Remove some small uses in the next test class. |
497 |
archive.newComponentUploader(coredev, main.name) |
498 |
self.assertEquals(True, archive.checkArchivePermission(coredev, main)) |
|
10156.2.13
by Jelmer Vernooij
Fix tests. |
499 |
|
500 |
def test_checkArchivePermission_ppa(self): |
|
11265.2.5
by James Westby
Remove some small uses in the next test class. |
501 |
owner = self.factory.makePerson() |
11168.3.1
by Jeroen Vermeulen
Test cruft and lint in Soyuz. |
502 |
archive = self.factory.makeArchive(purpose=ArchivePurpose.PPA, |
10156.2.13
by Jelmer Vernooij
Fix tests. |
503 |
owner=owner) |
11265.2.5
by James Westby
Remove some small uses in the next test class. |
504 |
somebody = self.factory.makePerson() |
10156.2.13
by Jelmer Vernooij
Fix tests. |
505 |
# The owner has access
|
506 |
self.assertEquals(True, archive.checkArchivePermission(owner)) |
|
507 |
# Somebody unrelated does not
|
|
10156.2.10
by Jelmer Vernooij
Rename IArchive.canUpload -> IArchive.checkArchivePermission. |
508 |
self.assertEquals(False, archive.checkArchivePermission(somebody)) |
10156.2.3
by Jelmer Vernooij
Add some tests for checkUpload, canUpload. |
509 |
|
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
510 |
def makeArchiveAndActiveDistroSeries(self, purpose=None): |
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
511 |
if purpose is None: |
512 |
purpose = ArchivePurpose.PRIMARY |
|
513 |
archive = self.factory.makeArchive(purpose=purpose) |
|
514 |
distroseries = self.factory.makeDistroSeries( |
|
515 |
distribution=archive.distribution, |
|
516 |
status=SeriesStatus.DEVELOPMENT) |
|
517 |
return archive, distroseries |
|
518 |
||
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
519 |
def makePersonWithComponentPermission(self, archive): |
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
520 |
person = self.factory.makePerson() |
521 |
component = self.factory.makeComponent() |
|
522 |
removeSecurityProxy(archive).newComponentUploader( |
|
523 |
person, component) |
|
524 |
return person, component |
|
525 |
||
11265.2.13
by James Westby
Merge test_permission from archiveuploader in to test_archive. |
526 |
def checkUpload(self, archive, person, sourcepackagename, |
527 |
distroseries=None, component=None, |
|
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
528 |
pocket=None, strict_component=False): |
529 |
if distroseries is None: |
|
530 |
distroseries = self.factory.makeDistroSeries() |
|
531 |
if component is None: |
|
532 |
component = self.factory.makeComponent() |
|
533 |
if pocket is None: |
|
11265.2.13
by James Westby
Merge test_permission from archiveuploader in to test_archive. |
534 |
pocket = PackagePublishingPocket.RELEASE |
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
535 |
return archive.checkUpload( |
536 |
person, distroseries, sourcepackagename, component, pocket, |
|
537 |
strict_component=strict_component) |
|
538 |
||
11265.2.13
by James Westby
Merge test_permission from archiveuploader in to test_archive. |
539 |
def assertCanUpload(self, archive, person, sourcepackagename, |
540 |
distroseries=None, component=None, |
|
541 |
pocket=None, strict_component=False): |
|
542 |
"""Assert an upload to 'archive' will be accepted."""
|
|
543 |
self.assertIs( |
|
544 |
None, |
|
545 |
self.checkUpload( |
|
546 |
archive, person, sourcepackagename, |
|
547 |
distroseries=distroseries, component=component, |
|
548 |
pocket=pocket, strict_component=strict_component)) |
|
549 |
||
550 |
def assertCannotUpload(self, reason, archive, person, sourcepackagename, |
|
551 |
distroseries=None, component=None, pocket=None, |
|
552 |
strict_component=False): |
|
553 |
"""Assert that upload to 'archive' will be rejected.
|
|
554 |
||
555 |
:param reason: The expected reason for not being able to upload. A
|
|
556 |
class.
|
|
557 |
"""
|
|
558 |
self.assertIsInstance( |
|
559 |
self.checkUpload( |
|
560 |
archive, person, sourcepackagename, |
|
561 |
distroseries=distroseries, component=component, |
|
562 |
pocket=pocket, strict_component=strict_component), |
|
11347.7.1
by Steve Kowalik
Shift the tests concerned with privacy from test_archive to test_archive_privacy |
563 |
reason) |
11265.2.13
by James Westby
Merge test_permission from archiveuploader in to test_archive. |
564 |
|
10156.2.3
by Jelmer Vernooij
Add some tests for checkUpload, canUpload. |
565 |
def test_checkUpload_partner_invalid_pocket(self): |
566 |
# Partner archives only have release and proposed pockets
|
|
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
567 |
archive, distroseries = self.makeArchiveAndActiveDistroSeries( |
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
568 |
purpose=ArchivePurpose.PARTNER) |
11265.2.13
by James Westby
Merge test_permission from archiveuploader in to test_archive. |
569 |
self.assertCannotUpload( |
570 |
InvalidPocketForPartnerArchive, archive, |
|
571 |
self.factory.makePerson(), self.factory.makeSourcePackageName(), |
|
572 |
pocket=PackagePublishingPocket.UPDATES, |
|
573 |
distroseries=distroseries) |
|
11168.3.1
by Jeroen Vermeulen
Test cruft and lint in Soyuz. |
574 |
|
10156.2.3
by Jelmer Vernooij
Add some tests for checkUpload, canUpload. |
575 |
def test_checkUpload_ppa_invalid_pocket(self): |
576 |
# PPA archives only have release pockets
|
|
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
577 |
archive, distroseries = self.makeArchiveAndActiveDistroSeries( |
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
578 |
purpose=ArchivePurpose.PPA) |
11265.2.13
by James Westby
Merge test_permission from archiveuploader in to test_archive. |
579 |
self.assertCannotUpload( |
580 |
InvalidPocketForPPA, archive, |
|
581 |
self.factory.makePerson(), self.factory.makeSourcePackageName(), |
|
582 |
pocket=PackagePublishingPocket.PROPOSED, |
|
583 |
distroseries=distroseries) |
|
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
584 |
|
585 |
def test_checkUpload_invalid_pocket_for_series_state(self): |
|
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
586 |
archive, distroseries = self.makeArchiveAndActiveDistroSeries( |
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
587 |
purpose=ArchivePurpose.PRIMARY) |
11265.2.13
by James Westby
Merge test_permission from archiveuploader in to test_archive. |
588 |
self.assertCannotUpload( |
589 |
CannotUploadToPocket, archive, |
|
590 |
self.factory.makePerson(), self.factory.makeSourcePackageName(), |
|
591 |
pocket=PackagePublishingPocket.PROPOSED, |
|
592 |
distroseries=distroseries) |
|
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
593 |
|
594 |
def test_checkUpload_disabled_archive(self): |
|
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
595 |
archive, distroseries = self.makeArchiveAndActiveDistroSeries( |
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
596 |
purpose=ArchivePurpose.PRIMARY) |
597 |
removeSecurityProxy(archive).disable() |
|
11265.2.13
by James Westby
Merge test_permission from archiveuploader in to test_archive. |
598 |
self.assertCannotUpload( |
599 |
ArchiveDisabled, archive, self.factory.makePerson(), |
|
600 |
self.factory.makeSourcePackageName(), |
|
601 |
distroseries=distroseries) |
|
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
602 |
|
603 |
def test_checkUpload_ppa_owner(self): |
|
604 |
person = self.factory.makePerson() |
|
605 |
archive = self.factory.makeArchive( |
|
606 |
purpose=ArchivePurpose.PPA, owner=person) |
|
11265.2.13
by James Westby
Merge test_permission from archiveuploader in to test_archive. |
607 |
self.assertCanUpload( |
608 |
archive, person, self.factory.makeSourcePackageName()) |
|
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
609 |
|
610 |
def test_checkUpload_ppa_with_permission(self): |
|
611 |
archive = self.factory.makeArchive(purpose=ArchivePurpose.PPA) |
|
612 |
person = self.factory.makePerson() |
|
613 |
removeSecurityProxy(archive).newComponentUploader(person, "main") |
|
614 |
# component is ignored
|
|
11265.2.13
by James Westby
Merge test_permission from archiveuploader in to test_archive. |
615 |
self.assertCanUpload( |
616 |
archive, person, self.factory.makeSourcePackageName(), |
|
617 |
component=self.factory.makeComponent(name="universe")) |
|
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
618 |
|
619 |
def test_checkUpload_ppa_with_no_permission(self): |
|
620 |
archive = self.factory.makeArchive(purpose=ArchivePurpose.PPA) |
|
621 |
person = self.factory.makePerson() |
|
11265.2.13
by James Westby
Merge test_permission from archiveuploader in to test_archive. |
622 |
self.assertCannotUpload( |
623 |
CannotUploadToPPA, archive, person, |
|
624 |
self.factory.makeSourcePackageName()) |
|
625 |
||
626 |
def test_owner_can_upload_to_ppa_no_sourcepackage(self): |
|
627 |
# The owner can upload to PPAs even if the source package doesn't
|
|
628 |
# exist yet.
|
|
629 |
team = self.factory.makeTeam() |
|
630 |
archive = self.factory.makeArchive( |
|
631 |
purpose=ArchivePurpose.PPA, owner=team) |
|
632 |
person = self.factory.makePerson() |
|
633 |
removeSecurityProxy(team).addMember(person, team.teamowner) |
|
634 |
self.assertCanUpload(archive, person, None) |
|
635 |
||
636 |
def test_can_upload_to_ppa_for_old_series(self): |
|
637 |
# You can upload whatever you want to a PPA, regardless of the upload
|
|
638 |
# policy.
|
|
639 |
person = self.factory.makePerson() |
|
640 |
archive = self.factory.makeArchive( |
|
641 |
purpose=ArchivePurpose.PPA, owner=person) |
|
642 |
spn = self.factory.makeSourcePackageName() |
|
643 |
distroseries = self.factory.makeDistroSeries( |
|
644 |
status=SeriesStatus.CURRENT) |
|
645 |
self.assertCanUpload( |
|
646 |
archive, person, spn, distroseries=distroseries) |
|
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
647 |
|
648 |
def test_checkUpload_copy_archive_no_permission(self): |
|
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
649 |
archive, distroseries = self.makeArchiveAndActiveDistroSeries( |
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
650 |
purpose=ArchivePurpose.COPY) |
651 |
sourcepackagename = self.factory.makeSourcePackageName() |
|
652 |
person = self.factory.makePerson() |
|
653 |
removeSecurityProxy(archive).newPackageUploader( |
|
654 |
person, sourcepackagename) |
|
11265.2.13
by James Westby
Merge test_permission from archiveuploader in to test_archive. |
655 |
self.assertCannotUpload( |
656 |
NoRightsForArchive, archive, person, sourcepackagename, |
|
657 |
distroseries=distroseries) |
|
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
658 |
|
11551.6.1
by Julian Edwards
failing test |
659 |
def test_checkUploadToPocket_for_released_distroseries_copy_archive(self): |
660 |
# Uploading to the release pocket in a released COPY archive
|
|
661 |
# should be allowed. This is mainly so that rebuilds that are
|
|
662 |
# running during the release process don't suddenly cause
|
|
663 |
# exceptions in the buildd-manager.
|
|
664 |
archive = self.factory.makeArchive(purpose=ArchivePurpose.COPY) |
|
665 |
distroseries = self.factory.makeDistroSeries( |
|
666 |
distribution=archive.distribution, |
|
667 |
status=SeriesStatus.CURRENT) |
|
668 |
self.assertIs( |
|
669 |
None, |
|
670 |
archive.checkUploadToPocket( |
|
671 |
distroseries, PackagePublishingPocket.RELEASE)) |
|
672 |
||
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
673 |
def test_checkUpload_package_permission(self): |
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
674 |
archive, distroseries = self.makeArchiveAndActiveDistroSeries( |
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
675 |
purpose=ArchivePurpose.PRIMARY) |
676 |
sourcepackagename = self.factory.makeSourcePackageName() |
|
677 |
person = self.factory.makePerson() |
|
678 |
removeSecurityProxy(archive).newPackageUploader( |
|
679 |
person, sourcepackagename) |
|
11265.2.13
by James Westby
Merge test_permission from archiveuploader in to test_archive. |
680 |
self.assertCanUpload( |
681 |
archive, person, sourcepackagename, distroseries=distroseries) |
|
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
682 |
|
683 |
def make_person_with_packageset_permission(self, archive, distroseries, |
|
684 |
packages=()): |
|
685 |
packageset = self.factory.makePackageset( |
|
686 |
distroseries=distroseries, packages=packages) |
|
687 |
person = self.factory.makePerson() |
|
13730.1.11
by Julian Edwards
Fix errant tests. |
688 |
with person_logged_in(archive.distribution.owner): |
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
689 |
archive.newPackagesetUploader(person, packageset) |
690 |
return person, packageset |
|
691 |
||
692 |
def test_checkUpload_packageset_permission(self): |
|
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
693 |
archive, distroseries = self.makeArchiveAndActiveDistroSeries( |
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
694 |
purpose=ArchivePurpose.PRIMARY) |
695 |
sourcepackagename = self.factory.makeSourcePackageName() |
|
696 |
person, packageset = self.make_person_with_packageset_permission( |
|
697 |
archive, distroseries, packages=[sourcepackagename]) |
|
11265.2.13
by James Westby
Merge test_permission from archiveuploader in to test_archive. |
698 |
self.assertCanUpload( |
699 |
archive, person, sourcepackagename, distroseries=distroseries) |
|
700 |
||
701 |
def test_checkUpload_packageset_wrong_distroseries(self): |
|
702 |
# A person with rights to upload to the package set in distro
|
|
703 |
# series K may not upload with these same rights to a different
|
|
704 |
# distro series L.
|
|
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
705 |
archive, distroseries = self.makeArchiveAndActiveDistroSeries( |
11265.2.13
by James Westby
Merge test_permission from archiveuploader in to test_archive. |
706 |
purpose=ArchivePurpose.PRIMARY) |
707 |
sourcepackagename = self.factory.makeSourcePackageName() |
|
708 |
person, packageset = self.make_person_with_packageset_permission( |
|
709 |
archive, distroseries, packages=[sourcepackagename]) |
|
710 |
other_distroseries = self.factory.makeDistroSeries() |
|
711 |
self.assertCannotUpload( |
|
712 |
InsufficientUploadRights, archive, person, sourcepackagename, |
|
713 |
distroseries=other_distroseries) |
|
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
714 |
|
715 |
def test_checkUpload_component_permission(self): |
|
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
716 |
archive, distroseries = self.makeArchiveAndActiveDistroSeries( |
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
717 |
purpose=ArchivePurpose.PRIMARY) |
718 |
sourcepackagename = self.factory.makeSourcePackageName() |
|
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
719 |
person, component = self.makePersonWithComponentPermission( |
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
720 |
archive) |
11265.2.13
by James Westby
Merge test_permission from archiveuploader in to test_archive. |
721 |
self.assertCanUpload( |
722 |
archive, person, sourcepackagename, distroseries=distroseries, |
|
723 |
component=component) |
|
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
724 |
|
725 |
def test_checkUpload_no_permissions(self): |
|
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
726 |
archive, distroseries = self.makeArchiveAndActiveDistroSeries( |
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
727 |
purpose=ArchivePurpose.PRIMARY) |
728 |
sourcepackagename = self.factory.makeSourcePackageName() |
|
729 |
person = self.factory.makePerson() |
|
11265.2.13
by James Westby
Merge test_permission from archiveuploader in to test_archive. |
730 |
self.assertCannotUpload( |
731 |
NoRightsForArchive, archive, person, sourcepackagename, |
|
732 |
distroseries=distroseries) |
|
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
733 |
|
734 |
def test_checkUpload_insufficient_permissions(self): |
|
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
735 |
archive, distroseries = self.makeArchiveAndActiveDistroSeries( |
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
736 |
purpose=ArchivePurpose.PRIMARY) |
737 |
sourcepackagename = self.factory.makeSourcePackageName() |
|
738 |
person, packageset = self.make_person_with_packageset_permission( |
|
739 |
archive, distroseries) |
|
11265.2.13
by James Westby
Merge test_permission from archiveuploader in to test_archive. |
740 |
self.assertCannotUpload( |
741 |
InsufficientUploadRights, archive, person, sourcepackagename, |
|
742 |
distroseries=distroseries) |
|
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
743 |
|
744 |
def test_checkUpload_without_strict_component(self): |
|
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
745 |
archive, distroseries = self.makeArchiveAndActiveDistroSeries( |
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
746 |
purpose=ArchivePurpose.PRIMARY) |
747 |
sourcepackagename = self.factory.makeSourcePackageName() |
|
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
748 |
person, component = self.makePersonWithComponentPermission( |
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
749 |
archive) |
750 |
other_component = self.factory.makeComponent() |
|
11265.2.13
by James Westby
Merge test_permission from archiveuploader in to test_archive. |
751 |
self.assertCanUpload( |
752 |
archive, person, sourcepackagename, distroseries=distroseries, |
|
753 |
component=other_component, strict_component=False) |
|
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
754 |
|
755 |
def test_checkUpload_with_strict_component(self): |
|
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
756 |
archive, distroseries = self.makeArchiveAndActiveDistroSeries( |
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
757 |
purpose=ArchivePurpose.PRIMARY) |
758 |
sourcepackagename = self.factory.makeSourcePackageName() |
|
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
759 |
person, component = self.makePersonWithComponentPermission( |
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
760 |
archive) |
761 |
other_component = self.factory.makeComponent() |
|
11265.2.13
by James Westby
Merge test_permission from archiveuploader in to test_archive. |
762 |
self.assertCannotUpload( |
763 |
NoRightsForComponent, archive, person, sourcepackagename, |
|
764 |
distroseries=distroseries, component=other_component, |
|
765 |
strict_component=True) |
|
766 |
||
767 |
def test_checkUpload_component_rights_no_package(self): |
|
768 |
# A person allowed to upload to a particular component of an archive
|
|
769 |
# can upload basically whatever they want to that component, even if
|
|
770 |
# the package doesn't exist yet.
|
|
771 |
archive = self.factory.makeArchive(purpose=ArchivePurpose.PRIMARY) |
|
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
772 |
person, component = self.makePersonWithComponentPermission( |
11265.2.13
by James Westby
Merge test_permission from archiveuploader in to test_archive. |
773 |
archive) |
774 |
self.assertCanUpload(archive, person, None, component=component) |
|
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
775 |
|
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
776 |
def makePackageToUpload(self, distroseries): |
11265.2.8
by James Westby
Better tests for checkUpload, including a small bug fix. |
777 |
sourcepackagename = self.factory.makeSourcePackageName() |
778 |
suitesourcepackage = self.factory.makeSuiteSourcePackage( |
|
779 |
pocket=PackagePublishingPocket.RELEASE, |
|
780 |
sourcepackagename=sourcepackagename, |
|
781 |
distroseries=distroseries) |
|
782 |
return suitesourcepackage |
|
11265.2.6
by James Westby
Add some tests for canUploadSuiteSourcePackage. |
783 |
|
784 |
def test_canUploadSuiteSourcePackage_invalid_pocket(self): |
|
785 |
# Test that canUploadSuiteSourcePackage calls checkUpload for
|
|
786 |
# the pocket checks.
|
|
787 |
person = self.factory.makePerson() |
|
788 |
archive = self.factory.makeArchive( |
|
789 |
purpose=ArchivePurpose.PPA, owner=person) |
|
790 |
suitesourcepackage = self.factory.makeSuiteSourcePackage( |
|
791 |
pocket=PackagePublishingPocket.PROPOSED) |
|
792 |
self.assertEqual( |
|
793 |
False, |
|
794 |
archive.canUploadSuiteSourcePackage(person, suitesourcepackage)) |
|
795 |
||
796 |
def test_canUploadSuiteSourcePackage_no_permission(self): |
|
797 |
# Test that canUploadSuiteSourcePackage calls verifyUpload for
|
|
798 |
# the permission checks.
|
|
799 |
archive = self.factory.makeArchive(purpose=ArchivePurpose.PPA) |
|
800 |
suitesourcepackage = self.factory.makeSuiteSourcePackage( |
|
801 |
pocket=PackagePublishingPocket.RELEASE) |
|
802 |
person = self.factory.makePerson() |
|
803 |
self.assertEqual( |
|
804 |
False, |
|
805 |
archive.canUploadSuiteSourcePackage(person, suitesourcepackage)) |
|
806 |
||
807 |
def test_canUploadSuiteSourcePackage_package_permission(self): |
|
808 |
# Test that a package permission is enough to upload a new
|
|
809 |
# package.
|
|
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
810 |
archive, distroseries = self.makeArchiveAndActiveDistroSeries() |
811 |
suitesourcepackage = self.makePackageToUpload(distroseries) |
|
11265.2.6
by James Westby
Add some tests for canUploadSuiteSourcePackage. |
812 |
person = self.factory.makePerson() |
813 |
removeSecurityProxy(archive).newPackageUploader( |
|
814 |
person, suitesourcepackage.sourcepackagename) |
|
815 |
self.assertEqual( |
|
816 |
True, |
|
817 |
archive.canUploadSuiteSourcePackage(person, suitesourcepackage)) |
|
818 |
||
819 |
def test_canUploadSuiteSourcePackage_component_permission(self): |
|
820 |
# Test that component upload permission is enough to be
|
|
821 |
# allowed to upload a new package.
|
|
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
822 |
archive, distroseries = self.makeArchiveAndActiveDistroSeries() |
823 |
suitesourcepackage = self.makePackageToUpload(distroseries) |
|
11265.2.6
by James Westby
Add some tests for canUploadSuiteSourcePackage. |
824 |
person = self.factory.makePerson() |
825 |
removeSecurityProxy(archive).newComponentUploader(person, "universe") |
|
826 |
self.assertEqual( |
|
827 |
True, |
|
828 |
archive.canUploadSuiteSourcePackage(person, suitesourcepackage)) |
|
829 |
||
830 |
def test_canUploadSuiteSourcePackage_strict_component(self): |
|
831 |
# Test that canUploadSuiteSourcePackage uses strict component
|
|
832 |
# checking.
|
|
11265.2.16
by James Westby
Tweaks from jml's review. Thanks. |
833 |
archive, distroseries = self.makeArchiveAndActiveDistroSeries() |
834 |
suitesourcepackage = self.makePackageToUpload(distroseries) |
|
11265.2.6
by James Westby
Add some tests for canUploadSuiteSourcePackage. |
835 |
main_component = self.factory.makeComponent(name="main") |
836 |
self.factory.makeSourcePackagePublishingHistory( |
|
837 |
archive=archive, distroseries=distroseries, |
|
838 |
sourcepackagename=suitesourcepackage.sourcepackagename, |
|
839 |
status=PackagePublishingStatus.PUBLISHED, |
|
840 |
pocket=PackagePublishingPocket.RELEASE, |
|
841 |
component=main_component) |
|
842 |
person = self.factory.makePerson() |
|
843 |
removeSecurityProxy(archive).newComponentUploader(person, "universe") |
|
844 |
# This time the user can't upload as there has been a
|
|
845 |
# publication and they don't have permission for the component
|
|
846 |
# the package is published in.
|
|
847 |
self.assertEqual( |
|
848 |
False, |
|
849 |
archive.canUploadSuiteSourcePackage(person, suitesourcepackage)) |
|
10156.2.25
by Jelmer Vernooij
Fix tests. |
850 |
|
12981.1.2
by Raphael Badin
Roll back 12977. |
851 |
def test_hasAnyPermission(self): |
852 |
# hasAnyPermission returns true if the person is the member of a
|
|
853 |
# team with any kind of permission on the archive.
|
|
854 |
archive = self.factory.makeArchive() |
|
855 |
person = self.factory.makePerson() |
|
856 |
team = self.factory.makeTeam() |
|
857 |
main = getUtility(IComponentSet)["main"] |
|
858 |
ArchivePermission( |
|
859 |
archive=archive, person=team, component=main, |
|
860 |
permission=ArchivePermissionType.UPLOAD) |
|
861 |
||
862 |
self.assertFalse(archive.hasAnyPermission(person)) |
|
863 |
with celebrity_logged_in('admin'): |
|
864 |
team.addMember(person, team.teamowner) |
|
865 |
self.assertTrue(archive.hasAnyPermission(person)) |
|
866 |
||
7675.557.20
by Jelmer Vernooij
Add a check box to archive admin pages to allow/disallow builds on ARM. |
867 |
|
7675.583.4
by William Grant
Add and test Archive.updatePackageDownloadCount. |
868 |
class TestUpdatePackageDownloadCount(TestCaseWithFactory): |
869 |
"""Ensure that updatePackageDownloadCount works as expected."""
|
|
870 |
||
871 |
layer = LaunchpadZopelessLayer |
|
872 |
||
873 |
def setUp(self): |
|
874 |
super(TestUpdatePackageDownloadCount, self).setUp() |
|
875 |
self.publisher = SoyuzTestPublisher() |
|
876 |
self.publisher.prepareBreezyAutotest() |
|
877 |
||
878 |
self.store = getUtility(IStoreSelector).get( |
|
879 |
MAIN_STORE, DEFAULT_FLAVOR) |
|
880 |
||
881 |
self.archive = self.factory.makeArchive() |
|
882 |
self.bpr_1 = self.publisher.getPubBinaries( |
|
883 |
archive=self.archive)[0].binarypackagerelease |
|
884 |
self.bpr_2 = self.publisher.getPubBinaries( |
|
885 |
archive=self.archive)[0].binarypackagerelease |
|
886 |
||
887 |
country_set = getUtility(ICountrySet) |
|
888 |
self.australia = country_set['AU'] |
|
889 |
self.new_zealand = country_set['NZ'] |
|
890 |
||
891 |
def assertCount(self, count, archive, bpr, day, country): |
|
892 |
self.assertEqual(count, self.store.find( |
|
893 |
BinaryPackageReleaseDownloadCount, |
|
894 |
archive=archive, binary_package_release=bpr, |
|
895 |
day=day, country=country).one().count) |
|
896 |
||
897 |
def test_creates_new_entry(self): |
|
898 |
# The first update for a particular archive, package, day and
|
|
899 |
# country will create a new BinaryPackageReleaseDownloadCount
|
|
900 |
# entry.
|
|
901 |
day = date(2010, 2, 20) |
|
902 |
self.assertIs(None, self.store.find( |
|
903 |
BinaryPackageReleaseDownloadCount, |
|
904 |
archive=self.archive, binary_package_release=self.bpr_1, |
|
905 |
day=day, country=self.australia).one()) |
|
906 |
self.archive.updatePackageDownloadCount( |
|
907 |
self.bpr_1, day, self.australia, 10) |
|
908 |
self.assertCount(10, self.archive, self.bpr_1, day, self.australia) |
|
909 |
||
910 |
def test_reuses_existing_entry(self): |
|
911 |
# A second update will simply add to the count on the existing
|
|
912 |
# BPRDC.
|
|
913 |
day = date(2010, 2, 20) |
|
914 |
self.archive.updatePackageDownloadCount( |
|
915 |
self.bpr_1, day, self.australia, 10) |
|
916 |
self.archive.updatePackageDownloadCount( |
|
917 |
self.bpr_1, day, self.australia, 3) |
|
918 |
self.assertCount(13, self.archive, self.bpr_1, day, self.australia) |
|
919 |
||
920 |
def test_differentiates_between_countries(self): |
|
921 |
# A different country will cause a new entry to be created.
|
|
922 |
day = date(2010, 2, 20) |
|
923 |
self.archive.updatePackageDownloadCount( |
|
924 |
self.bpr_1, day, self.australia, 10) |
|
925 |
self.archive.updatePackageDownloadCount( |
|
926 |
self.bpr_1, day, self.new_zealand, 3) |
|
927 |
||
928 |
self.assertCount(10, self.archive, self.bpr_1, day, self.australia) |
|
929 |
self.assertCount(3, self.archive, self.bpr_1, day, self.new_zealand) |
|
930 |
||
7675.583.11
by William Grant
Test that updatePackageDownloadCount works with None as the country. |
931 |
def test_country_can_be_none(self): |
932 |
# The country can be None, indicating that it is unknown.
|
|
933 |
day = date(2010, 2, 20) |
|
934 |
self.archive.updatePackageDownloadCount( |
|
935 |
self.bpr_1, day, self.australia, 10) |
|
936 |
self.archive.updatePackageDownloadCount( |
|
937 |
self.bpr_1, day, None, 3) |
|
938 |
||
939 |
self.assertCount(10, self.archive, self.bpr_1, day, self.australia) |
|
940 |
self.assertCount(3, self.archive, self.bpr_1, day, None) |
|
941 |
||
7675.583.4
by William Grant
Add and test Archive.updatePackageDownloadCount. |
942 |
def test_differentiates_between_days(self): |
943 |
# A different date will also cause a new entry to be created.
|
|
944 |
day = date(2010, 2, 20) |
|
945 |
another_day = date(2010, 2, 21) |
|
946 |
self.archive.updatePackageDownloadCount( |
|
947 |
self.bpr_1, day, self.australia, 10) |
|
948 |
self.archive.updatePackageDownloadCount( |
|
949 |
self.bpr_1, another_day, self.australia, 3) |
|
950 |
||
951 |
self.assertCount(10, self.archive, self.bpr_1, day, self.australia) |
|
952 |
self.assertCount( |
|
953 |
3, self.archive, self.bpr_1, another_day, self.australia) |
|
954 |
||
955 |
def test_differentiates_between_bprs(self): |
|
956 |
# And even a different package will create a new entry.
|
|
957 |
day = date(2010, 2, 20) |
|
958 |
self.archive.updatePackageDownloadCount( |
|
959 |
self.bpr_1, day, self.australia, 10) |
|
960 |
self.archive.updatePackageDownloadCount( |
|
961 |
self.bpr_2, day, self.australia, 3) |
|
962 |
||
963 |
self.assertCount(10, self.archive, self.bpr_1, day, self.australia) |
|
964 |
self.assertCount(3, self.archive, self.bpr_2, day, self.australia) |
|
965 |
||
966 |
||
11065.4.2
by Jelmer Vernooij
Change IArchive.arm_builds_allowed to IArchive.enabled_restricted_families. |
967 |
class TestEnabledRestrictedBuilds(TestCaseWithFactory): |
7675.734.3
by Jelmer Vernooij
Fix dangling whitespace. |
968 |
"""Ensure that restricted architecture family builds can be allowed and
|
11065.4.2
by Jelmer Vernooij
Change IArchive.arm_builds_allowed to IArchive.enabled_restricted_families. |
969 |
disallowed correctly."""
|
7675.557.20
by Jelmer Vernooij
Add a check box to archive admin pages to allow/disallow builds on ARM. |
970 |
|
971 |
layer = LaunchpadZopelessLayer |
|
972 |
||
973 |
def setUp(self): |
|
974 |
"""Setup an archive with relevant publications."""
|
|
11065.4.2
by Jelmer Vernooij
Change IArchive.arm_builds_allowed to IArchive.enabled_restricted_families. |
975 |
super(TestEnabledRestrictedBuilds, self).setUp() |
7675.557.20
by Jelmer Vernooij
Add a check box to archive admin pages to allow/disallow builds on ARM. |
976 |
self.publisher = SoyuzTestPublisher() |
977 |
self.publisher.prepareBreezyAutotest() |
|
978 |
self.archive = self.factory.makeArchive() |
|
979 |
self.archive_arch_set = getUtility(IArchiveArchSet) |
|
980 |
self.arm = getUtility(IProcessorFamilySet).getByName('arm') |
|
981 |
||
11078.1.1
by Jelmer Vernooij
Always allow building main archives on restricted architectures. |
982 |
def test_main_archive_can_use_restricted(self): |
11168.3.1
by Jeroen Vermeulen
Test cruft and lint in Soyuz. |
983 |
# Main archives for distributions can always use restricted
|
11078.1.2
by Jelmer Vernooij
Review feedback. |
984 |
# architectures.
|
11078.1.1
by Jelmer Vernooij
Always allow building main archives on restricted architectures. |
985 |
distro = self.factory.makeDistribution() |
11078.1.2
by Jelmer Vernooij
Review feedback. |
986 |
self.assertContentEqual([self.arm], |
987 |
distro.main_archive.enabled_restricted_families) |
|
11078.1.1
by Jelmer Vernooij
Always allow building main archives on restricted architectures. |
988 |
|
989 |
def test_main_archive_can_not_be_restricted(self): |
|
11078.1.2
by Jelmer Vernooij
Review feedback. |
990 |
# A main archive can not be restricted to certain architectures.
|
11078.1.1
by Jelmer Vernooij
Always allow building main archives on restricted architectures. |
991 |
distro = self.factory.makeDistribution() |
992 |
# Restricting to all restricted architectures is fine
|
|
993 |
distro.main_archive.enabled_restricted_families = [self.arm] |
|
11168.3.1
by Jeroen Vermeulen
Test cruft and lint in Soyuz. |
994 |
|
11078.1.1
by Jelmer Vernooij
Always allow building main archives on restricted architectures. |
995 |
def restrict(): |
996 |
distro.main_archive.enabled_restricted_families = [] |
|
11168.3.1
by Jeroen Vermeulen
Test cruft and lint in Soyuz. |
997 |
|
11078.1.1
by Jelmer Vernooij
Always allow building main archives on restricted architectures. |
998 |
self.assertRaises(CannotRestrictArchitectures, restrict) |
999 |
||
7675.557.20
by Jelmer Vernooij
Add a check box to archive admin pages to allow/disallow builds on ARM. |
1000 |
def test_default(self): |
11065.4.2
by Jelmer Vernooij
Change IArchive.arm_builds_allowed to IArchive.enabled_restricted_families. |
1001 |
"""By default, ARM builds are not allowed as ARM is restricted."""
|
7675.561.2
by Michael Nelson
Resolved conflicts |
1002 |
self.assertEquals(0, |
7675.658.3
by Michael Nelson
Removed lint. |
1003 |
self.archive_arch_set.getByArchive( |
1004 |
self.archive, self.arm).count()) |
|
11078.1.2
by Jelmer Vernooij
Review feedback. |
1005 |
self.assertContentEqual([], self.archive.enabled_restricted_families) |
7675.557.20
by Jelmer Vernooij
Add a check box to archive admin pages to allow/disallow builds on ARM. |
1006 |
|
1007 |
def test_get_uses_archivearch(self): |
|
7675.561.2
by Michael Nelson
Resolved conflicts |
1008 |
"""Adding an entry to ArchiveArch for ARM and an archive will
|
11065.4.2
by Jelmer Vernooij
Change IArchive.arm_builds_allowed to IArchive.enabled_restricted_families. |
1009 |
enable enabled_restricted_families for arm for that archive."""
|
11078.1.2
by Jelmer Vernooij
Review feedback. |
1010 |
self.assertContentEqual([], self.archive.enabled_restricted_families) |
7675.557.20
by Jelmer Vernooij
Add a check box to archive admin pages to allow/disallow builds on ARM. |
1011 |
self.archive_arch_set.new(self.archive, self.arm) |
7675.734.3
by Jelmer Vernooij
Fix dangling whitespace. |
1012 |
self.assertEquals([self.arm], |
11065.4.2
by Jelmer Vernooij
Change IArchive.arm_builds_allowed to IArchive.enabled_restricted_families. |
1013 |
list(self.archive.enabled_restricted_families)) |
7675.557.20
by Jelmer Vernooij
Add a check box to archive admin pages to allow/disallow builds on ARM. |
1014 |
|
11065.4.2
by Jelmer Vernooij
Change IArchive.arm_builds_allowed to IArchive.enabled_restricted_families. |
1015 |
def test_get_returns_restricted_only(self): |
7675.734.3
by Jelmer Vernooij
Fix dangling whitespace. |
1016 |
"""Adding an entry to ArchiveArch for something that is not
|
11065.4.2
by Jelmer Vernooij
Change IArchive.arm_builds_allowed to IArchive.enabled_restricted_families. |
1017 |
restricted does not make it show up in enabled_restricted_families.
|
1018 |
"""
|
|
11078.1.2
by Jelmer Vernooij
Review feedback. |
1019 |
self.assertContentEqual([], self.archive.enabled_restricted_families) |
7675.561.2
by Michael Nelson
Resolved conflicts |
1020 |
self.archive_arch_set.new(self.archive, |
7675.557.20
by Jelmer Vernooij
Add a check box to archive admin pages to allow/disallow builds on ARM. |
1021 |
getUtility(IProcessorFamilySet).getByName('amd64')) |
11078.1.2
by Jelmer Vernooij
Review feedback. |
1022 |
self.assertContentEqual([], self.archive.enabled_restricted_families) |
7675.557.20
by Jelmer Vernooij
Add a check box to archive admin pages to allow/disallow builds on ARM. |
1023 |
|
1024 |
def test_set(self): |
|
1025 |
"""The property remembers its value correctly and sets ArchiveArch."""
|
|
11065.4.2
by Jelmer Vernooij
Change IArchive.arm_builds_allowed to IArchive.enabled_restricted_families. |
1026 |
self.archive.enabled_restricted_families = [self.arm] |
7675.557.20
by Jelmer Vernooij
Add a check box to archive admin pages to allow/disallow builds on ARM. |
1027 |
allowed_restricted_families = self.archive_arch_set.getByArchive( |
1028 |
self.archive, self.arm) |
|
1029 |
self.assertEquals(1, allowed_restricted_families.count()) |
|
1030 |
self.assertEquals(self.arm, |
|
1031 |
allowed_restricted_families[0].processorfamily) |
|
11168.3.1
by Jeroen Vermeulen
Test cruft and lint in Soyuz. |
1032 |
self.assertEquals( |
1033 |
[self.arm], self.archive.enabled_restricted_families) |
|
11065.4.2
by Jelmer Vernooij
Change IArchive.arm_builds_allowed to IArchive.enabled_restricted_families. |
1034 |
self.archive.enabled_restricted_families = [] |
7675.561.2
by Michael Nelson
Resolved conflicts |
1035 |
self.assertEquals(0, |
7675.658.3
by Michael Nelson
Removed lint. |
1036 |
self.archive_arch_set.getByArchive( |
1037 |
self.archive, self.arm).count()) |
|
11078.1.2
by Jelmer Vernooij
Review feedback. |
1038 |
self.assertContentEqual([], self.archive.enabled_restricted_families) |
11065.4.2
by Jelmer Vernooij
Change IArchive.arm_builds_allowed to IArchive.enabled_restricted_families. |
1039 |
|
7675.557.20
by Jelmer Vernooij
Add a check box to archive admin pages to allow/disallow builds on ARM. |
1040 |
|
11015.3.2
by Steve Kowalik
* Stop exporting newAuthToken, we're doing it differently now. |
1041 |
class TestArchiveTokens(TestCaseWithFactory): |
1042 |
layer = LaunchpadZopelessLayer |
|
1043 |
||
1044 |
def setUp(self): |
|
1045 |
super(TestArchiveTokens, self).setUp() |
|
1046 |
owner = self.factory.makePerson() |
|
1047 |
self.private_ppa = self.factory.makeArchive(owner=owner) |
|
1048 |
self.private_ppa.buildd_secret = 'blah' |
|
1049 |
self.private_ppa.private = True |
|
1050 |
self.joe = self.factory.makePerson(name='joe') |
|
1051 |
self.private_ppa.newSubscription(self.joe, owner) |
|
1052 |
||
1053 |
def test_getAuthToken_with_no_token(self): |
|
1054 |
token = self.private_ppa.getAuthToken(self.joe) |
|
1055 |
self.assertEqual(token, None) |
|
1056 |
||
1057 |
def test_getAuthToken_with_token(self): |
|
1058 |
token = self.private_ppa.newAuthToken(self.joe) |
|
1059 |
self.assertEqual(self.private_ppa.getAuthToken(self.joe), token) |
|
1060 |
||
7675.744.1
by Steve Kowalik
* Rename .getPrivateSourcesList() to .getArchiveSubscriptionURL(), and shift |
1061 |
def test_getArchiveSubscriptionURL(self): |
1062 |
url = self.joe.getArchiveSubscriptionURL(self.joe, self.private_ppa) |
|
11015.3.2
by Steve Kowalik
* Stop exporting newAuthToken, we're doing it differently now. |
1063 |
token = self.private_ppa.getAuthToken(self.joe) |
1064 |
self.assertEqual(token.archive_url, url) |
|
7675.561.2
by Michael Nelson
Resolved conflicts |
1065 |
|
11168.3.1
by Jeroen Vermeulen
Test cruft and lint in Soyuz. |
1066 |
|
7675.590.12
by William Grant
Add Archive.getBinaryPackageRelease, allowing BPR retrieval by name, version, and build DAS arch tag. |
1067 |
class TestGetBinaryPackageRelease(TestCaseWithFactory): |
1068 |
"""Ensure that getBinaryPackageRelease works as expected."""
|
|
1069 |
||
1070 |
layer = LaunchpadZopelessLayer |
|
1071 |
||
1072 |
def setUp(self): |
|
1073 |
"""Setup an archive with relevant publications."""
|
|
1074 |
super(TestGetBinaryPackageRelease, self).setUp() |
|
1075 |
self.publisher = SoyuzTestPublisher() |
|
1076 |
self.publisher.prepareBreezyAutotest() |
|
1077 |
||
1078 |
self.archive = self.factory.makeArchive() |
|
1079 |
self.archive.require_virtualized = False |
|
1080 |
||
1081 |
self.i386_pub, self.hppa_pub = self.publisher.getPubBinaries( |
|
1082 |
version="1.2.3-4", archive=self.archive, binaryname="foo-bin", |
|
1083 |
status=PackagePublishingStatus.PUBLISHED, |
|
1084 |
architecturespecific=True) |
|
1085 |
||
1086 |
self.i386_indep_pub, self.hppa_indep_pub = ( |
|
1087 |
self.publisher.getPubBinaries( |
|
1088 |
version="1.2.3-4", archive=self.archive, binaryname="bar-bin", |
|
1089 |
status=PackagePublishingStatus.PUBLISHED)) |
|
1090 |
||
1091 |
self.bpns = getUtility(IBinaryPackageNameSet) |
|
1092 |
||
1093 |
def test_returns_matching_binarypackagerelease(self): |
|
1094 |
# The BPR with a file by the given name should be returned.
|
|
1095 |
self.assertEqual( |
|
1096 |
self.i386_pub.binarypackagerelease, |
|
1097 |
self.archive.getBinaryPackageRelease( |
|
1098 |
self.bpns['foo-bin'], '1.2.3-4', 'i386')) |
|
1099 |
||
1100 |
def test_returns_correct_architecture(self): |
|
1101 |
# The architecture is taken into account correctly.
|
|
1102 |
self.assertEqual( |
|
1103 |
self.hppa_pub.binarypackagerelease, |
|
1104 |
self.archive.getBinaryPackageRelease( |
|
1105 |
self.bpns['foo-bin'], '1.2.3-4', 'hppa')) |
|
1106 |
||
1107 |
def test_works_with_architecture_independent_binaries(self): |
|
1108 |
# Architecture independent binaries with multiple publishings
|
|
1109 |
# are found properly.
|
|
1110 |
# We use 'i386' as the arch tag here, since what we have in the DB
|
|
1111 |
# is the *build* arch tag, not the one in the filename ('all').
|
|
1112 |
self.assertEqual( |
|
1113 |
self.i386_indep_pub.binarypackagerelease, |
|
1114 |
self.archive.getBinaryPackageRelease( |
|
1115 |
self.bpns['bar-bin'], '1.2.3-4', 'i386')) |
|
1116 |
||
1117 |
def test_returns_none_for_nonexistent_binary(self): |
|
1118 |
# Non-existent files return None.
|
|
1119 |
self.assertIs( |
|
1120 |
None, |
|
1121 |
self.archive.getBinaryPackageRelease( |
|
1122 |
self.bpns['cdrkit'], '1.2.3-4', 'i386')) |
|
1123 |
||
1124 |
def test_returns_none_for_duplicate_file(self): |
|
1125 |
# In the unlikely case of multiple BPRs in this archive with the same
|
|
1126 |
# name (hopefully impossible, but it still happens occasionally due
|
|
1127 |
# to bugs), None is returned.
|
|
1128 |
||
1129 |
# Publish the same binaries again. Evil.
|
|
1130 |
self.publisher.getPubBinaries( |
|
1131 |
version="1.2.3-4", archive=self.archive, binaryname="foo-bin", |
|
1132 |
status=PackagePublishingStatus.PUBLISHED, |
|
1133 |
architecturespecific=True) |
|
1134 |
||
1135 |
self.assertIs( |
|
1136 |
None, |
|
1137 |
self.archive.getBinaryPackageRelease( |
|
1138 |
self.bpns['foo-bin'], '1.2.3-4', 'i386')) |
|
1139 |
||
1140 |
def test_returns_none_from_another_archive(self): |
|
1141 |
# Cross-archive searches are not performed.
|
|
1142 |
self.assertIs( |
|
1143 |
None, |
|
1144 |
self.factory.makeArchive().getBinaryPackageRelease( |
|
1145 |
self.bpns['foo-bin'], '1.2.3-4', 'i386')) |
|
1146 |
||
1147 |
||
10351.2.2
by William Grant
Add and test Archive.getBinaryPackageReleaseByFileName. |
1148 |
class TestGetBinaryPackageReleaseByFileName(TestCaseWithFactory): |
1149 |
"""Ensure that getBinaryPackageReleaseByFileName works as expected."""
|
|
1150 |
||
1151 |
layer = LaunchpadZopelessLayer |
|
1152 |
||
1153 |
def setUp(self): |
|
1154 |
"""Setup an archive with relevant publications."""
|
|
1155 |
super(TestGetBinaryPackageReleaseByFileName, self).setUp() |
|
1156 |
self.publisher = SoyuzTestPublisher() |
|
1157 |
self.publisher.prepareBreezyAutotest() |
|
1158 |
||
1159 |
self.archive = self.factory.makeArchive() |
|
1160 |
self.archive.require_virtualized = False |
|
1161 |
||
1162 |
self.i386_pub, self.hppa_pub = self.publisher.getPubBinaries( |
|
1163 |
version="1.2.3-4", archive=self.archive, binaryname="foo-bin", |
|
1164 |
status=PackagePublishingStatus.PUBLISHED, |
|
1165 |
architecturespecific=True) |
|
1166 |
||
1167 |
self.i386_indep_pub, self.hppa_indep_pub = ( |
|
1168 |
self.publisher.getPubBinaries( |
|
1169 |
version="1.2.3-4", archive=self.archive, binaryname="bar-bin", |
|
1170 |
status=PackagePublishingStatus.PUBLISHED)) |
|
1171 |
||
1172 |
def test_returns_matching_binarypackagerelease(self): |
|
1173 |
# The BPR with a file by the given name should be returned.
|
|
1174 |
self.assertEqual( |
|
1175 |
self.i386_pub.binarypackagerelease, |
|
1176 |
self.archive.getBinaryPackageReleaseByFileName( |
|
1177 |
"foo-bin_1.2.3-4_i386.deb")) |
|
1178 |
||
1179 |
def test_returns_correct_architecture(self): |
|
1180 |
# The architecture is taken into account correctly.
|
|
1181 |
self.assertEqual( |
|
1182 |
self.hppa_pub.binarypackagerelease, |
|
1183 |
self.archive.getBinaryPackageReleaseByFileName( |
|
1184 |
"foo-bin_1.2.3-4_hppa.deb")) |
|
1185 |
||
1186 |
def test_works_with_architecture_independent_binaries(self): |
|
1187 |
# Architecture independent binaries with multiple publishings
|
|
1188 |
# are found properly.
|
|
1189 |
self.assertEqual( |
|
1190 |
self.i386_indep_pub.binarypackagerelease, |
|
1191 |
self.archive.getBinaryPackageReleaseByFileName( |
|
1192 |
"bar-bin_1.2.3-4_all.deb")) |
|
1193 |
||
1194 |
def test_returns_none_for_source_file(self): |
|
1195 |
# None is returned if the file is a source component instead.
|
|
1196 |
self.assertIs( |
|
1197 |
None, |
|
1198 |
self.archive.getBinaryPackageReleaseByFileName( |
|
1199 |
"foo_1.2.3-4.dsc")) |
|
1200 |
||
1201 |
def test_returns_none_for_nonexistent_file(self): |
|
1202 |
# Non-existent files return None.
|
|
1203 |
self.assertIs( |
|
1204 |
None, |
|
1205 |
self.archive.getBinaryPackageReleaseByFileName( |
|
1206 |
"this-is-not-real_1.2.3-4_all.deb")) |
|
1207 |
||
12243.3.1
by William Grant
In the case of duplicates, getBinaryPackageReleaseByFileName now returns the latest, not None. |
1208 |
def test_returns_latest_for_duplicate_file(self): |
10351.2.2
by William Grant
Add and test Archive.getBinaryPackageReleaseByFileName. |
1209 |
# In the unlikely case of multiple BPRs in this archive with the same
|
1210 |
# name (hopefully impossible, but it still happens occasionally due
|
|
12243.3.1
by William Grant
In the case of duplicates, getBinaryPackageReleaseByFileName now returns the latest, not None. |
1211 |
# to bugs), the latest is returned.
|
10351.2.2
by William Grant
Add and test Archive.getBinaryPackageReleaseByFileName. |
1212 |
|
1213 |
# Publish the same binaries again. Evil.
|
|
12243.3.1
by William Grant
In the case of duplicates, getBinaryPackageReleaseByFileName now returns the latest, not None. |
1214 |
new_pubs = self.publisher.getPubBinaries( |
10351.2.2
by William Grant
Add and test Archive.getBinaryPackageReleaseByFileName. |
1215 |
version="1.2.3-4", archive=self.archive, binaryname="foo-bin", |
1216 |
status=PackagePublishingStatus.PUBLISHED, |
|
1217 |
architecturespecific=True) |
|
1218 |
||
12243.3.1
by William Grant
In the case of duplicates, getBinaryPackageReleaseByFileName now returns the latest, not None. |
1219 |
self.assertEquals( |
1220 |
new_pubs[0].binarypackagerelease, |
|
10351.2.2
by William Grant
Add and test Archive.getBinaryPackageReleaseByFileName. |
1221 |
self.archive.getBinaryPackageReleaseByFileName( |
1222 |
"foo-bin_1.2.3-4_i386.deb")) |
|
1223 |
||
1224 |
def test_returns_none_from_another_archive(self): |
|
1225 |
# Cross-archive searches are not performed.
|
|
1226 |
self.assertIs( |
|
1227 |
None, |
|
1228 |
self.factory.makeArchive().getBinaryPackageReleaseByFileName( |
|
1229 |
"foo-bin_1.2.3-4_i386.deb")) |
|
1230 |
||
1231 |
||
7675.658.1
by Michael Nelson
Added failing test. |
1232 |
class TestArchiveDelete(TestCaseWithFactory): |
1233 |
"""Edge-case tests for PPA deletion.
|
|
1234 |
||
1235 |
PPA deletion is also documented in lp/soyuz/doc/archive-deletion.txt.
|
|
1236 |
"""
|
|
1237 |
||
1238 |
layer = DatabaseFunctionalLayer |
|
1239 |
||
1240 |
def setUp(self): |
|
1241 |
"""Create a test archive and login as the owner."""
|
|
1242 |
super(TestArchiveDelete, self).setUp() |
|
1243 |
self.archive = self.factory.makeArchive() |
|
1244 |
login_person(self.archive.owner) |
|
1245 |
||
1246 |
def test_delete(self): |
|
1247 |
# Sanity check for the unit-test.
|
|
1248 |
self.archive.delete(deleted_by=self.archive.owner) |
|
1249 |
self.failUnlessEqual(ArchiveStatus.DELETING, self.archive.status) |
|
1250 |
||
7675.658.4
by Michael Nelson
Removed bug number from test method name, as per thumper's review comment. |
1251 |
def test_delete_when_disabled(self): |
1252 |
# A disabled archive can also be deleted (bug 574246).
|
|
7675.658.1
by Michael Nelson
Added failing test. |
1253 |
self.archive.disable() |
1254 |
self.archive.delete(deleted_by=self.archive.owner) |
|
1255 |
self.failUnlessEqual(ArchiveStatus.DELETING, self.archive.status) |
|
1256 |
||
1257 |
||
7675.724.4
by Julian Edwards
Add zcml for security and tests. |
1258 |
class TestCommercialArchive(TestCaseWithFactory): |
1259 |
"""Tests relating to commercial archives."""
|
|
1260 |
||
1261 |
layer = DatabaseFunctionalLayer |
|
1262 |
||
1263 |
def setUp(self): |
|
1264 |
super(TestCommercialArchive, self).setUp() |
|
1265 |
self.archive = self.factory.makeArchive() |
|
1266 |
||
1267 |
def setCommercial(self, archive, commercial): |
|
1268 |
"""Helper function."""
|
|
1269 |
archive.commercial = commercial |
|
1270 |
||
1271 |
def test_set_and_get_commercial(self): |
|
1272 |
# Basic set and get of the commercial property. Anyone can read
|
|
1273 |
# it and it defaults to False.
|
|
1274 |
login_person(self.archive.owner) |
|
1275 |
self.assertFalse(self.archive.commercial) |
|
1276 |
||
1277 |
# The archive owner can't change the value.
|
|
1278 |
self.assertRaises( |
|
1279 |
Unauthorized, self.setCommercial, self.archive, True) |
|
1280 |
||
1281 |
# Commercial admins can change it.
|
|
7675.767.12
by William Grant
Use lp.testing.sampledata instead of hardcoding sampledata email address. |
1282 |
login(COMMERCIAL_ADMIN_EMAIL) |
7675.724.4
by Julian Edwards
Add zcml for security and tests. |
1283 |
self.setCommercial(self.archive, True) |
1284 |
self.assertTrue(self.archive.commercial) |
|
7675.767.8
by William Grant
Add test of Archive.build_debug_symbols permissions. |
1285 |
|
1286 |
||
1287 |
class TestBuildDebugSymbols(TestCaseWithFactory): |
|
1288 |
"""Tests relating to the build_debug_symbols flag."""
|
|
1289 |
||
1290 |
layer = DatabaseFunctionalLayer |
|
1291 |
||
1292 |
def setUp(self): |
|
1293 |
super(TestBuildDebugSymbols, self).setUp() |
|
1294 |
self.archive = self.factory.makeArchive() |
|
1295 |
||
1296 |
def setBuildDebugSymbols(self, archive, build_debug_symbols): |
|
1297 |
"""Helper function."""
|
|
1298 |
archive.build_debug_symbols = build_debug_symbols |
|
1299 |
||
7675.767.15
by William Grant
Split build_debug_symbols tests up more sanely. |
1300 |
def test_build_debug_symbols_is_public(self): |
1301 |
# Anyone can see the attribute.
|
|
1302 |
login(ANONYMOUS) |
|
7675.767.8
by William Grant
Add test of Archive.build_debug_symbols permissions. |
1303 |
self.assertFalse(self.archive.build_debug_symbols) |
1304 |
||
7675.767.15
by William Grant
Split build_debug_symbols tests up more sanely. |
1305 |
def test_owner_cannot_set_build_debug_symbols(self): |
1306 |
# The archive owner cannot set it.
|
|
1307 |
login_person(self.archive.owner) |
|
7675.767.8
by William Grant
Add test of Archive.build_debug_symbols permissions. |
1308 |
self.assertRaises( |
1309 |
Unauthorized, self.setBuildDebugSymbols, self.archive, True) |
|
1310 |
||
7675.767.15
by William Grant
Split build_debug_symbols tests up more sanely. |
1311 |
def test_commercial_admin_can_set_build_debug_symbols(self): |
1312 |
# A commercial admin can set it.
|
|
7675.767.12
by William Grant
Use lp.testing.sampledata instead of hardcoding sampledata email address. |
1313 |
login(COMMERCIAL_ADMIN_EMAIL) |
7675.767.8
by William Grant
Add test of Archive.build_debug_symbols permissions. |
1314 |
self.setBuildDebugSymbols(self.archive, True) |
1315 |
self.assertTrue(self.archive.build_debug_symbols) |
|
7675.724.4
by Julian Edwards
Add zcml for security and tests. |
1316 |
|
1317 |
||
13137.1.16
by Aaron Bentley
Add tests. |
1318 |
class TestAddArchiveDependencies(TestCaseWithFactory): |
1319 |
||
1320 |
layer = DatabaseFunctionalLayer |
|
1321 |
||
1322 |
def test_add_hidden_dependency(self): |
|
1323 |
# The user cannot add a dependency on an archive they cannot see.
|
|
1324 |
archive = self.factory.makeArchive(private=True) |
|
1325 |
dependency = self.factory.makeArchive(private=True) |
|
1326 |
with person_logged_in(archive.owner): |
|
1327 |
with ExpectedException( |
|
1328 |
ArchiveDependencyError, |
|
1329 |
"You don't have permission to use this dependency."): |
|
1330 |
archive.addArchiveDependency(dependency, 'foo') |
|
1331 |
||
1332 |
def test_private_dependency_public_archive(self): |
|
1333 |
# A public archive may not depend on a private archive.
|
|
1334 |
archive = self.factory.makeArchive() |
|
1335 |
dependency = self.factory.makeArchive( |
|
1336 |
private=True, owner=archive.owner) |
|
1337 |
with person_logged_in(archive.owner): |
|
1338 |
with ExpectedException( |
|
1339 |
ArchiveDependencyError, |
|
1340 |
"Public PPAs cannot depend on private ones."): |
|
1341 |
archive.addArchiveDependency(dependency, 'foo') |
|
1342 |
||
1343 |
def test_add_private_dependency(self): |
|
1344 |
# The user can add a dependency on private archive they can see.
|
|
1345 |
archive = self.factory.makeArchive(private=True) |
|
1346 |
dependency = self.factory.makeArchive( |
|
1347 |
private=True, owner=archive.owner) |
|
1348 |
with person_logged_in(archive.owner): |
|
1349 |
archive_dependency = archive.addArchiveDependency(dependency, |
|
13137.1.17
by Aaron Bentley
Fix lint. |
1350 |
PackagePublishingPocket.RELEASE) |
1351 |
self.assertContentEqual( |
|
1352 |
archive.dependencies, [archive_dependency]) |
|
13137.1.16
by Aaron Bentley
Add tests. |
1353 |
|
1354 |
||
13137.1.20
by Aaron Bentley
Fix failing tests. |
1355 |
class TestArchiveDependencies(TestCaseWithFactory): |
1356 |
||
13137.1.21
by Aaron Bentley
Fix test layer. |
1357 |
layer = LaunchpadZopelessLayer |
13137.1.20
by Aaron Bentley
Fix failing tests. |
1358 |
|
1359 |
def test_private_sources_list(self): |
|
1360 |
"""Entries for private dependencies include credentials."""
|
|
1361 |
p3a = self.factory.makeArchive(name='p3a', private=True) |
|
1362 |
dependency = self.factory.makeArchive( |
|
1363 |
name='dependency', private=True, owner=p3a.owner) |
|
1364 |
with person_logged_in(p3a.owner): |
|
1365 |
bpph = self.factory.makeBinaryPackagePublishingHistory( |
|
1366 |
archive=dependency, status=PackagePublishingStatus.PUBLISHED) |
|
1367 |
p3a.addArchiveDependency(dependency, |
|
1368 |
PackagePublishingPocket.RELEASE) |
|
1369 |
build = self.factory.makeBinaryPackageBuild(archive=p3a, |
|
1370 |
distroarchseries=bpph.distroarchseries) |
|
1371 |
sources_list = get_sources_list_for_building( |
|
1372 |
build, build.distro_arch_series, |
|
1373 |
build.source_package_release.name) |
|
1374 |
matches = MatchesRegex( |
|
1375 |
"deb http://buildd:sekrit@private-ppa.launchpad.dev/"
|
|
1376 |
"person-name-.*/dependency/ubuntu distroseries-.* main") |
|
1377 |
self.assertThat(sources_list[0], matches) |
|
1378 |
||
1379 |
||
11149.9.19
by William Grant
Replace findDepCandidateByName with findDepCandidates, now returning all matching publications. Tests updated, and _isDependencySatisfied now checks if any publications satisfy its version criteria. Added tests for versioned dependency behaviour. |
1380 |
class TestFindDepCandidates(TestCaseWithFactory): |
1381 |
"""Tests for Archive.findDepCandidates."""
|
|
11149.9.1
by William Grant
Replace findDepCandidateByName doctests with unit tests. |
1382 |
|
1383 |
layer = LaunchpadZopelessLayer |
|
1384 |
||
1385 |
def setUp(self): |
|
11149.9.19
by William Grant
Replace findDepCandidateByName with findDepCandidates, now returning all matching publications. Tests updated, and _isDependencySatisfied now checks if any publications satisfy its version criteria. Added tests for versioned dependency behaviour. |
1386 |
super(TestFindDepCandidates, self).setUp() |
11149.9.1
by William Grant
Replace findDepCandidateByName doctests with unit tests. |
1387 |
self.archive = self.factory.makeArchive() |
1388 |
self.publisher = SoyuzTestPublisher() |
|
1389 |
login('admin@canonical.com') |
|
1390 |
self.publisher.prepareBreezyAutotest() |
|
1391 |
||
11149.9.7
by William Grant
Adjust findDepCandidateByName to take all relevant arguments. |
1392 |
def assertDep(self, arch_tag, name, expected, archive=None, |
1393 |
pocket=PackagePublishingPocket.RELEASE, component=None, |
|
1394 |
source_package_name='something-new'): |
|
11149.9.19
by William Grant
Replace findDepCandidateByName with findDepCandidates, now returning all matching publications. Tests updated, and _isDependencySatisfied now checks if any publications satisfy its version criteria. Added tests for versioned dependency behaviour. |
1395 |
"""Helper to check that findDepCandidates works.
|
11149.9.2
by William Grant
Test that PPAs search the primary archive, even if there's no explicit dependency. |
1396 |
|
1397 |
Searches for the given dependency name in the given architecture and
|
|
1398 |
archive, and compares it to the given expected value.
|
|
1399 |
The archive defaults to self.archive.
|
|
1400 |
||
11149.9.19
by William Grant
Replace findDepCandidateByName with findDepCandidates, now returning all matching publications. Tests updated, and _isDependencySatisfied now checks if any publications satisfy its version criteria. Added tests for versioned dependency behaviour. |
1401 |
Also commits, since findDepCandidates uses the slave store.
|
11149.9.2
by William Grant
Test that PPAs search the primary archive, even if there's no explicit dependency. |
1402 |
"""
|
11149.9.1
by William Grant
Replace findDepCandidateByName doctests with unit tests. |
1403 |
transaction.commit() |
1404 |
||
11149.9.7
by William Grant
Adjust findDepCandidateByName to take all relevant arguments. |
1405 |
if component is None: |
1406 |
component = getUtility(IComponentSet)['main'] |
|
11149.9.1
by William Grant
Replace findDepCandidateByName doctests with unit tests. |
1407 |
if archive is None: |
1408 |
archive = self.archive |
|
11149.9.7
by William Grant
Adjust findDepCandidateByName to take all relevant arguments. |
1409 |
|
11149.9.1
by William Grant
Replace findDepCandidateByName doctests with unit tests. |
1410 |
self.assertEquals( |
11149.9.19
by William Grant
Replace findDepCandidateByName with findDepCandidates, now returning all matching publications. Tests updated, and _isDependencySatisfied now checks if any publications satisfy its version criteria. Added tests for versioned dependency behaviour. |
1411 |
list( |
1412 |
archive.findDepCandidates( |
|
1413 |
self.publisher.distroseries[arch_tag], pocket, component, |
|
1414 |
source_package_name, name)), |
|
11149.9.1
by William Grant
Replace findDepCandidateByName doctests with unit tests. |
1415 |
expected) |
1416 |
||
1417 |
def test_finds_candidate_in_same_archive(self): |
|
1418 |
# A published candidate in the same archive should be found.
|
|
1419 |
bins = self.publisher.getPubBinaries( |
|
1420 |
binaryname='foo', archive=self.archive, |
|
1421 |
status=PackagePublishingStatus.PUBLISHED) |
|
11149.9.19
by William Grant
Replace findDepCandidateByName with findDepCandidates, now returning all matching publications. Tests updated, and _isDependencySatisfied now checks if any publications satisfy its version criteria. Added tests for versioned dependency behaviour. |
1422 |
self.assertDep('i386', 'foo', [bins[0]]) |
1423 |
self.assertDep('hppa', 'foo', [bins[1]]) |
|
11149.9.1
by William Grant
Replace findDepCandidateByName doctests with unit tests. |
1424 |
|
1425 |
def test_does_not_find_pending_publication(self): |
|
1426 |
# A pending candidate in the same archive should not be found.
|
|
13137.1.17
by Aaron Bentley
Fix lint. |
1427 |
self.publisher.getPubBinaries( |
11149.9.1
by William Grant
Replace findDepCandidateByName doctests with unit tests. |
1428 |
binaryname='foo', archive=self.archive) |
11149.9.19
by William Grant
Replace findDepCandidateByName with findDepCandidates, now returning all matching publications. Tests updated, and _isDependencySatisfied now checks if any publications satisfy its version criteria. Added tests for versioned dependency behaviour. |
1429 |
self.assertDep('i386', 'foo', []) |
11149.9.1
by William Grant
Replace findDepCandidateByName doctests with unit tests. |
1430 |
|
11149.9.2
by William Grant
Test that PPAs search the primary archive, even if there's no explicit dependency. |
1431 |
def test_ppa_searches_primary_archive(self): |
1432 |
# PPA searches implicitly look in the primary archive too.
|
|
1433 |
self.assertEquals(self.archive.purpose, ArchivePurpose.PPA) |
|
11149.9.19
by William Grant
Replace findDepCandidateByName with findDepCandidates, now returning all matching publications. Tests updated, and _isDependencySatisfied now checks if any publications satisfy its version criteria. Added tests for versioned dependency behaviour. |
1434 |
self.assertDep('i386', 'foo', []) |
11149.9.2
by William Grant
Test that PPAs search the primary archive, even if there's no explicit dependency. |
1435 |
|
1436 |
bins = self.publisher.getPubBinaries( |
|
1437 |
binaryname='foo', archive=self.archive.distribution.main_archive, |
|
1438 |
status=PackagePublishingStatus.PUBLISHED) |
|
1439 |
||
11149.9.19
by William Grant
Replace findDepCandidateByName with findDepCandidates, now returning all matching publications. Tests updated, and _isDependencySatisfied now checks if any publications satisfy its version criteria. Added tests for versioned dependency behaviour. |
1440 |
self.assertDep('i386', 'foo', [bins[0]]) |
11149.9.2
by William Grant
Test that PPAs search the primary archive, even if there's no explicit dependency. |
1441 |
|
11149.9.1
by William Grant
Replace findDepCandidateByName doctests with unit tests. |
1442 |
def test_searches_dependencies(self): |
11149.9.2
by William Grant
Test that PPAs search the primary archive, even if there's no explicit dependency. |
1443 |
# Candidates from archives on which the target explicitly depends
|
1444 |
# should be found.
|
|
11149.9.1
by William Grant
Replace findDepCandidateByName doctests with unit tests. |
1445 |
bins = self.publisher.getPubBinaries( |
1446 |
binaryname='foo', archive=self.archive, |
|
1447 |
status=PackagePublishingStatus.PUBLISHED) |
|
1448 |
other_archive = self.factory.makeArchive() |
|
11149.9.19
by William Grant
Replace findDepCandidateByName with findDepCandidates, now returning all matching publications. Tests updated, and _isDependencySatisfied now checks if any publications satisfy its version criteria. Added tests for versioned dependency behaviour. |
1449 |
self.assertDep('i386', 'foo', [], archive=other_archive) |
11149.9.1
by William Grant
Replace findDepCandidateByName doctests with unit tests. |
1450 |
|
1451 |
other_archive.addArchiveDependency( |
|
1452 |
self.archive, PackagePublishingPocket.RELEASE) |
|
11149.9.19
by William Grant
Replace findDepCandidateByName with findDepCandidates, now returning all matching publications. Tests updated, and _isDependencySatisfied now checks if any publications satisfy its version criteria. Added tests for versioned dependency behaviour. |
1453 |
self.assertDep('i386', 'foo', [bins[0]], archive=other_archive) |
7675.724.4
by Julian Edwards
Add zcml for security and tests. |
1454 |
|
11149.9.8
by William Grant
Use expand_dependencies to calculate archives, pockets and components in which findDepCandidateByName should hunt. |
1455 |
def test_obeys_dependency_pockets(self): |
1456 |
# Only packages published in a pocket matching the dependency should
|
|
1457 |
# be found.
|
|
1458 |
release_bins = self.publisher.getPubBinaries( |
|
1459 |
binaryname='foo-release', archive=self.archive, |
|
1460 |
status=PackagePublishingStatus.PUBLISHED) |
|
1461 |
updates_bins = self.publisher.getPubBinaries( |
|
1462 |
binaryname='foo-updates', archive=self.archive, |
|
1463 |
status=PackagePublishingStatus.PUBLISHED, |
|
1464 |
pocket=PackagePublishingPocket.UPDATES) |
|
1465 |
proposed_bins = self.publisher.getPubBinaries( |
|
1466 |
binaryname='foo-proposed', archive=self.archive, |
|
1467 |
status=PackagePublishingStatus.PUBLISHED, |
|
1468 |
pocket=PackagePublishingPocket.PROPOSED) |
|
1469 |
||
1470 |
# Temporarily turn our test PPA into a copy archive, so we can
|
|
1471 |
# add non-RELEASE dependencies on it.
|
|
1472 |
removeSecurityProxy(self.archive).purpose = ArchivePurpose.COPY |
|
1473 |
||
1474 |
other_archive = self.factory.makeArchive() |
|
1475 |
other_archive.addArchiveDependency( |
|
1476 |
self.archive, PackagePublishingPocket.UPDATES) |
|
1477 |
self.assertDep( |
|
11149.9.19
by William Grant
Replace findDepCandidateByName with findDepCandidates, now returning all matching publications. Tests updated, and _isDependencySatisfied now checks if any publications satisfy its version criteria. Added tests for versioned dependency behaviour. |
1478 |
'i386', 'foo-release', [release_bins[0]], archive=other_archive) |
11149.9.8
by William Grant
Use expand_dependencies to calculate archives, pockets and components in which findDepCandidateByName should hunt. |
1479 |
self.assertDep( |
11149.9.19
by William Grant
Replace findDepCandidateByName with findDepCandidates, now returning all matching publications. Tests updated, and _isDependencySatisfied now checks if any publications satisfy its version criteria. Added tests for versioned dependency behaviour. |
1480 |
'i386', 'foo-updates', [updates_bins[0]], archive=other_archive) |
1481 |
self.assertDep('i386', 'foo-proposed', [], archive=other_archive) |
|
11149.9.8
by William Grant
Use expand_dependencies to calculate archives, pockets and components in which findDepCandidateByName should hunt. |
1482 |
|
1483 |
other_archive.removeArchiveDependency(self.archive) |
|
1484 |
other_archive.addArchiveDependency( |
|
1485 |
self.archive, PackagePublishingPocket.PROPOSED) |
|
1486 |
self.assertDep( |
|
11149.9.19
by William Grant
Replace findDepCandidateByName with findDepCandidates, now returning all matching publications. Tests updated, and _isDependencySatisfied now checks if any publications satisfy its version criteria. Added tests for versioned dependency behaviour. |
1487 |
'i386', 'foo-proposed', [proposed_bins[0]], archive=other_archive) |
11149.9.8
by William Grant
Use expand_dependencies to calculate archives, pockets and components in which findDepCandidateByName should hunt. |
1488 |
|
1489 |
def test_obeys_dependency_components(self): |
|
1490 |
# Only packages published in a component matching the dependency
|
|
1491 |
# should be found.
|
|
1492 |
primary = self.archive.distribution.main_archive |
|
1493 |
main_bins = self.publisher.getPubBinaries( |
|
1494 |
binaryname='foo-main', archive=primary, component='main', |
|
1495 |
status=PackagePublishingStatus.PUBLISHED) |
|
1496 |
universe_bins = self.publisher.getPubBinaries( |
|
1497 |
binaryname='foo-universe', archive=primary, |
|
1498 |
component='universe', |
|
1499 |
status=PackagePublishingStatus.PUBLISHED) |
|
1500 |
||
1501 |
self.archive.addArchiveDependency( |
|
1502 |
primary, PackagePublishingPocket.RELEASE, |
|
1503 |
component=getUtility(IComponentSet)['main']) |
|
11149.9.19
by William Grant
Replace findDepCandidateByName with findDepCandidates, now returning all matching publications. Tests updated, and _isDependencySatisfied now checks if any publications satisfy its version criteria. Added tests for versioned dependency behaviour. |
1504 |
self.assertDep('i386', 'foo-main', [main_bins[0]]) |
1505 |
self.assertDep('i386', 'foo-universe', []) |
|
11149.9.8
by William Grant
Use expand_dependencies to calculate archives, pockets and components in which findDepCandidateByName should hunt. |
1506 |
|
1507 |
self.archive.removeArchiveDependency(primary) |
|
1508 |
self.archive.addArchiveDependency( |
|
1509 |
primary, PackagePublishingPocket.RELEASE, |
|
1510 |
component=getUtility(IComponentSet)['universe']) |
|
11149.9.19
by William Grant
Replace findDepCandidateByName with findDepCandidates, now returning all matching publications. Tests updated, and _isDependencySatisfied now checks if any publications satisfy its version criteria. Added tests for versioned dependency behaviour. |
1511 |
self.assertDep('i386', 'foo-main', [main_bins[0]]) |
1512 |
self.assertDep('i386', 'foo-universe', [universe_bins[0]]) |
|
11265.2.13
by James Westby
Merge test_permission from archiveuploader in to test_archive. |
1513 |
|
1514 |
||
7675.1146.10
by Raphael Badin
Add complex overlay unit test. |
1515 |
class TestOverlays(TestCaseWithFactory): |
1516 |
||
1517 |
layer = LaunchpadZopelessLayer |
|
1518 |
||
1519 |
def _createDep(self, derived_series, parent_series, |
|
1520 |
parent_distro, component_name=None, pocket=None, |
|
1521 |
overlay=True, arch_tag='i386', |
|
1522 |
publish_base_url=u'http://archive.launchpad.dev/'): |
|
1523 |
# Helper to create a parent/child relationshipi.
|
|
1524 |
if type(parent_distro) == str: |
|
1525 |
depdistro = self.factory.makeDistribution(parent_distro, |
|
1526 |
publish_base_url=publish_base_url) |
|
1527 |
else: |
|
1528 |
depdistro = parent_distro |
|
1529 |
if type(parent_series) == str: |
|
1530 |
depseries = self.factory.makeDistroSeries( |
|
1531 |
name=parent_series, distribution=depdistro) |
|
13697.6.5
by Henning Eggers
Removed some lint. |
1532 |
self.factory.makeDistroArchSeries( |
7675.1146.10
by Raphael Badin
Add complex overlay unit test. |
1533 |
distroseries=depseries, architecturetag=arch_tag) |
1534 |
else: |
|
1535 |
depseries = parent_series |
|
1536 |
if component_name is not None: |
|
1537 |
component = getUtility(IComponentSet)[component_name] |
|
1538 |
else: |
|
1539 |
component = None |
|
1540 |
||
1541 |
self.factory.makeDistroSeriesParent( |
|
1542 |
derived_series=derived_series, parent_series=depseries, |
|
1543 |
initialized=True, is_overlay=overlay, pocket=pocket, |
|
1544 |
component=component) |
|
1545 |
return depseries, depdistro |
|
1546 |
||
1547 |
def test_overlay_dependencies(self): |
|
1548 |
# sources.list is properly generated for a complex overlay structure.
|
|
1549 |
# Pocket dependencies and component dependencies are taken into
|
|
1550 |
# account when generating sources.list.
|
|
1551 |
#
|
|
1552 |
# breezy type of relation:
|
|
1553 |
# | | |
|
|
1554 |
# ----------------------- | o
|
|
1555 |
# | | | | |
|
|
1556 |
# o o | no overlay overlay
|
|
1557 |
# | | |
|
|
1558 |
# series11 series21 series31
|
|
1559 |
# |
|
|
1560 |
# o
|
|
1561 |
# |
|
|
1562 |
# series12
|
|
1563 |
#
|
|
1564 |
test_publisher = SoyuzTestPublisher() |
|
1565 |
test_publisher.prepareBreezyAutotest() |
|
1566 |
breezy = test_publisher.breezy_autotest |
|
1567 |
pub_source = test_publisher.getPubSource( |
|
1568 |
version='1.1', archive=breezy.main_archive) |
|
1569 |
[build] = pub_source.createMissingBuilds() |
|
1570 |
series11, depdistro = self._createDep( |
|
1571 |
breezy, 'series11', 'depdistro', 'universe', |
|
1572 |
PackagePublishingPocket.SECURITY) |
|
1573 |
self._createDep( |
|
1574 |
breezy, 'series21', 'depdistro2', 'multiverse', |
|
1575 |
PackagePublishingPocket.UPDATES) |
|
1576 |
self._createDep(breezy, 'series31', 'depdistro3', overlay=False) |
|
1577 |
self._createDep( |
|
1578 |
series11, 'series12', 'depdistro4', 'multiverse', |
|
1579 |
PackagePublishingPocket.UPDATES) |
|
1580 |
sources_list = get_sources_list_for_building(build, |
|
1581 |
build.distro_arch_series, build.source_package_release.name) |
|
1582 |
||
7675.1146.11
by Raphael Badin
Refactor test to use DocTestMatches. |
1583 |
self.assertThat( |
1584 |
"\n".join(sources_list), |
|
1585 |
DocTestMatches( |
|
1586 |
".../ubuntutest breezy-autotest main\n" |
|
1587 |
".../depdistro series11 main universe\n" |
|
1588 |
".../depdistro series11-security main universe\n" |
|
1589 |
".../depdistro2 series21 "
|
|
1590 |
"main restricted universe multiverse\n" |
|
1591 |
".../depdistro2 series21-security "
|
|
1592 |
"main restricted universe multiverse\n" |
|
1593 |
".../depdistro2 series21-updates "
|
|
1594 |
"main restricted universe multiverse\n" |
|
1595 |
".../depdistro4 series12 main restricted "
|
|
1596 |
"universe multiverse\n" |
|
1597 |
".../depdistro4 series12-security main "
|
|
1598 |
"restricted universe multiverse\n" |
|
1599 |
".../depdistro4 series12-updates "
|
|
13697.6.5
by Henning Eggers
Removed some lint. |
1600 |
"main restricted universe multiverse\n", |
1601 |
doctest.ELLIPSIS)) |
|
7675.1146.10
by Raphael Badin
Add complex overlay unit test. |
1602 |
|
1603 |
||
11265.2.13
by James Westby
Merge test_permission from archiveuploader in to test_archive. |
1604 |
class TestComponents(TestCaseWithFactory): |
1605 |
||
1606 |
layer = DatabaseFunctionalLayer |
|
1607 |
||
1608 |
def test_no_components_for_arbitrary_person(self): |
|
1609 |
# By default, a person cannot upload to any component of an archive.
|
|
1610 |
archive = self.factory.makeArchive() |
|
1611 |
person = self.factory.makePerson() |
|
1612 |
self.assertEqual(set(), |
|
1613 |
set(archive.getComponentsForUploader(person))) |
|
1614 |
||
1615 |
def test_components_for_person_with_permissions(self): |
|
1616 |
# If a person has been explicitly granted upload permissions to a
|
|
1617 |
# particular component, then those components are included in
|
|
1618 |
# IArchive.getComponentsForUploader.
|
|
1619 |
archive = self.factory.makeArchive() |
|
1620 |
component = self.factory.makeComponent() |
|
1621 |
person = self.factory.makePerson() |
|
1622 |
# Only admins or techboard members can add permissions normally. That
|
|
1623 |
# restriction isn't relevant to this test.
|
|
1624 |
ap_set = removeSecurityProxy(getUtility(IArchivePermissionSet)) |
|
1625 |
ap = ap_set.newComponentUploader(archive, person, component) |
|
1626 |
self.assertEqual(set([ap]), |
|
1627 |
set(archive.getComponentsForUploader(person))) |
|
7675.884.7
by William Grant
Add getComponentsForSeries tests. |
1628 |
|
1629 |
||
13496.1.3
by Jonathan Lange
Add validation checks for privacy |
1630 |
class TestValidatePPA(TestCaseWithFactory): |
11706.2.5
by Steve Kowalik
* Remove acceptance. |
1631 |
|
1632 |
layer = DatabaseFunctionalLayer |
|
1633 |
||
1634 |
def test_open_teams(self): |
|
1635 |
team = self.factory.makeTeam() |
|
11822.1.1
by Steve Kowalik
Correct strings used in tests to match the changes to Archive.validatePPA() |
1636 |
self.assertEqual('Open teams cannot have PPAs.', |
11706.2.5
by Steve Kowalik
* Remove acceptance. |
1637 |
Archive.validatePPA(team, None)) |
1638 |
||
1639 |
def test_distribution_name(self): |
|
1640 |
ppa_owner = self.factory.makePerson() |
|
1641 |
self.assertEqual( |
|
11822.1.1
by Steve Kowalik
Correct strings used in tests to match the changes to Archive.validatePPA() |
1642 |
'A PPA cannot have the same name as its distribution.', |
11706.2.5
by Steve Kowalik
* Remove acceptance. |
1643 |
Archive.validatePPA(ppa_owner, 'ubuntu')) |
1644 |
||
13496.1.3
by Jonathan Lange
Add validation checks for privacy |
1645 |
def test_private_ppa_non_commercial_admin(self): |
1646 |
ppa_owner = self.factory.makePerson() |
|
1647 |
self.assertEqual( |
|
1648 |
'%s is not allowed to make private PPAs' % (ppa_owner.name,), |
|
1649 |
Archive.validatePPA(ppa_owner, self.factory.getUniqueString(), |
|
1650 |
private=True)) |
|
1651 |
||
1652 |
def test_private_ppa_commercial_admin(self): |
|
1653 |
ppa_owner = self.factory.makePerson() |
|
1654 |
with celebrity_logged_in('admin'): |
|
1655 |
comm = getUtility(ILaunchpadCelebrities).commercial_admin |
|
1656 |
comm.addMember(ppa_owner, comm.teamowner) |
|
1657 |
self.assertIs( |
|
1658 |
None, |
|
1659 |
Archive.validatePPA(ppa_owner, self.factory.getUniqueString(), |
|
1660 |
private=True)) |
|
1661 |
||
13496.1.5
by Jonathan Lange
Oops. admins should also be able to do this. |
1662 |
def test_private_ppa_admin(self): |
1663 |
ppa_owner = self.factory.makeAdministrator() |
|
1664 |
self.assertIs( |
|
1665 |
None, |
|
1666 |
Archive.validatePPA(ppa_owner, self.factory.getUniqueString(), |
|
1667 |
private=True)) |
|
1668 |
||
11706.2.5
by Steve Kowalik
* Remove acceptance. |
1669 |
def test_two_ppas(self): |
1670 |
ppa = self.factory.makeArchive(name='ppa') |
|
1671 |
self.assertEqual("You already have a PPA named 'ppa'.", |
|
1672 |
Archive.validatePPA(ppa.owner, 'ppa')) |
|
1673 |
||
12043.1.1
by Steve Kowalik
Fix message to work better for teams. |
1674 |
def test_two_ppas_with_team(self): |
1675 |
team = self.factory.makeTeam( |
|
1676 |
subscription_policy=TeamSubscriptionPolicy.MODERATED) |
|
13137.1.17
by Aaron Bentley
Fix lint. |
1677 |
self.factory.makeArchive(owner=team, name='ppa') |
12043.1.1
by Steve Kowalik
Fix message to work better for teams. |
1678 |
self.assertEqual("%s already has a PPA named 'ppa'." % ( |
1679 |
team.displayname), Archive.validatePPA(team, 'ppa')) |
|
1680 |
||
11706.2.5
by Steve Kowalik
* Remove acceptance. |
1681 |
def test_valid_ppa(self): |
1682 |
ppa_owner = self.factory.makePerson() |
|
1683 |
self.assertEqual(None, Archive.validatePPA(ppa_owner, None)) |
|
7675.884.16
by William Grant
Merge devel. |
1684 |
|
1685 |
||
7675.884.7
by William Grant
Add getComponentsForSeries tests. |
1686 |
class TestGetComponentsForSeries(TestCaseWithFactory): |
7675.884.14
by William Grant
Add comments and docstrings to TestGetComponentsForSeries. |
1687 |
"""Tests for Archive.getComponentsForSeries."""
|
7675.884.7
by William Grant
Add getComponentsForSeries tests. |
1688 |
|
1689 |
layer = DatabaseFunctionalLayer |
|
1690 |
||
1691 |
def setUp(self): |
|
1692 |
super(TestGetComponentsForSeries, self).setUp() |
|
1693 |
self.series = self.factory.makeDistroSeries() |
|
1694 |
self.comp1 = self.factory.makeComponent() |
|
1695 |
self.comp2 = self.factory.makeComponent() |
|
1696 |
||
1697 |
def test_series_components_for_primary_archive(self): |
|
7675.884.14
by William Grant
Add comments and docstrings to TestGetComponentsForSeries. |
1698 |
# The primary archive uses the series' defined components.
|
12014.1.3
by Julian Edwards
fix test_series_components_for_primary_archive which was actually testing a PPA ... |
1699 |
archive = self.factory.makeArchive(purpose=ArchivePurpose.PRIMARY) |
7675.884.7
by William Grant
Add getComponentsForSeries tests. |
1700 |
self.assertEquals( |
12177.11.8
by William Grant
Turn DistroSeries.components into a list instead of a resultset. Nobody uses its laziness, and it makes caching useless. |
1701 |
0, len(archive.getComponentsForSeries(self.series))) |
7675.884.7
by William Grant
Add getComponentsForSeries tests. |
1702 |
|
1703 |
ComponentSelection(distroseries=self.series, component=self.comp1) |
|
1704 |
ComponentSelection(distroseries=self.series, component=self.comp2) |
|
12177.11.6
by William Grant
Turn DistroSeries.components into a cachedproperty, and fix a test to cope. |
1705 |
clear_property_cache(self.series) |
7675.884.7
by William Grant
Add getComponentsForSeries tests. |
1706 |
|
1707 |
self.assertEquals( |
|
1708 |
set((self.comp1, self.comp2)), |
|
1709 |
set(archive.getComponentsForSeries(self.series))) |
|
1710 |
||
1711 |
def test_partner_component_for_partner_archive(self): |
|
7675.884.14
by William Grant
Add comments and docstrings to TestGetComponentsForSeries. |
1712 |
# The partner archive always uses only the 'partner' component.
|
7675.884.7
by William Grant
Add getComponentsForSeries tests. |
1713 |
archive = self.factory.makeArchive(purpose=ArchivePurpose.PARTNER) |
1714 |
ComponentSelection(distroseries=self.series, component=self.comp1) |
|
1715 |
partner_comp = getUtility(IComponentSet)['partner'] |
|
1716 |
self.assertEquals( |
|
1717 |
[partner_comp], |
|
1718 |
list(archive.getComponentsForSeries(self.series))) |
|
12014.1.1
by Julian Edwards
PPAs should only have a 'main' component. |
1719 |
|
1720 |
def test_component_for_ppas(self): |
|
1721 |
# PPAs only use 'main'.
|
|
1722 |
archive = self.factory.makeArchive(purpose=ArchivePurpose.PPA) |
|
1723 |
ComponentSelection(distroseries=self.series, component=self.comp1) |
|
1724 |
main_comp = getUtility(IComponentSet)['main'] |
|
1725 |
self.assertEquals( |
|
1726 |
[main_comp], list(archive.getComponentsForSeries(self.series))) |
|
12016.1.1
by Julian Edwards
add new tests |
1727 |
|
1728 |
||
12177.11.1
by William Grant
Add (I)Archive.default_component. |
1729 |
class TestDefaultComponent(TestCaseWithFactory): |
1730 |
"""Tests for Archive.default_component."""
|
|
1731 |
||
1732 |
layer = DatabaseFunctionalLayer |
|
1733 |
||
12177.11.11
by William Grant
s/forced_component/default_component/ in tests. |
1734 |
def test_default_component_for_other_archives(self): |
12177.11.1
by William Grant
Add (I)Archive.default_component. |
1735 |
archive = self.factory.makeArchive(purpose=ArchivePurpose.PRIMARY) |
1736 |
self.assertIs(None, archive.default_component) |
|
1737 |
||
12177.11.11
by William Grant
s/forced_component/default_component/ in tests. |
1738 |
def test_default_component_for_partner(self): |
12177.11.4
by William Grant
Make default_component work for partner, and use default_component in getComponentsForSeries. |
1739 |
archive = self.factory.makeArchive(purpose=ArchivePurpose.PARTNER) |
1740 |
self.assertEquals( |
|
1741 |
getUtility(IComponentSet)['partner'], archive.default_component) |
|
1742 |
||
12177.11.11
by William Grant
s/forced_component/default_component/ in tests. |
1743 |
def test_default_component_for_ppas(self): |
12177.11.1
by William Grant
Add (I)Archive.default_component. |
1744 |
archive = self.factory.makeArchive(purpose=ArchivePurpose.PPA) |
1745 |
self.assertEquals( |
|
1746 |
getUtility(IComponentSet)['main'], archive.default_component) |
|
1747 |
||
1748 |
||
12016.1.1
by Julian Edwards
add new tests |
1749 |
class TestGetPockets(TestCaseWithFactory): |
1750 |
||
1751 |
layer = DatabaseFunctionalLayer |
|
1752 |
||
1753 |
def test_getPockets_for_other_archives(self): |
|
1754 |
archive = self.factory.makeArchive(purpose=ArchivePurpose.PRIMARY) |
|
1755 |
self.assertEqual( |
|
12016.1.3
by Julian Edwards
Make the publisher use the context archive to get a list of pockets to consider. |
1756 |
list(PackagePublishingPocket.items), archive.getPockets()) |
12016.1.1
by Julian Edwards
add new tests |
1757 |
|
1758 |
def test_getPockets_for_PPAs(self): |
|
12016.1.2
by Julian Edwards
fix test and add getPockets |
1759 |
archive = self.factory.makeArchive(purpose=ArchivePurpose.PPA) |
12016.1.1
by Julian Edwards
add new tests |
1760 |
self.assertEqual( |
12016.1.2
by Julian Edwards
fix test and add getPockets |
1761 |
[PackagePublishingPocket.RELEASE], archive.getPockets()) |
12019.8.3
by William Grant
Merge devel, resolving conflicts. |
1762 |
|
1763 |
||
12019.8.2
by William Grant
Replace most of archive-files.txt with unittests in test_archive. The remainder is now build-files.txt. |
1764 |
class TestGetFileByName(TestCaseWithFactory): |
1765 |
"""Tests for Archive.getFileByName."""
|
|
1766 |
||
1767 |
layer = LaunchpadZopelessLayer |
|
1768 |
||
1769 |
def setUp(self): |
|
1770 |
super(TestGetFileByName, self).setUp() |
|
1771 |
self.archive = self.factory.makeArchive() |
|
1772 |
||
1773 |
def test_unknown_file_is_not_found(self): |
|
1774 |
# A file with an unsupported extension is not found.
|
|
1775 |
self.assertRaises(NotFoundError, self.archive.getFileByName, 'a.bar') |
|
1776 |
||
1777 |
def test_source_file_is_found(self): |
|
1778 |
# A file from a published source package can be retrieved.
|
|
1779 |
pub = self.factory.makeSourcePackagePublishingHistory( |
|
1780 |
archive=self.archive) |
|
1781 |
dsc = self.factory.makeLibraryFileAlias(filename='foo_1.0.dsc') |
|
1782 |
self.assertRaises( |
|
1783 |
NotFoundError, self.archive.getFileByName, dsc.filename) |
|
1784 |
pub.sourcepackagerelease.addFile(dsc) |
|
1785 |
self.assertEquals(dsc, self.archive.getFileByName(dsc.filename)) |
|
1786 |
||
1787 |
def test_nonexistent_source_file_is_not_found(self): |
|
1788 |
# Something that looks like a source file but isn't is not
|
|
1789 |
# found.
|
|
1790 |
self.assertRaises( |
|
1791 |
NotFoundError, self.archive.getFileByName, 'foo_1.0.dsc') |
|
1792 |
||
1793 |
def test_binary_file_is_found(self): |
|
1794 |
# A file from a published binary package can be retrieved.
|
|
1795 |
pub = self.factory.makeBinaryPackagePublishingHistory( |
|
1796 |
archive=self.archive) |
|
1797 |
deb = self.factory.makeLibraryFileAlias(filename='foo_1.0_all.deb') |
|
1798 |
self.assertRaises( |
|
1799 |
NotFoundError, self.archive.getFileByName, deb.filename) |
|
1800 |
pub.binarypackagerelease.addFile(deb) |
|
1801 |
self.assertEquals(deb, self.archive.getFileByName(deb.filename)) |
|
1802 |
||
1803 |
def test_nonexistent_binary_file_is_not_found(self): |
|
1804 |
# Something that looks like a binary file but isn't is not
|
|
1805 |
# found.
|
|
1806 |
self.assertRaises( |
|
1807 |
NotFoundError, self.archive.getFileByName, 'foo_1.0_all.deb') |
|
1808 |
||
1809 |
def test_source_changes_file_is_found(self): |
|
1810 |
# A .changes file from a published source can be retrieved.
|
|
1811 |
pub = self.factory.makeSourcePackagePublishingHistory( |
|
1812 |
archive=self.archive) |
|
1813 |
pu = self.factory.makePackageUpload( |
|
1814 |
changes_filename='foo_1.0_source.changes') |
|
1815 |
pu.setDone() |
|
1816 |
self.assertRaises( |
|
1817 |
NotFoundError, self.archive.getFileByName, |
|
1818 |
pu.changesfile.filename) |
|
1819 |
pu.addSource(pub.sourcepackagerelease) |
|
1820 |
self.assertEquals( |
|
1821 |
pu.changesfile, |
|
1822 |
self.archive.getFileByName(pu.changesfile.filename)) |
|
1823 |
||
1824 |
def test_nonexistent_source_changes_file_is_not_found(self): |
|
1825 |
# Something that looks like a source .changes file but isn't is not
|
|
1826 |
# found.
|
|
1827 |
self.assertRaises( |
|
1828 |
NotFoundError, self.archive.getFileByName, |
|
1829 |
'foo_1.0_source.changes') |
|
1830 |
||
1831 |
def test_package_diff_is_found(self): |
|
1832 |
# A .diff.gz from a package diff can be retrieved.
|
|
1833 |
pub = self.factory.makeSourcePackagePublishingHistory( |
|
1834 |
archive=self.archive) |
|
1835 |
diff = self.factory.makePackageDiff( |
|
1836 |
to_source=pub.sourcepackagerelease, |
|
1837 |
diff_filename='foo_1.0.diff.gz') |
|
1838 |
self.assertEquals( |
|
1839 |
diff.diff_content, |
|
1840 |
self.archive.getFileByName(diff.diff_content.filename)) |
|
1841 |
||
1842 |
def test_expired_files_are_skipped(self): |
|
1843 |
# Expired files are ignored.
|
|
1844 |
pub = self.factory.makeSourcePackagePublishingHistory( |
|
1845 |
archive=self.archive) |
|
1846 |
dsc = self.factory.makeLibraryFileAlias(filename='foo_1.0.dsc') |
|
1847 |
pub.sourcepackagerelease.addFile(dsc) |
|
1848 |
||
1849 |
# The file is initially found without trouble.
|
|
1850 |
self.assertEquals(dsc, self.archive.getFileByName(dsc.filename)) |
|
1851 |
||
1852 |
# But after expiry it is not.
|
|
1853 |
removeSecurityProxy(dsc).content = None |
|
1854 |
self.assertRaises( |
|
1855 |
NotFoundError, self.archive.getFileByName, dsc.filename) |
|
1856 |
||
1857 |
# It reappears if we create a new one.
|
|
1858 |
new_dsc = self.factory.makeLibraryFileAlias(filename=dsc.filename) |
|
1859 |
pub.sourcepackagerelease.addFile(new_dsc) |
|
1860 |
self.assertEquals(new_dsc, self.archive.getFileByName(dsc.filename)) |
|
12505.4.1
by Robert Collins
Hopefully fix bug 727560 by permitting a much better query plan for folk querying the primary archive. |
1861 |
|
1862 |
||
1863 |
class TestGetPublishedSources(TestCaseWithFactory): |
|
1864 |
||
1865 |
layer = DatabaseFunctionalLayer |
|
1866 |
||
1867 |
def test_getPublishedSources_comprehensive(self): |
|
1868 |
# The doctests for getPublishedSources migrated from a doctest for
|
|
1869 |
# better testing.
|
|
1870 |
cprov = getUtility(IPersonSet).getByName('cprov') |
|
1871 |
cprov_archive = cprov.archive |
|
1872 |
# There are three published sources by default - no args returns all
|
|
1873 |
# publications.
|
|
1874 |
self.assertEqual(3, cprov_archive.getPublishedSources().count()) |
|
1875 |
# Various filters.
|
|
1876 |
active_status = [PackagePublishingStatus.PENDING, |
|
1877 |
PackagePublishingStatus.PUBLISHED] |
|
1878 |
inactive_status = [PackagePublishingStatus.SUPERSEDED, |
|
1879 |
PackagePublishingStatus.DELETED] |
|
1880 |
warty = cprov_archive.distribution['warty'] |
|
1881 |
hoary = cprov_archive.distribution['hoary'] |
|
1882 |
breezy_autotest = cprov_archive.distribution['breezy-autotest'] |
|
1883 |
all_sources = cprov_archive.getPublishedSources() |
|
1884 |
expected = [('cdrkit - 1.0', 'breezy-autotest'), |
|
1885 |
('iceweasel - 1.0', 'warty'), |
|
1886 |
('pmount - 0.1-1', 'warty'), |
|
1887 |
]
|
|
1888 |
found = [] |
|
1889 |
for pub in all_sources: |
|
1890 |
title = pub.sourcepackagerelease.title |
|
1891 |
pub_ds = pub.distroseries.name |
|
1892 |
found.append((title, pub_ds)) |
|
1893 |
self.assertEqual(expected, found) |
|
1894 |
self.assertEqual(1, |
|
1895 |
cprov_archive.getPublishedSources(name='cd').count()) |
|
1896 |
self.assertEqual(1, |
|
1897 |
cprov_archive.getPublishedSources(name='ice').count()) |
|
1898 |
self.assertEqual(1, cprov_archive.getPublishedSources( |
|
1899 |
name='iceweasel', exact_match=True).count()) |
|
1900 |
self.assertEqual(0, cprov_archive.getPublishedSources( |
|
1901 |
name='ice', exact_match=True).count()) |
|
1902 |
self.assertRaises(VersionRequiresName, |
|
1903 |
cprov_archive.getPublishedSources, |
|
1904 |
version='1.0') |
|
1905 |
self.assertEqual(1, cprov_archive.getPublishedSources( |
|
1906 |
name='ice', version='1.0').count()) |
|
1907 |
self.assertEqual(0, cprov_archive.getPublishedSources( |
|
1908 |
name='ice', version='666').count()) |
|
1909 |
self.assertEqual(3, cprov_archive.getPublishedSources( |
|
1910 |
status=PackagePublishingStatus.PUBLISHED).count()) |
|
1911 |
self.assertEqual(3, cprov_archive.getPublishedSources( |
|
1912 |
status=active_status).count()) |
|
1913 |
self.assertEqual(0, cprov_archive.getPublishedSources( |
|
1914 |
status=inactive_status).count()) |
|
1915 |
self.assertEqual(2, cprov_archive.getPublishedSources( |
|
1916 |
distroseries=warty).count()) |
|
1917 |
self.assertEqual(0, cprov_archive.getPublishedSources( |
|
1918 |
distroseries=hoary).count()) |
|
1919 |
self.assertEqual(1, cprov_archive.getPublishedSources( |
|
1920 |
distroseries=breezy_autotest).count()) |
|
1921 |
self.assertEqual(2, cprov_archive.getPublishedSources( |
|
1922 |
distroseries=warty, |
|
1923 |
pocket=PackagePublishingPocket.RELEASE).count()) |
|
1924 |
self.assertEqual(0, cprov_archive.getPublishedSources( |
|
1925 |
distroseries=warty, |
|
1926 |
pocket=PackagePublishingPocket.UPDATES).count()) |
|
1927 |
self.assertEqual(1, cprov_archive.getPublishedSources( |
|
1928 |
name='ice', distroseries=warty).count()) |
|
1929 |
self.assertEqual(0, cprov_archive.getPublishedSources( |
|
1930 |
name='ice', distroseries=breezy_autotest).count()) |
|
1931 |
self.assertEqual(0, cprov_archive.getPublishedSources( |
|
1932 |
created_since_date='2007-07-09 14:00:00').count()) |
|
1933 |
mid_2007 = datetime(year=2007, month=7, day=9, hour=14) |
|
1934 |
self.assertEqual(0, cprov_archive.getPublishedSources( |
|
1935 |
created_since_date=mid_2007).count()) |
|
1936 |
one_hour_step = timedelta(hours=1) |
|
1937 |
one_hour_earlier = mid_2007 - one_hour_step |
|
1938 |
self.assertEqual(1, cprov_archive.getPublishedSources( |
|
1939 |
created_since_date=one_hour_earlier).count()) |
|
1940 |
two_hours_earlier = one_hour_earlier - one_hour_step |
|
1941 |
self.assertEqual(3, cprov_archive.getPublishedSources( |
|
1942 |
created_since_date=two_hours_earlier).count()) |
|
13011.1.1
by William Grant
Test that ubuntu-security can use syncSource, not the DSD sync feature. |
1943 |
|
13168.12.25
by Raphael Badin
Refactor IArchive.getPublishedSources to remove the names parameter. |
1944 |
def test_getPublishedSources_name(self): |
13168.12.35
by Raphael Badin
Fix typo. |
1945 |
# The name parameter allows filtering with a list of
|
13168.12.23
by Raphael Badin
Refactor initialization to use the packagecopier if the destination archive is not empty. |
1946 |
# names.
|
13697.6.5
by Henning Eggers
Removed some lint. |
1947 |
distroseries = self.factory.makeDistroSeries() |
13168.12.23
by Raphael Badin
Refactor initialization to use the packagecopier if the destination archive is not empty. |
1948 |
# Create some SourcePackagePublishingHistory.
|
1949 |
for package_name in ['package1', 'package2', 'package3']: |
|
1950 |
self.factory.makeSourcePackagePublishingHistory( |
|
1951 |
distroseries=distroseries, |
|
1952 |
archive=distroseries.main_archive, |
|
1953 |
sourcepackagename=self.factory.makeSourcePackageName( |
|
1954 |
package_name)) |
|
1955 |
filtered_sources = distroseries.main_archive.getPublishedSources( |
|
13168.12.25
by Raphael Badin
Refactor IArchive.getPublishedSources to remove the names parameter. |
1956 |
name=['package1', 'package2']) |
13168.12.23
by Raphael Badin
Refactor initialization to use the packagecopier if the destination archive is not empty. |
1957 |
|
1958 |
self.assertEqual( |
|
1959 |
3, |
|
1960 |
distroseries.main_archive.getPublishedSources().count()) |
|
1961 |
self.assertEqual( |
|
1962 |
2, |
|
1963 |
filtered_sources.count()) |
|
1964 |
self.assertContentEqual( |
|
1965 |
['package1', 'package2'], |
|
1966 |
[filtered_source.sourcepackagerelease.name for filtered_source in |
|
1967 |
filtered_sources]) |
|
1968 |
||
13499.1.1
by Julian Edwards
write failing test |
1969 |
def test_getPublishedSources_multi_pockets(self): |
1970 |
# Passing an iterable of pockets should return publications
|
|
1971 |
# with any of them in.
|
|
13697.6.5
by Henning Eggers
Removed some lint. |
1972 |
distroseries = self.factory.makeDistroSeries() |
13499.1.5
by Julian Edwards
make test easier on the eye |
1973 |
pockets = [ |
1974 |
PackagePublishingPocket.RELEASE, |
|
1975 |
PackagePublishingPocket.UPDATES, |
|
1976 |
PackagePublishingPocket.BACKPORTS, |
|
1977 |
]
|
|
1978 |
for pocket in pockets: |
|
13499.1.1
by Julian Edwards
write failing test |
1979 |
self.factory.makeSourcePackagePublishingHistory( |
1980 |
sourcepackagename=pocket.name.lower(), |
|
1981 |
distroseries=distroseries, |
|
1982 |
archive=distroseries.main_archive, |
|
1983 |
pocket=pocket) |
|
13499.1.5
by Julian Edwards
make test easier on the eye |
1984 |
required_pockets = [ |
1985 |
PackagePublishingPocket.RELEASE, |
|
1986 |
PackagePublishingPocket.UPDATES, |
|
1987 |
]
|
|
13499.1.1
by Julian Edwards
write failing test |
1988 |
filtered = distroseries.main_archive.getPublishedSources( |
13499.1.5
by Julian Edwards
make test easier on the eye |
1989 |
pocket=required_pockets) |
13499.1.1
by Julian Edwards
write failing test |
1990 |
|
1991 |
self.assertContentEqual( |
|
13697.6.5
by Henning Eggers
Removed some lint. |
1992 |
[PackagePublishingPocket.RELEASE, |
1993 |
PackagePublishingPocket.UPDATES], |
|
13499.1.1
by Julian Edwards
write failing test |
1994 |
[source.pocket for source in filtered]) |
1995 |
||
13011.1.1
by William Grant
Test that ubuntu-security can use syncSource, not the DSD sync feature. |
1996 |
|
13410.1.28
by Julian Edwards
Add (failing) test. |
1997 |
class TestSyncSourceFeatureFlag(TestCaseWithFactory): |
1998 |
||
1999 |
layer = DatabaseFunctionalLayer |
|
2000 |
||
2001 |
def test_copyPackage_requires_feature_flag(self): |
|
2002 |
# Ensure feature is off.
|
|
2003 |
self.useFixture(FeatureFixture({u"soyuz.copypackage.enabled": ''})) |
|
13482.3.1
by Julian Edwards
prevent the use of copyPackage with a PPA destination |
2004 |
archive = self.factory.makeArchive(purpose=ArchivePurpose.PRIMARY) |
13410.1.28
by Julian Edwards
Add (failing) test. |
2005 |
self.assertRaises( |
2006 |
ForbiddenByFeatureFlag, |
|
2007 |
archive.copyPackage, |
|
2008 |
None, None, None, None, None) |
|
2009 |
||
13410.1.30
by Julian Edwards
Add failing test for copyPackages |
2010 |
def test_copyPackages_requires_feature_flag(self): |
2011 |
# Ensure feature is off.
|
|
2012 |
self.useFixture(FeatureFixture({u"soyuz.copypackage.enabled": ''})) |
|
13482.3.1
by Julian Edwards
prevent the use of copyPackage with a PPA destination |
2013 |
archive = self.factory.makeArchive(purpose=ArchivePurpose.PRIMARY) |
2014 |
self.assertRaises( |
|
2015 |
ForbiddenByFeatureFlag, |
|
2016 |
archive.copyPackages, |
|
2017 |
None, None, None, None, None) |
|
2018 |
||
2019 |
def test_copyPackage_to_ppa_requires_feature_flag(self): |
|
2020 |
# Ensure feature is off.
|
|
2021 |
self.useFixture(FeatureFixture({u"soyuz.copypackage.enabled": 'on'})) |
|
2022 |
self.useFixture(FeatureFixture({u"soyuz.copypackageppa.enabled": ''})) |
|
2023 |
archive = self.factory.makeArchive(purpose=ArchivePurpose.PPA) |
|
2024 |
self.assertRaises( |
|
2025 |
ForbiddenByFeatureFlag, |
|
2026 |
archive.copyPackage, |
|
2027 |
None, None, None, None, None) |
|
2028 |
||
2029 |
def test_copyPackages_to_ppa_requires_feature_flag(self): |
|
2030 |
# Ensure feature is off.
|
|
2031 |
self.useFixture(FeatureFixture({u"soyuz.copypackage.enabled": 'on'})) |
|
2032 |
self.useFixture(FeatureFixture({u"soyuz.copypackageppa.enabled": ''})) |
|
2033 |
archive = self.factory.makeArchive(purpose=ArchivePurpose.PPA) |
|
13410.1.30
by Julian Edwards
Add failing test for copyPackages |
2034 |
self.assertRaises( |
2035 |
ForbiddenByFeatureFlag, |
|
2036 |
archive.copyPackages, |
|
2037 |
None, None, None, None, None) |
|
2038 |
||
13410.1.28
by Julian Edwards
Add (failing) test. |
2039 |
|
13011.1.1
by William Grant
Test that ubuntu-security can use syncSource, not the DSD sync feature. |
2040 |
class TestSyncSource(TestCaseWithFactory): |
2041 |
||
2042 |
layer = DatabaseFunctionalLayer |
|
2043 |
||
13410.1.32
by Julian Edwards
Make sure existing copypackage tests get the feature flag enabled. |
2044 |
def setUp(self): |
2045 |
super(TestSyncSource, self).setUp() |
|
13482.3.2
by Julian Edwards
Use FeatureFixture properly |
2046 |
self.useFixture(FeatureFixture({ |
2047 |
u"soyuz.copypackage.enabled": 'on', |
|
2048 |
u"soyuz.copypackageppa.enabled": 'on', |
|
2049 |
}))
|
|
13410.1.32
by Julian Edwards
Make sure existing copypackage tests get the feature flag enabled. |
2050 |
|
13011.1.1
by William Grant
Test that ubuntu-security can use syncSource, not the DSD sync feature. |
2051 |
def test_security_team_can_copy_to_primary(self): |
2052 |
# A member of ubuntu-security can use syncSource on any package
|
|
2053 |
# in the Ubuntu primary archive, regardless of their normal
|
|
2054 |
# upload permissions.
|
|
2055 |
# This is until we can open syncSource up more widely and sort
|
|
2056 |
# out the permissions that everyone needs.
|
|
2057 |
with celebrity_logged_in('admin'): |
|
2058 |
security_person = self.factory.makePerson() |
|
2059 |
getUtility(ILaunchpadCelebrities).ubuntu_security.addMember( |
|
2060 |
security_person, security_person) |
|
2061 |
ubuntu = getUtility(ILaunchpadCelebrities).ubuntu |
|
2062 |
source = self.factory.makeSourcePackagePublishingHistory( |
|
2063 |
archive=self.factory.makeArchive(purpose=ArchivePurpose.PPA), |
|
2064 |
distroseries=ubuntu.currentseries) |
|
2065 |
self.assertEqual( |
|
2066 |
0, |
|
2067 |
ubuntu.main_archive.getPublishedSources( |
|
2068 |
name=source.source_package_name).count()) |
|
2069 |
with person_logged_in(security_person): |
|
2070 |
ubuntu.main_archive.syncSource( |
|
2071 |
source_name=source.source_package_name, |
|
2072 |
version=source.source_package_version, |
|
2073 |
from_archive=source.archive, |
|
2074 |
to_pocket='Security') |
|
2075 |
self.assertEqual( |
|
2076 |
1, |
|
2077 |
ubuntu.main_archive.getPublishedSources( |
|
2078 |
name=source.source_package_name).count()) |
|
13410.1.1
by Julian Edwards
Add a test for the yet unwritten copyPackage. |
2079 |
|
13410.1.5
by Julian Edwards
Add test showing non-primary-archive uploaders get rejected. |
2080 |
def _setup_copy_data(self, target_purpose=None): |
2081 |
if target_purpose is None: |
|
2082 |
target_purpose = ArchivePurpose.PPA |
|
13410.1.1
by Julian Edwards
Add a test for the yet unwritten copyPackage. |
2083 |
source_archive = self.factory.makeArchive() |
13410.1.5
by Julian Edwards
Add test showing non-primary-archive uploaders get rejected. |
2084 |
target_archive = self.factory.makeArchive(purpose=target_purpose) |
13410.1.1
by Julian Edwards
Add a test for the yet unwritten copyPackage. |
2085 |
source = self.factory.makeSourcePackagePublishingHistory( |
13410.1.18
by Julian Edwards
Add first test of basic usage with a single source. |
2086 |
archive=source_archive, status=PackagePublishingStatus.PUBLISHED) |
13410.1.1
by Julian Edwards
Add a test for the yet unwritten copyPackage. |
2087 |
source_name = source.source_package_name |
13410.1.2
by Julian Edwards
Add initial implementation. |
2088 |
version = source.source_package_version |
2089 |
to_pocket = PackagePublishingPocket.RELEASE |
|
13410.1.1
by Julian Edwards
Add a test for the yet unwritten copyPackage. |
2090 |
to_series = self.factory.makeDistroSeries( |
2091 |
distribution=target_archive.distribution) |
|
13410.1.3
by Julian Edwards
Move the interface declaration to IArchiveView and implement direct upload |
2092 |
return (source, source_archive, source_name, target_archive, |
2093 |
to_pocket, to_series, version) |
|
2094 |
||
2095 |
def test_copyPackage_creates_packagecopyjob(self): |
|
2096 |
# The copyPackage method should create a PCJ with the appropriate
|
|
2097 |
# parameters.
|
|
2098 |
(source, source_archive, source_name, target_archive, to_pocket, |
|
2099 |
to_series, version) = self._setup_copy_data() |
|
13410.1.2
by Julian Edwards
Add initial implementation. |
2100 |
with person_logged_in(target_archive.owner): |
2101 |
target_archive.copyPackage( |
|
13410.1.10
by Julian Edwards
Woops, change params so textual names are passed instead, like syncSource. |
2102 |
source_name, version, source_archive, to_pocket.name, |
2103 |
to_series=to_series.name, include_binaries=False, |
|
13410.1.3
by Julian Edwards
Move the interface declaration to IArchiveView and implement direct upload |
2104 |
person=target_archive.owner) |
13410.1.1
by Julian Edwards
Add a test for the yet unwritten copyPackage. |
2105 |
|
2106 |
# The source should not be published yet in the target_archive.
|
|
2107 |
published = target_archive.getPublishedSources( |
|
2108 |
name=source.source_package_name).any() |
|
2109 |
self.assertIs(None, published) |
|
2110 |
||
2111 |
# There should be one copy job.
|
|
2112 |
job_source = getUtility(IPlainPackageCopyJobSource) |
|
2113 |
copy_job = job_source.getActiveJobs(target_archive).one() |
|
2114 |
||
2115 |
# Its data should reflect the requested copy.
|
|
13697.6.3
by Henning Eggers
Use MatchesStructure.byEquality. |
2116 |
self.assertThat(copy_job, MatchesStructure.byEquality( |
2117 |
package_name=source_name, |
|
2118 |
package_version=version, |
|
2119 |
target_archive=target_archive, |
|
2120 |
source_archive=source_archive, |
|
2121 |
target_distroseries=to_series, |
|
2122 |
target_pocket=to_pocket, |
|
2123 |
include_binaries=False, |
|
2124 |
copy_policy=PackageCopyPolicy.INSECURE)) |
|
13410.1.3
by Julian Edwards
Move the interface declaration to IArchiveView and implement direct upload |
2125 |
|
13410.1.5
by Julian Edwards
Add test showing non-primary-archive uploaders get rejected. |
2126 |
def test_copyPackage_disallows_non_primary_archive_uploaders(self): |
2127 |
# If copying to a primary archive and you're not an uploader for
|
|
2128 |
# the package then you can't copy.
|
|
2129 |
(source, source_archive, source_name, target_archive, to_pocket, |
|
2130 |
to_series, version) = self._setup_copy_data( |
|
2131 |
target_purpose=ArchivePurpose.PRIMARY) |
|
2132 |
person = self.factory.makePerson() |
|
2133 |
self.assertRaises( |
|
2134 |
CannotCopy, |
|
2135 |
target_archive.copyPackage, source_name, version, source_archive, |
|
13410.1.10
by Julian Edwards
Woops, change params so textual names are passed instead, like syncSource. |
2136 |
to_pocket.name, to_series=to_series.name, include_binaries=False, |
13410.1.5
by Julian Edwards
Add test showing non-primary-archive uploaders get rejected. |
2137 |
person=person) |
2138 |
||
13410.1.6
by Julian Edwards
Add test showing primary-archive uploaders are allowed. |
2139 |
def test_copyPackage_allows_primary_archive_uploaders(self): |
2140 |
# Copying to a primary archive if you're already an uploader is OK.
|
|
2141 |
(source, source_archive, source_name, target_archive, to_pocket, |
|
2142 |
to_series, version) = self._setup_copy_data( |
|
2143 |
target_purpose=ArchivePurpose.PRIMARY) |
|
2144 |
person = self.factory.makePerson() |
|
13730.1.7
by Julian Edwards
re-merge backed-out revision |
2145 |
with person_logged_in(target_archive.distribution.owner): |
13410.1.6
by Julian Edwards
Add test showing primary-archive uploaders are allowed. |
2146 |
target_archive.newComponentUploader(person, "universe") |
2147 |
target_archive.copyPackage( |
|
13410.1.10
by Julian Edwards
Woops, change params so textual names are passed instead, like syncSource. |
2148 |
source_name, version, source_archive, to_pocket.name, |
2149 |
to_series=to_series.name, include_binaries=False, |
|
13410.1.6
by Julian Edwards
Add test showing primary-archive uploaders are allowed. |
2150 |
person=person) |
2151 |
||
2152 |
# There should be one copy job.
|
|
2153 |
job_source = getUtility(IPlainPackageCopyJobSource) |
|
2154 |
copy_job = job_source.getActiveJobs(target_archive).one() |
|
2155 |
self.assertEqual(target_archive, copy_job.target_archive) |
|
13410.1.5
by Julian Edwards
Add test showing non-primary-archive uploaders get rejected. |
2156 |
|
13410.1.3
by Julian Edwards
Move the interface declaration to IArchiveView and implement direct upload |
2157 |
def test_copyPackage_disallows_non_PPA_owners(self): |
2158 |
# Only people with launchpad.Append are allowed to call copyPackage.
|
|
2159 |
(source, source_archive, source_name, target_archive, to_pocket, |
|
2160 |
to_series, version) = self._setup_copy_data() |
|
2161 |
person = self.factory.makePerson() |
|
13410.1.4
by Julian Edwards
Add test showing non-release pocket copies in PPAs are disallowed immediately. |
2162 |
self.assertTrue(target_archive.is_ppa) |
2163 |
self.assertRaises( |
|
2164 |
CannotCopy, |
|
2165 |
target_archive.copyPackage, source_name, version, source_archive, |
|
13410.1.10
by Julian Edwards
Woops, change params so textual names are passed instead, like syncSource. |
2166 |
to_pocket.name, to_series=to_series.name, include_binaries=False, |
13410.1.4
by Julian Edwards
Add test showing non-release pocket copies in PPAs are disallowed immediately. |
2167 |
person=person) |
2168 |
||
2169 |
def test_copyPackage_disallows_non_release_target_pocket_for_PPA(self): |
|
2170 |
(source, source_archive, source_name, target_archive, to_pocket, |
|
2171 |
to_series, version) = self._setup_copy_data() |
|
2172 |
to_pocket = PackagePublishingPocket.UPDATES |
|
2173 |
self.assertTrue(target_archive.is_ppa) |
|
2174 |
self.assertRaises( |
|
2175 |
CannotCopy, |
|
2176 |
target_archive.copyPackage, source_name, version, source_archive, |
|
13410.1.10
by Julian Edwards
Woops, change params so textual names are passed instead, like syncSource. |
2177 |
to_pocket.name, to_series=to_series.name, include_binaries=False, |
13410.1.4
by Julian Edwards
Add test showing non-release pocket copies in PPAs are disallowed immediately. |
2178 |
person=target_archive.owner) |
2179 |
||
13410.1.18
by Julian Edwards
Add first test of basic usage with a single source. |
2180 |
def test_copyPackages_with_single_package(self): |
2181 |
(source, source_archive, source_name, target_archive, to_pocket, |
|
2182 |
to_series, version) = self._setup_copy_data() |
|
2183 |
||
2184 |
with person_logged_in(target_archive.owner): |
|
2185 |
target_archive.copyPackages( |
|
2186 |
[source_name], source_archive, to_pocket.name, |
|
2187 |
to_series=to_series.name, include_binaries=False, |
|
2188 |
person=target_archive.owner) |
|
2189 |
||
2190 |
# The source should not be published yet in the target_archive.
|
|
2191 |
published = target_archive.getPublishedSources( |
|
2192 |
name=source.source_package_name).any() |
|
2193 |
self.assertIs(None, published) |
|
2194 |
||
2195 |
# There should be one copy job.
|
|
2196 |
job_source = getUtility(IPlainPackageCopyJobSource) |
|
2197 |
copy_job = job_source.getActiveJobs(target_archive).one() |
|
13697.6.3
by Henning Eggers
Use MatchesStructure.byEquality. |
2198 |
self.assertThat(copy_job, MatchesStructure.byEquality( |
2199 |
package_name=source_name, |
|
2200 |
package_version=version, |
|
2201 |
target_archive=target_archive, |
|
2202 |
source_archive=source_archive, |
|
2203 |
target_distroseries=to_series, |
|
2204 |
target_pocket=to_pocket, |
|
2205 |
include_binaries=False, |
|
2206 |
copy_policy=PackageCopyPolicy.MASS_SYNC)) |
|
13410.1.18
by Julian Edwards
Add first test of basic usage with a single source. |
2207 |
|
13410.1.19
by Julian Edwards
Loads more test cases. |
2208 |
def test_copyPackages_with_multiple_packages(self): |
13576.1.1
by Julian Edwards
Make a failing test. |
2209 |
# PENDING and PUBLISHED packages should both be copied.
|
13410.1.19
by Julian Edwards
Loads more test cases. |
2210 |
(source, source_archive, source_name, target_archive, to_pocket, |
2211 |
to_series, version) = self._setup_copy_data() |
|
2212 |
sources = [source] |
|
2213 |
sources.append(self.factory.makeSourcePackagePublishingHistory( |
|
2214 |
archive=source_archive, |
|
13576.1.1
by Julian Edwards
Make a failing test. |
2215 |
status=PackagePublishingStatus.PENDING)) |
13410.1.19
by Julian Edwards
Loads more test cases. |
2216 |
sources.append(self.factory.makeSourcePackagePublishingHistory( |
2217 |
archive=source_archive, |
|
2218 |
status=PackagePublishingStatus.PUBLISHED)) |
|
2219 |
names = [source.sourcepackagerelease.sourcepackagename.name |
|
2220 |
for source in sources] |
|
2221 |
||
2222 |
with person_logged_in(target_archive.owner): |
|
2223 |
target_archive.copyPackages( |
|
2224 |
names, source_archive, to_pocket.name, |
|
2225 |
to_series=to_series.name, include_binaries=False, |
|
2226 |
person=target_archive.owner) |
|
2227 |
||
2228 |
# Make sure three copy jobs exist.
|
|
2229 |
job_source = getUtility(IPlainPackageCopyJobSource) |
|
2230 |
copy_jobs = job_source.getActiveJobs(target_archive) |
|
2231 |
self.assertEqual(3, copy_jobs.count()) |
|
2232 |
||
2233 |
def test_copyPackages_disallows_non_primary_archive_uploaders(self): |
|
2234 |
# If copying to a primary archive and you're not an uploader for
|
|
2235 |
# the package then you can't copy.
|
|
2236 |
(source, source_archive, source_name, target_archive, to_pocket, |
|
2237 |
to_series, version) = self._setup_copy_data( |
|
2238 |
target_purpose=ArchivePurpose.PRIMARY) |
|
2239 |
person = self.factory.makePerson() |
|
2240 |
self.assertRaises( |
|
2241 |
CannotCopy, |
|
2242 |
target_archive.copyPackages, [source_name], source_archive, |
|
2243 |
to_pocket.name, to_series=to_series.name, include_binaries=False, |
|
2244 |
person=person) |
|
2245 |
||
2246 |
def test_copyPackages_allows_primary_archive_uploaders(self): |
|
2247 |
# Copying to a primary archive if you're already an uploader is OK.
|
|
2248 |
(source, source_archive, source_name, target_archive, to_pocket, |
|
2249 |
to_series, version) = self._setup_copy_data( |
|
2250 |
target_purpose=ArchivePurpose.PRIMARY) |
|
2251 |
person = self.factory.makePerson() |
|
13730.1.7
by Julian Edwards
re-merge backed-out revision |
2252 |
with person_logged_in(target_archive.distribution.owner): |
13410.1.19
by Julian Edwards
Loads more test cases. |
2253 |
target_archive.newComponentUploader(person, "universe") |
2254 |
target_archive.copyPackages( |
|
2255 |
[source_name], source_archive, to_pocket.name, |
|
2256 |
to_series=to_series.name, include_binaries=False, |
|
2257 |
person=person) |
|
2258 |
||
2259 |
# There should be one copy job.
|
|
2260 |
job_source = getUtility(IPlainPackageCopyJobSource) |
|
2261 |
copy_job = job_source.getActiveJobs(target_archive).one() |
|
2262 |
self.assertEqual(target_archive, copy_job.target_archive) |
|
2263 |
||
2264 |
def test_copyPackages_disallows_non_PPA_owners(self): |
|
2265 |
# Only people with launchpad.Append are allowed to call copyPackage.
|
|
2266 |
(source, source_archive, source_name, target_archive, to_pocket, |
|
2267 |
to_series, version) = self._setup_copy_data() |
|
2268 |
person = self.factory.makePerson() |
|
2269 |
self.assertTrue(target_archive.is_ppa) |
|
2270 |
self.assertRaises( |
|
2271 |
CannotCopy, |
|
2272 |
target_archive.copyPackages, [source_name], source_archive, |
|
2273 |
to_pocket.name, to_series=to_series.name, include_binaries=False, |
|
2274 |
person=person) |
|
13765.2.1
by Benji York
permissions that are already removed can be removed again |
2275 |
|
2276 |
||
2277 |
class TestRemovingPermissions(TestCaseWithFactory): |
|
2278 |
||
2279 |
layer = DatabaseFunctionalLayer |
|
2280 |
||
2281 |
def test_remove_permission_is_none(self): |
|
2282 |
# Several API functions remove permissions if they are not already
|
|
2283 |
# removed. This verifies that the underlying utility function does
|
|
2284 |
# not generate an error if the permission is None.
|
|
2285 |
ap_set = ArchivePermissionSet() |
|
2286 |
ap_set._remove_permission(None) |