本文整理匯總了Python中lp.soyuz.tests.test_publishing.SoyuzTestPublisher.addFakeChroots方法的典型用法代碼示例。如果您正苦於以下問題:Python SoyuzTestPublisher.addFakeChroots方法的具體用法?Python SoyuzTestPublisher.addFakeChroots怎麽用?Python SoyuzTestPublisher.addFakeChroots使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類lp.soyuz.tests.test_publishing.SoyuzTestPublisher
的用法示例。
在下文中一共展示了SoyuzTestPublisher.addFakeChroots方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_copy_archive_without_leak
# 需要導入模塊: from lp.soyuz.tests.test_publishing import SoyuzTestPublisher [as 別名]
# 或者: from lp.soyuz.tests.test_publishing.SoyuzTestPublisher import addFakeChroots [as 別名]
def test_copy_archive_without_leak(self):
# If source publications are copied to a .COPY archive, they don't
# "leak" into SourcePackage.getBuildRecords().
admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
# Set up a distroseries and related bits, so we can create builds.
source_name = self.factory.getUniqueString()
spn = self.factory.makeSourcePackageName(name=source_name)
processor = self.factory.makeProcessor()
distroseries = self.factory.makeDistroSeries()
das = self.factory.makeDistroArchSeries(
distroseries=distroseries, processor=processor,
supports_virtualized=True)
with person_logged_in(admin):
publisher = SoyuzTestPublisher()
publisher.prepareBreezyAutotest()
publisher.addFakeChroots(distroseries=distroseries)
distroseries.nominatedarchindep = das
self.factory.makeBuilder(processor=processor)
spph = self.factory.makeSourcePackagePublishingHistory(
sourcepackagename=spn, distroseries=distroseries)
spph.createMissingBuilds()
# Create a copy archive.
copy = self.factory.makeArchive(
purpose=ArchivePurpose.COPY,
distribution=distroseries.distribution)
# And copy the publication into it.
copy_spph = spph.copyTo(
distroseries, PackagePublishingPocket.RELEASE, copy)
[copy_build] = copy_spph.createMissingBuilds()
builds = copy.getBuildRecords()
self.assertEquals([copy_build], list(builds))
source = SourcePackage(spn, spph.distroseries)
# SourcePackage.getBuildRecords() doesn't have two build records.
builds = source.getBuildRecords().count()
self.assertEquals(1, builds)
示例2: setUp
# 需要導入模塊: from lp.soyuz.tests.test_publishing import SoyuzTestPublisher [as 別名]
# 或者: from lp.soyuz.tests.test_publishing.SoyuzTestPublisher import addFakeChroots [as 別名]
def setUp(self):
super(TestBuildPrivacy, self).setUp()
# Add everything we need to create builds.
self.admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
processor = self.factory.makeProcessor()
distroseries = self.factory.makeDistroSeries()
das = self.factory.makeDistroArchSeries(
distroseries=distroseries, processor=processor,
supports_virtualized=True)
with person_logged_in(self.admin):
publisher = SoyuzTestPublisher()
publisher.prepareBreezyAutotest()
distroseries.nominatedarchindep = das
publisher.addFakeChroots(distroseries=distroseries)
self.factory.makeBuilder(processor=processor)
self.public_archive = self.factory.makeArchive()
self.private_archive = self.factory.makeArchive(private=True)
# Create one public and one private build.
public_spph = publisher.getPubSource(
sourcename=self.factory.getUniqueString(),
version="%s.1" % self.factory.getUniqueInteger(),
distroseries=distroseries, archive=self.public_archive)
[public_build] = public_spph.createMissingBuilds()
private_spph = publisher.getPubSource(
sourcename=self.factory.getUniqueString(),
version="%s.1" % self.factory.getUniqueInteger(),
distroseries=distroseries, archive=self.private_archive)
with person_logged_in(self.admin):
[private_build] = private_spph.createMissingBuilds()
self.expected_title = '%s build of %s %s in %s %s RELEASE' % (
das.architecturetag, private_spph.source_package_name,
private_spph.source_package_version,
distroseries.distribution.name, distroseries.name)
示例3: test_dispatchBuildToSlave
# 需要導入模塊: from lp.soyuz.tests.test_publishing import SoyuzTestPublisher [as 別名]
# 或者: from lp.soyuz.tests.test_publishing.SoyuzTestPublisher import addFakeChroots [as 別名]
def test_dispatchBuildToSlave(self):
# Ensure dispatchBuildToSlave will make the right calls to the slave
job = self.makeJob()
test_publisher = SoyuzTestPublisher()
test_publisher.addFakeChroots(job.build.distroseries)
slave = OkSlave()
builder = MockBuilder("bob-de-bouwer")
builder.processor = getUtility(IProcessorSet).getByName("386")
job.setBuilder(builder, slave)
logger = BufferLogger()
d = defer.maybeDeferred(job.dispatchBuildToSlave, "someid", logger)
def check_dispatch(ignored):
self.assertThat(
logger.getLogBuffer(),
StartsWith(
dedent(
"""\
INFO Sending chroot file for recipe build to bob-de-bouwer
INFO Initiating build 1-someid on http://fake:0000
"""
)
),
)
self.assertEquals(["ensurepresent", "build"], [call[0] for call in slave.call_log])
build_args = slave.call_log[1][1:]
self.assertEquals(build_args[0], job.getBuildCookie())
self.assertEquals(build_args[1], "sourcepackagerecipe")
self.assertEquals(build_args[3], [])
distroarchseries = job.build.distroseries.architectures[0]
self.assertEqual(build_args[4], job._extraBuildArgs(distroarchseries))
return d.addCallback(check_dispatch)
示例4: TestBuildStartEstimation
# 需要導入模塊: from lp.soyuz.tests.test_publishing import SoyuzTestPublisher [as 別名]
# 或者: from lp.soyuz.tests.test_publishing.SoyuzTestPublisher import addFakeChroots [as 別名]
class TestBuildStartEstimation(TestCaseWithFactory):
layer = LaunchpadFunctionalLayer
def setUp(self):
super(TestBuildStartEstimation, self).setUp()
self.admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
with person_logged_in(self.admin):
self.publisher = SoyuzTestPublisher()
self.publisher.prepareBreezyAutotest()
for buildd in getUtility(IBuilderSet):
buildd.builderok = True
self.distroseries = self.factory.makeDistroSeries()
self.bob = getUtility(IBuilderSet).getByName(BOB_THE_BUILDER_NAME)
das = self.factory.makeDistroArchSeries(
distroseries=self.distroseries, processor=self.bob.processor,
architecturetag='i386', supports_virtualized=True)
with person_logged_in(self.admin):
self.distroseries.nominatedarchindep = das
self.publisher.addFakeChroots(distroseries=self.distroseries)
def job_start_estimate(self, build):
return build.buildqueue_record.getEstimatedJobStartTime()
def test_estimation(self):
pkg = self.publisher.getPubSource(
sourcename=self.factory.getUniqueString(),
distroseries=self.distroseries)
build = pkg.createMissingBuilds()[0]
now = datetime.now(pytz.UTC)
estimate = self.job_start_estimate(build)
self.assertTrue(estimate > now)
def test_disabled_archives(self):
pkg1 = self.publisher.getPubSource(
sourcename=self.factory.getUniqueString(),
distroseries=self.distroseries)
[build1] = pkg1.createMissingBuilds()
build1.buildqueue_record.lastscore = 1000
# No user-serviceable parts inside
removeSecurityProxy(build1.buildqueue_record).estimated_duration = (
timedelta(minutes=10))
pkg2 = self.publisher.getPubSource(
sourcename=self.factory.getUniqueString(),
distroseries=self.distroseries)
[build2] = pkg2.createMissingBuilds()
build2.buildqueue_record.lastscore = 100
now = datetime.now(pytz.UTC)
# Since build1 is higher priority, it's estimated dispatch time is now
estimate = self.job_start_estimate(build1)
self.assertEquals(5, (estimate - now).seconds)
# And build2 is next, so must take build1's duration into account
estimate = self.job_start_estimate(build2)
self.assertEquals(600, (estimate - now).seconds)
# If we disable build1's archive, build2 is next
with person_logged_in(self.admin):
build1.archive.disable()
estimate = self.job_start_estimate(build2)
self.assertEquals(5, (estimate - now).seconds)
示例5: TestDistributionHasBuildRecords
# 需要導入模塊: from lp.soyuz.tests.test_publishing import SoyuzTestPublisher [as 別名]
# 或者: from lp.soyuz.tests.test_publishing.SoyuzTestPublisher import addFakeChroots [as 別名]
class TestDistributionHasBuildRecords(TestCaseWithFactory):
"""Populate a distroseries with builds"""
layer = LaunchpadZopelessLayer
def setUp(self):
super(TestDistributionHasBuildRecords, self).setUp()
self.admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
# Create the machinery we need to create builds, such as
# DistroArchSeries and builders.
self.processor_one = self.factory.makeProcessor()
self.processor_two = self.factory.makeProcessor()
self.distroseries = self.factory.makeDistroSeries()
self.distribution = self.distroseries.distribution
self.das_one = self.factory.makeDistroArchSeries(
distroseries=self.distroseries, processor=self.processor_one,
supports_virtualized=True)
self.das_two = self.factory.makeDistroArchSeries(
distroseries=self.distroseries, processor=self.processor_two,
supports_virtualized=True)
self.archive = self.factory.makeArchive(
distribution=self.distroseries.distribution,
purpose=ArchivePurpose.PRIMARY)
self.arch_ids = [arch.id for arch in self.distroseries.architectures]
with person_logged_in(self.admin):
self.publisher = SoyuzTestPublisher()
self.publisher.prepareBreezyAutotest()
self.distroseries.nominatedarchindep = self.das_one
self.publisher.addFakeChroots(distroseries=self.distroseries)
self.builder_one = self.factory.makeBuilder(
processor=self.processor_one)
self.builder_two = self.factory.makeBuilder(
processor=self.processor_two)
self.builds = []
self.createBuilds()
def createBuilds(self):
for i in range(5):
# Create some test builds.
spph = self.publisher.getPubSource(
sourcename=self.factory.getUniqueString(),
version="%s.%s" % (self.factory.getUniqueInteger(), i),
distroseries=self.distroseries, architecturehintlist='any')
builds = spph.createMissingBuilds()
for b in builds:
b.updateStatus(BuildStatus.BUILDING)
if i == 4:
b.updateStatus(BuildStatus.FAILEDTOBUILD)
else:
b.updateStatus(BuildStatus.FULLYBUILT)
b.buildqueue_record.destroySelf()
self.builds += builds
def test_get_build_records(self):
# A Distribution also implements IHasBuildRecords.
builds = self.distribution.getBuildRecords().count()
self.assertEquals(10, builds)
示例6: _prepareMergeCopy
# 需要導入模塊: from lp.soyuz.tests.test_publishing import SoyuzTestPublisher [as 別名]
# 或者: from lp.soyuz.tests.test_publishing.SoyuzTestPublisher import addFakeChroots [as 別名]
def _prepareMergeCopy(self):
"""Add a fresher and a new package to ubuntu/hoary.
This is used to test merge copy functionality."""
test_publisher = SoyuzTestPublisher()
ubuntu = getUtility(IDistributionSet).getByName('ubuntu')
hoary = ubuntu.getSeries('hoary')
test_publisher.addFakeChroots(hoary)
test_publisher.setUpDefaultDistroSeries(hoary)
test_publisher.getPubSource(
sourcename="new-in-second-round", version="1.0",
distroseries=hoary, archive=ubuntu.main_archive)
test_publisher.getPubSource(
sourcename="alsa-utils", version="2.0", distroseries=hoary,
archive=ubuntu.main_archive)
sources = ubuntu.main_archive.getPublishedSources(
distroseries=hoary, status=self.pending_statuses,
name=u'alsa-utils')
for src in sources:
if src.source_package_version != '2.0':
src.supersede()
LaunchpadZopelessLayer.txn.commit()
示例7: getTestPublisher
# 需要導入模塊: from lp.soyuz.tests.test_publishing import SoyuzTestPublisher [as 別名]
# 或者: from lp.soyuz.tests.test_publishing.SoyuzTestPublisher import addFakeChroots [as 別名]
def getTestPublisher(self, distroseries):
"""Return an `SoyuzTestPublisher`instance."""
stp = SoyuzTestPublisher()
stp.addFakeChroots(distroseries)
stp.setUpDefaultDistroSeries(distroseries)
return stp
示例8: TestBuild
# 需要導入模塊: from lp.soyuz.tests.test_publishing import SoyuzTestPublisher [as 別名]
# 或者: from lp.soyuz.tests.test_publishing.SoyuzTestPublisher import addFakeChroots [as 別名]
class TestBuild(TestCaseWithFactory):
layer = LaunchpadFunctionalLayer
def setUp(self):
super(TestBuild, self).setUp()
self.admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
self.processor = self.factory.makeProcessor()
self.distroseries = self.factory.makeDistroSeries()
self.das = self.factory.makeDistroArchSeries(
distroseries=self.distroseries, processor=self.processor,
supports_virtualized=True)
with person_logged_in(self.admin):
self.publisher = SoyuzTestPublisher()
self.publisher.prepareBreezyAutotest()
self.distroseries.nominatedarchindep = self.das
self.publisher.addFakeChroots(distroseries=self.distroseries)
self.builder = self.factory.makeBuilder(processor=self.processor)
self.now = datetime.now(pytz.UTC)
def test_title(self):
# A build has a title which describes the context source version and
# in which series and architecture it is targeted for.
spph = self.publisher.getPubSource(
sourcename=self.factory.getUniqueString(),
version="%s.1" % self.factory.getUniqueInteger(),
distroseries=self.distroseries)
[build] = spph.createMissingBuilds()
expected_title = '%s build of %s %s in %s %s RELEASE' % (
self.das.architecturetag, spph.source_package_name,
spph.source_package_version, self.distroseries.distribution.name,
self.distroseries.name)
self.assertEquals(expected_title, build.title)
def test_linking(self):
# A build directly links to the archive, distribution, distroseries,
# distroarchseries, pocket in its context and also the source version
# that generated it.
spph = self.publisher.getPubSource(
sourcename=self.factory.getUniqueString(),
version="%s.1" % self.factory.getUniqueInteger(),
distroseries=self.distroseries)
[build] = spph.createMissingBuilds()
self.assertEquals(self.distroseries.main_archive, build.archive)
self.assertEquals(self.distroseries.distribution, build.distribution)
self.assertEquals(self.distroseries, build.distro_series)
self.assertEquals(self.das, build.distro_arch_series)
self.assertEquals(PackagePublishingPocket.RELEASE, build.pocket)
self.assertEquals(self.das.architecturetag, build.arch_tag)
self.assertTrue(build.is_virtualized)
self.assertEquals(
'%s - %s' % (spph.source_package_name,
spph.source_package_version),
build.source_package_release.title)
def test_processed_builds(self):
# Builds which were already processed also offer additional
# information about its process such as the time it was started and
# finished and its 'log' and 'upload_changesfile' as librarian files.
spn = self.factory.getUniqueString()
version = "%s.1" % self.factory.getUniqueInteger()
spph = self.publisher.getPubSource(
sourcename=spn, version=version,
distroseries=self.distroseries,
status=PackagePublishingStatus.PUBLISHED)
with person_logged_in(self.admin):
binary = self.publisher.getPubBinaries(binaryname=spn,
distroseries=self.distroseries, pub_source=spph,
version=version, builder=self.builder)
build = binary[0].binarypackagerelease.build
self.assertTrue(build.was_built)
self.assertEquals(
PackageUploadStatus.DONE, build.package_upload.status)
self.assertEquals(
datetime(2008, 01, 01, 0, 0, 0, tzinfo=pytz.UTC),
build.date_started)
self.assertEquals(
datetime(2008, 01, 01, 0, 5, 0, tzinfo=pytz.UTC),
build.date_finished)
self.assertEquals(timedelta(minutes=5), build.duration)
expected_buildlog = 'buildlog_%s-%s-%s.%s_%s_FULLYBUILT.txt.gz' % (
self.distroseries.distribution.name, self.distroseries.name,
self.das.architecturetag, spn, version)
self.assertEquals(expected_buildlog, build.log.filename)
url_start = (
'http://launchpad.dev/%s/+source/%s/%s/+build/%s/+files' % (
self.distroseries.distribution.name, spn, version, build.id))
expected_buildlog_url = '%s/%s' % (url_start, expected_buildlog)
self.assertEquals(expected_buildlog_url, build.log_url)
expected_changesfile = '%s_%s_%s.changes' % (
spn, version, self.das.architecturetag)
self.assertEquals(
expected_changesfile, build.upload_changesfile.filename)
expected_changesfile_url = '%s/%s' % (url_start, expected_changesfile)
self.assertEquals(expected_changesfile_url, build.changesfile_url)
# Since this build was sucessful, it can not be retried
self.assertFalse(build.can_be_retried)
def test_current_component(self):
# The currently published component is provided via the
#.........這裏部分代碼省略.........
示例9: TestDetermineArchitecturesToBuild
# 需要導入模塊: from lp.soyuz.tests.test_publishing import SoyuzTestPublisher [as 別名]
# 或者: from lp.soyuz.tests.test_publishing.SoyuzTestPublisher import addFakeChroots [as 別名]
class TestDetermineArchitecturesToBuild(TestCaseWithFactory):
"""Test that determine_architectures_to_build correctly interprets hints.
"""
layer = LaunchpadZopelessLayer
def setUp(self):
super(TestDetermineArchitecturesToBuild, self).setUp()
self.publisher = SoyuzTestPublisher()
self.publisher.prepareBreezyAutotest()
armel = self.factory.makeProcessor('armel', 'armel', 'armel')
self.publisher.breezy_autotest.newArch(
'armel', armel, False, self.publisher.person)
self.publisher.addFakeChroots()
def assertArchitecturesToBuild(self, expected_arch_tags, pub,
allowed_arch_tags=None):
if allowed_arch_tags is None:
allowed_archs = self.publisher.breezy_autotest.architectures
else:
allowed_archs = [
arch for arch in self.publisher.breezy_autotest.architectures
if arch.architecturetag in allowed_arch_tags]
architectures = determine_architectures_to_build(
pub.sourcepackagerelease.architecturehintlist, pub.archive,
self.publisher.breezy_autotest, allowed_archs)
self.assertContentEqual(
expected_arch_tags, [a.architecturetag for a in architectures])
def assertArchsForHint(self, hint_string, expected_arch_tags,
allowed_arch_tags=None, sourcename=None):
"""Assert that the given hint resolves to the expected archtags."""
pub = self.publisher.getPubSource(
sourcename=sourcename, architecturehintlist=hint_string)
self.assertArchitecturesToBuild(
expected_arch_tags, pub, allowed_arch_tags=allowed_arch_tags)
def test_single_architecture(self):
# A hint string with a single arch resolves to just that arch.
self.assertArchsForHint('hppa', ['hppa'])
def test_three_architectures(self):
# A hint string with multiple archs resolves to just those
# archs.
self.assertArchsForHint('amd64 i386 hppa', ['hppa', 'i386'])
def test_independent(self):
# 'all' is special, meaning just a single build. The
# nominatedarchindep architecture is used -- in this case i386.
self.assertArchsForHint('all', ['i386'])
def test_one_and_independent(self):
# 'all' is redundant if we have another build anyway.
self.assertArchsForHint('hppa all', ['hppa'])
def test_fictional_and_independent(self):
# But 'all' is useful if present with an arch that wouldn't
# generate a build.
self.assertArchsForHint('foo all', ['i386'])
def test_wildcard(self):
# 'any' is a wildcard that matches all available archs.
self.assertArchsForHint('any', ['armel', 'hppa', 'i386'])
def test_kernel_specific_architecture(self):
# Since we only support Linux-based architectures, 'linux-foo'
# is treated the same as 'foo'.
self.assertArchsForHint('linux-hppa', ['hppa'])
def test_unknown_kernel_specific_architecture(self):
# Non-Linux architectures aren't supported.
self.assertArchsForHint('kfreebsd-hppa', [])
def test_kernel_wildcard_architecture(self):
# Wildcards work for kernels: 'any-foo' is treated like 'foo'.
self.assertArchsForHint('any-hppa', ['hppa'])
def test_kernel_wildcard_architecture_arm(self):
# The second part of a wildcard matches the canonical CPU name, not
# on the Debian architecture, so 'any-arm' matches 'armel'.
self.assertArchsForHint('any-arm', ['armel'])
def test_kernel_specific_architecture_wildcard(self):
# Wildcards work for archs too: 'linux-any' is treated like 'any'.
self.assertArchsForHint('linux-any', ['armel', 'hppa', 'i386'])
def test_unknown_kernel_specific_architecture_wildcard(self):
# But unknown kernels continue to result in nothing.
self.assertArchsForHint('kfreebsd-any', [])
def test_wildcard_and_independent(self):
# 'all' continues to be ignored alongside a valid wildcard.
self.assertArchsForHint('all linux-any', ['armel', 'hppa', 'i386'])
def test_kernel_independent_is_invalid(self):
# 'linux-all' isn't supported.
self.assertArchsForHint('linux-all', [])
def test_double_wildcard_is_same_as_single(self):
# 'any-any' is redundant with 'any', but dpkg-architecture supports
#.........這裏部分代碼省略.........
示例10: TestBuildDepWait
# 需要導入模塊: from lp.soyuz.tests.test_publishing import SoyuzTestPublisher [as 別名]
# 或者: from lp.soyuz.tests.test_publishing.SoyuzTestPublisher import addFakeChroots [as 別名]
class TestBuildDepWait(TestCaseWithFactory):
layer = LaunchpadFunctionalLayer
def setUp(self):
super(TestBuildDepWait, self).setUp()
self.admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
# Create everything we need to create builds, such as a
# DistroArchSeries and a builder.
self.processor = self.factory.makeProcessor()
self.distroseries = self.factory.makeDistroSeries()
self.das = self.factory.makeDistroArchSeries(
distroseries=self.distroseries, processor=self.processor,
supports_virtualized=True)
self.archive = self.factory.makeArchive(
distribution=self.distroseries.distribution,
purpose=ArchivePurpose.PRIMARY)
with person_logged_in(self.admin):
self.publisher = SoyuzTestPublisher()
self.publisher.prepareBreezyAutotest()
self.distroseries.nominatedarchindep = self.das
self.publisher.addFakeChroots(distroseries=self.distroseries)
self.builder = self.factory.makeBuilder(processor=self.processor)
def test_update_dependancies(self):
# Calling .updateDependencies() on a build will remove those which
# are reachable.
spph = self.publisher.getPubSource(
sourcename=self.factory.getUniqueString(),
version="%s.1" % self.factory.getUniqueInteger(),
distroseries=self.distroseries, archive=self.archive)
[build] = spph.createMissingBuilds()
spn = self.factory.getUniqueString()
version = "%s.1" % self.factory.getUniqueInteger()
with person_logged_in(self.admin):
build.updateStatus(
BuildStatus.MANUALDEPWAIT,
slave_status={'dependencies': unicode(spn)})
[bpph] = self.publisher.getPubBinaries(
binaryname=spn, distroseries=self.distroseries,
version=version, builder=self.builder, archive=self.archive,
status=PackagePublishingStatus.PUBLISHED)
# Commit to make sure stuff hits the database.
transaction.commit()
build.updateDependencies()
self.assertEquals(u'', build.dependencies)
def test_update_dependancies_respects_component(self):
# Since main can only utilise packages that are published in main,
# dependencies are not satisfied if they are not in main.
spph = self.publisher.getPubSource(
sourcename=self.factory.getUniqueString(),
version="%s.1" % self.factory.getUniqueInteger(),
distroseries=self.distroseries, archive=self.archive)
[build] = spph.createMissingBuilds()
spn = self.factory.getUniqueString()
version = "%s.1" % self.factory.getUniqueInteger()
with person_logged_in(self.admin):
build.updateStatus(
BuildStatus.MANUALDEPWAIT,
slave_status={'dependencies': unicode(spn)})
[bpph] = self.publisher.getPubBinaries(
binaryname=spn, distroseries=self.distroseries,
version=version, builder=self.builder, archive=self.archive,
status=PackagePublishingStatus.PUBLISHED,
component='universe')
# Commit to make sure stuff hits the database.
transaction.commit()
build.updateDependencies()
# Since the dependency is in universe, we still can't see it.
self.assertEquals(unicode(spn), build.dependencies)
with person_logged_in(self.admin):
bpph.component = getUtility(IComponentSet)['main']
transaction.commit()
# Now that we have moved it main, we can see it.
build.updateDependencies()
self.assertEquals(u'', build.dependencies)
示例11: TestSourcePublicationListingExtra
# 需要導入模塊: from lp.soyuz.tests.test_publishing import SoyuzTestPublisher [as 別名]
# 或者: from lp.soyuz.tests.test_publishing.SoyuzTestPublisher import addFakeChroots [as 別名]
class TestSourcePublicationListingExtra(BrowserTestCase):
layer = LaunchpadFunctionalLayer
def setUp(self):
super(TestSourcePublicationListingExtra, self).setUp()
self.admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
# Create everything we need to create builds, such as a
# DistroArchSeries and a builder.
self.processor = self.factory.makeProcessor()
self.distroseries = self.factory.makeDistroSeries()
self.das = self.factory.makeDistroArchSeries(
distroseries=self.distroseries, processor=self.processor,
supports_virtualized=True)
self.archive = self.factory.makeArchive(
distribution=self.distroseries.distribution)
with person_logged_in(self.admin):
self.publisher = SoyuzTestPublisher()
self.publisher.prepareBreezyAutotest()
self.distroseries.nominatedarchindep = self.das
self.publisher.addFakeChroots(distroseries=self.distroseries)
self.builder = self.factory.makeBuilder(processor=self.processor)
def test_view_with_source_package_recipe(self):
# When a SourcePackageRelease is linked to a
# SourcePackageRecipeBuild, the view shows which recipe was
# responsible for creating the SPR.
sprb = self.factory.makeSourcePackageRecipeBuild(
archive=self.archive)
recipe = sprb.recipe
requester = sprb.requester
spph = self.publisher.getPubSource(
archive=self.archive, status=PackagePublishingStatus.PUBLISHED)
spph.sourcepackagerelease.source_package_recipe_build = sprb
recipe_link_matches = soupmatchers.HTMLContains(
soupmatchers.Tag(
'link to build', 'a', attrs={'href': canonical_url(sprb)},
text='Built'),
soupmatchers.Tag(
'recipe name', 'a', attrs={'href': canonical_url(recipe)},
text=recipe.name),
soupmatchers.Tag(
'requester', 'a',
attrs={
'href': canonical_url(requester)},
text=requester.displayname))
browser = self.getViewBrowser(spph, '+listing-archive-extra')
self.assertThat(browser.contents, recipe_link_matches)
def test_view_without_source_package_recipe(self):
# And if a SourcePackageRelease is not linked, there is no sign of it
# in the view.
spph = self.publisher.getPubSource(
archive=self.archive, status=PackagePublishingStatus.PUBLISHED)
browser = self.getViewBrowser(spph, '+listing-archive-extra')
self.assertNotIn('Built by recipe', browser.contents)
def test_view_with_deleted_source_package_recipe(self):
# If a SourcePackageRelease is linked to a deleted recipe, the text
# 'deleted recipe' is displayed, rather than a link.
sprb = self.factory.makeSourcePackageRecipeBuild(
archive=self.archive)
recipe = sprb.recipe
requester = sprb.requester
spph = self.publisher.getPubSource(
archive=self.archive, status=PackagePublishingStatus.PUBLISHED)
spph.sourcepackagerelease.source_package_recipe_build = sprb
with person_logged_in(recipe.owner):
recipe.destroySelf()
recipe_link_matches = soupmatchers.HTMLContains(
soupmatchers.Tag(
'link to build', 'a',
attrs={'href': canonical_url(sprb)},
text='Built'),
soupmatchers.Tag(
'requester', 'a',
attrs={
'href': canonical_url(requester)},
text=requester.displayname))
browser = self.getViewBrowser(spph, '+listing-archive-extra')
self.assertThat(browser.contents, recipe_link_matches)
self.assertIn('deleted recipe', browser.contents)
示例12: TestBuildSet
# 需要導入模塊: from lp.soyuz.tests.test_publishing import SoyuzTestPublisher [as 別名]
# 或者: from lp.soyuz.tests.test_publishing.SoyuzTestPublisher import addFakeChroots [as 別名]
class TestBuildSet(TestCaseWithFactory):
layer = LaunchpadFunctionalLayer
def setUp(self):
super(TestBuildSet, self).setUp()
self.admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
self.processor_one = self.factory.makeProcessor()
self.processor_two = self.factory.makeProcessor()
self.distroseries = self.factory.makeDistroSeries()
self.distribution = self.distroseries.distribution
self.das_one = self.factory.makeDistroArchSeries(
distroseries=self.distroseries, processor=self.processor_one,
supports_virtualized=True)
self.das_two = self.factory.makeDistroArchSeries(
distroseries=self.distroseries, processor=self.processor_two,
supports_virtualized=True)
self.archive = self.factory.makeArchive(
distribution=self.distroseries.distribution,
purpose=ArchivePurpose.PRIMARY)
with person_logged_in(self.admin):
self.publisher = SoyuzTestPublisher()
self.publisher.prepareBreezyAutotest()
self.distroseries.nominatedarchindep = self.das_one
self.publisher.addFakeChroots(distroseries=self.distroseries)
self.builder_one = self.factory.makeBuilder(
processor=self.processor_one)
self.builder_two = self.factory.makeBuilder(
processor=self.processor_two)
self.builds = []
self.spphs = []
def setUpBuilds(self):
for i in range(5):
# Create some test builds
spph = self.publisher.getPubSource(
sourcename=self.factory.getUniqueString(),
version="%s.%s" % (self.factory.getUniqueInteger(), i),
distroseries=self.distroseries, architecturehintlist='any')
self.spphs.append(spph)
builds = spph.createMissingBuilds()
with person_logged_in(self.admin):
for b in builds:
b.updateStatus(BuildStatus.BUILDING)
if i == 4:
b.updateStatus(BuildStatus.FAILEDTOBUILD)
else:
b.updateStatus(BuildStatus.FULLYBUILT)
b.buildqueue_record.destroySelf()
self.builds += builds
def test_get_for_distro_distribution(self):
# Test fetching builds for a distro's main archives
self.setUpBuilds()
set = getUtility(IBinaryPackageBuildSet).getBuildsForDistro(
self.distribution)
self.assertEquals(set.count(), 10)
def test_get_for_distro_distroseries(self):
# Test fetching builds for a distroseries' main archives
self.setUpBuilds()
set = getUtility(IBinaryPackageBuildSet).getBuildsForDistro(
self.distroseries)
self.assertEquals(set.count(), 10)
def test_get_for_distro_distroarchseries(self):
# Test fetching builds for a distroarchseries' main archives
self.setUpBuilds()
set = getUtility(IBinaryPackageBuildSet).getBuildsForDistro(
self.das_one)
self.assertEquals(set.count(), 5)
def test_get_for_distro_filter_build_status(self):
# The result can be filtered based on the build status
self.setUpBuilds()
set = getUtility(IBinaryPackageBuildSet).getBuildsForDistro(
self.distribution, status=BuildStatus.FULLYBUILT)
self.assertEquals(set.count(), 8)
def test_get_for_distro_filter_name(self):
# The result can be filtered based on the name
self.setUpBuilds()
spn = self.builds[2].source_package_release.sourcepackagename.name
set = getUtility(IBinaryPackageBuildSet).getBuildsForDistro(
self.distribution, name=spn)
self.assertEquals(set.count(), 2)
def test_get_for_distro_filter_pocket(self):
# The result can be filtered based on the pocket of the build
self.setUpBuilds()
set = getUtility(IBinaryPackageBuildSet).getBuildsForDistro(
self.distribution, pocket=PackagePublishingPocket.RELEASE)
self.assertEquals(set.count(), 10)
set = getUtility(IBinaryPackageBuildSet).getBuildsForDistro(
self.distribution, pocket=PackagePublishingPocket.UPDATES)
self.assertEquals(set.count(), 0)
def test_get_for_distro_filter_arch_tag(self):
# The result can be filtered based on the archtag of the build
self.setUpBuilds()
#.........這裏部分代碼省略.........
示例13: TestBuildNotify
# 需要導入模塊: from lp.soyuz.tests.test_publishing import SoyuzTestPublisher [as 別名]
# 或者: from lp.soyuz.tests.test_publishing.SoyuzTestPublisher import addFakeChroots [as 別名]
class TestBuildNotify(TestCaseWithFactory):
layer = LaunchpadFunctionalLayer
def setUp(self):
super(TestBuildNotify, self).setUp()
self.admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
# Create all of the items we need to create builds
self.processor = self.factory.makeProcessor()
self.distroseries = self.factory.makeDistroSeries()
self.das = self.factory.makeDistroArchSeries(
distroseries=self.distroseries, processor=self.processor,
supports_virtualized=True)
self.creator = self.factory.makePerson(email='[email protected]')
self.gpgkey = self.factory.makeGPGKey(owner=self.creator)
self.archive = self.factory.makeArchive(
distribution=self.distroseries.distribution,
purpose=ArchivePurpose.PRIMARY)
self.ppa = self.factory.makeArchive()
buildd_admins = getUtility(IPersonSet).getByName(
'launchpad-buildd-admins')
self.buildd_admins_email = []
with person_logged_in(self.admin):
self.publisher = SoyuzTestPublisher()
self.publisher.prepareBreezyAutotest()
self.distroseries.nominatedarchindep = self.das
self.publisher.addFakeChroots(distroseries=self.distroseries)
self.builder = self.factory.makeBuilder(processor=self.processor)
for member in buildd_admins.activemembers:
self.buildd_admins_email.append(member.preferredemail.email)
self.builds = []
def create_builds(self, archive):
for status in BuildStatus.items:
spph = self.publisher.getPubSource(
sourcename=self.factory.getUniqueString(),
version="%s.%s" % (
self.factory.getUniqueInteger(), status.value),
distroseries=self.distroseries, architecturehintlist='any',
creator=self.creator, archive=archive)
spph.sourcepackagerelease.dscsigningkey = self.gpgkey
[build] = spph.createMissingBuilds()
with person_logged_in(self.admin):
build.updateStatus(BuildStatus.BUILDING, builder=self.builder)
build.updateStatus(status,
date_finished=(
build.date_started + timedelta(
minutes=5 * (status.value + 1))))
if status != BuildStatus.BUILDING:
build.buildqueue_record.destroySelf()
else:
build.buildqueue_record.builder = self.builder
self.builds.append(build)
def _assert_mail_is_correct(self, build, notification, ppa=False):
# Assert that the mail sent (which is in notification), matches
# the data from the build
self.assertEquals('[email protected]',
notification['X-Creator-Recipient'])
self.assertEquals(
self.das.architecturetag, notification['X-Launchpad-Build-Arch'])
self.assertEquals(
'main', notification['X-Launchpad-Build-Component'])
self.assertEquals(
build.status.name, notification['X-Launchpad-Build-State'])
if ppa is True:
self.assertEquals(
get_ppa_reference(self.ppa), notification['X-Launchpad-PPA'])
body = notification.get_payload(decode=True)
build_log = 'None'
if ppa is True:
archive = '%s PPA' % get_ppa_reference(build.archive)
source = 'not available'
else:
archive = '%s primary archive' % (
self.distroseries.distribution.name)
source = canonical_url(build.distributionsourcepackagerelease)
builder = canonical_url(build.builder)
if build.status == BuildStatus.BUILDING:
duration = 'not finished'
build_log = 'see builder page'
elif (
build.status == BuildStatus.SUPERSEDED or
build.status == BuildStatus.NEEDSBUILD):
duration = 'not available'
build_log = 'not available'
builder = 'not available'
elif build.status == BuildStatus.UPLOADING:
duration = 'uploading'
build_log = 'see builder page'
builder = 'not available'
else:
duration = DurationFormatterAPI(
build.duration).approximateduration()
expected_body = dedent("""
* Source Package: %s
* Version: %s
* Architecture: %s
* Archive: %s
* Component: main
#.........這裏部分代碼省略.........