223
226
# Calling series_with_sources returns all series with publishings.
224
227
distribution = self.factory.makeDistribution()
225
228
archive = self.factory.makeArchive(distribution=distribution)
226
series_with_no_sources = self.factory.makeDistroSeries(
229
self.factory.makeDistroSeries(
227
230
distribution=distribution, version="0.5")
228
231
series_with_sources1 = self.factory.makeDistroSeries(
229
232
distribution=distribution, version="1")
425
428
other_spn = self.factory.makeSourcePackageName(name="bar")
426
429
archive = self.factory.makeArchive()
427
430
self.makePublishedSources(archive,
428
[PackagePublishingStatus.PUBLISHED]*3,
431
[PackagePublishingStatus.PUBLISHED] * 3,
429
432
["1.0", "1.1", "2.0"],
430
433
[sourcepackagename, sourcepackagename, other_spn])
431
434
pubs = removeSecurityProxy(archive)._collectLatestPublishedSources(
1299
1302
self.assertTrue(self.archive.build_debug_symbols)
1305
class TestAddArchiveDependencies(TestCaseWithFactory):
1307
layer = DatabaseFunctionalLayer
1309
def test_add_hidden_dependency(self):
1310
# The user cannot add a dependency on an archive they cannot see.
1311
archive = self.factory.makeArchive(private=True)
1312
dependency = self.factory.makeArchive(private=True)
1313
with person_logged_in(archive.owner):
1314
with ExpectedException(
1315
ArchiveDependencyError,
1316
"You don't have permission to use this dependency."):
1317
archive.addArchiveDependency(dependency, 'foo')
1319
def test_private_dependency_public_archive(self):
1320
# A public archive may not depend on a private archive.
1321
archive = self.factory.makeArchive()
1322
dependency = self.factory.makeArchive(
1323
private=True, owner=archive.owner)
1324
with person_logged_in(archive.owner):
1325
with ExpectedException(
1326
ArchiveDependencyError,
1327
"Public PPAs cannot depend on private ones."):
1328
archive.addArchiveDependency(dependency, 'foo')
1330
def test_add_private_dependency(self):
1331
# The user can add a dependency on private archive they can see.
1332
archive = self.factory.makeArchive(private=True)
1333
dependency = self.factory.makeArchive(
1334
private=True, owner=archive.owner)
1335
with person_logged_in(archive.owner):
1336
archive_dependency = archive.addArchiveDependency(dependency,
1337
PackagePublishingPocket.RELEASE)
1338
self.assertContentEqual(
1339
archive.dependencies, [archive_dependency])
1342
class TestArchiveDependencies(TestCaseWithFactory):
1344
layer = LaunchpadZopelessLayer
1346
def test_private_sources_list(self):
1347
"""Entries for private dependencies include credentials."""
1348
p3a = self.factory.makeArchive(name='p3a', private=True)
1349
dependency = self.factory.makeArchive(
1350
name='dependency', private=True, owner=p3a.owner)
1351
with person_logged_in(p3a.owner):
1352
bpph = self.factory.makeBinaryPackagePublishingHistory(
1353
archive=dependency, status=PackagePublishingStatus.PUBLISHED)
1354
p3a.addArchiveDependency(dependency,
1355
PackagePublishingPocket.RELEASE)
1356
build = self.factory.makeBinaryPackageBuild(archive=p3a,
1357
distroarchseries=bpph.distroarchseries)
1358
sources_list = get_sources_list_for_building(
1359
build, build.distro_arch_series,
1360
build.source_package_release.name)
1361
sources_list_str = '\n'.join(sources_list)
1362
matches = MatchesRegex(
1363
"deb http://buildd:sekrit@private-ppa.launchpad.dev/"
1364
"person-name-.*/dependency/ubuntu distroseries-.* main")
1365
self.assertThat(sources_list[0], matches)
1302
1368
class TestFindDepCandidates(TestCaseWithFactory):
1303
1369
"""Tests for Archive.findDepCandidates."""
1572
1638
def test_two_ppas_with_team(self):
1573
1639
team = self.factory.makeTeam(
1574
1640
subscription_policy=TeamSubscriptionPolicy.MODERATED)
1575
ppa = self.factory.makeArchive(owner=team, name='ppa')
1641
self.factory.makeArchive(owner=team, name='ppa')
1576
1642
self.assertEqual("%s already has a PPA named 'ppa'." % (
1577
1643
team.displayname), Archive.validatePPA(team, 'ppa'))