本文整理匯總了Python中lp.soyuz.tests.test_publishing.SoyuzTestPublisher.getPubBinaries方法的典型用法代碼示例。如果您正苦於以下問題:Python SoyuzTestPublisher.getPubBinaries方法的具體用法?Python SoyuzTestPublisher.getPubBinaries怎麽用?Python SoyuzTestPublisher.getPubBinaries使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類lp.soyuz.tests.test_publishing.SoyuzTestPublisher
的用法示例。
在下文中一共展示了SoyuzTestPublisher.getPubBinaries方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create_child
# 需要導入模塊: from lp.soyuz.tests.test_publishing import SoyuzTestPublisher [as 別名]
# 或者: from lp.soyuz.tests.test_publishing.SoyuzTestPublisher import getPubBinaries [as 別名]
def create_child(factory):
processor = factory.makeProcessor()
parent = factory.makeDistroSeries()
parent_das = factory.makeDistroArchSeries(distroseries=parent, processor=processor)
lf = factory.makeLibraryFileAlias()
# Since the LFA needs to be in the librarian, commit.
transaction.commit()
parent_das.addOrUpdateChroot(lf)
with celebrity_logged_in("admin"):
parent_das.supports_virtualized = True
parent.nominatedarchindep = parent_das
publisher = SoyuzTestPublisher()
publisher.prepareBreezyAutotest()
packages = {"udev": "0.1-1", "libc6": "2.8-1"}
for package in packages.keys():
publisher.getPubBinaries(
distroseries=parent,
binaryname=package,
version=packages[package],
status=PackagePublishingStatus.PUBLISHED,
)
test1 = getUtility(IPackagesetSet).new(u"test1", u"test 1 packageset", parent.owner, distroseries=parent)
test1_packageset_id = str(test1.id)
test1.addSources("udev")
parent.updatePackageCount()
child = factory.makeDistroSeries()
getUtility(ISourcePackageFormatSelectionSet).add(child, SourcePackageFormat.FORMAT_1_0)
# Make sure everything hits the database, switching db users aborts.
transaction.commit()
return parent, child, test1_packageset_id
示例2: TestBuildUpdateDependencies
# 需要導入模塊: from lp.soyuz.tests.test_publishing import SoyuzTestPublisher [as 別名]
# 或者: from lp.soyuz.tests.test_publishing.SoyuzTestPublisher import getPubBinaries [as 別名]
class TestBuildUpdateDependencies(TestCaseWithFactory):
layer = LaunchpadZopelessLayer
def _setupSimpleDepwaitContext(self):
"""Use `SoyuzTestPublisher` to setup a simple depwait context.
Return an `IBinaryPackageBuild` in MANUALDEWAIT state and depending
on a binary that exists and is reachable.
"""
self.publisher = SoyuzTestPublisher()
self.publisher.prepareBreezyAutotest()
depwait_source = self.publisher.getPubSource(
sourcename='depwait-source')
self.publisher.getPubBinaries(
binaryname='dep-bin', status=PackagePublishingStatus.PUBLISHED)
[depwait_build] = depwait_source.createMissingBuilds()
depwait_build.updateStatus(
BuildStatus.MANUALDEPWAIT,
slave_status={'dependencies': u'dep-bin'})
return depwait_build
def testBuildqueueRemoval(self):
"""Test removing buildqueue items.
Removing a Buildqueue row should also remove its associated
BuildPackageJob and Job rows.
"""
# Create a build in depwait.
depwait_build = self._setupSimpleDepwaitContext()
depwait_build_id = depwait_build.id
# Grab the relevant db records for later comparison.
store = Store.of(depwait_build)
build_package_job = store.find(
BuildPackageJob, depwait_build.id == BuildPackageJob.build).one()
build_package_job_id = build_package_job.id
job_id = store.find(Job, Job.id == build_package_job.job.id).one().id
build_queue_id = store.find(BuildQueue,
BuildQueue.job == job_id).one().id
depwait_build.buildqueue_record.destroySelf()
# Test that the records above no longer exist in the db.
self.assertEqual(
store.find(BuildPackageJob,
BuildPackageJob.id == build_package_job_id).count(), 0)
self.assertEqual(store.find(Job, Job.id == job_id).count(), 0)
self.assertEqual(
store.find(BuildQueue, BuildQueue.id == build_queue_id).count(), 0)
# But the build itself still exists.
self.assertEqual(
store.find(BinaryPackageBuild,
BinaryPackageBuild.id == depwait_build_id).count(), 1)
def testUpdateDependenciesWorks(self):
# Calling `IBinaryPackageBuild.updateDependencies` makes the build
# record ready for dispatch.
depwait_build = self._setupSimpleDepwaitContext()
self.layer.txn.commit()
depwait_build.updateDependencies()
self.assertEqual(depwait_build.dependencies, '')
def assertRaisesUnparsableDependencies(self, depwait_build, dependencies):
depwait_build.updateStatus(
BuildStatus.MANUALDEPWAIT,
slave_status={'dependencies': dependencies})
self.assertRaises(UnparsableDependencies,
depwait_build.updateDependencies)
def testInvalidDependencies(self):
# Calling `IBinaryPackageBuild.updateDependencies` on a build with
# invalid 'dependencies' raises an AssertionError.
# Anything not following '<name> [([relation] <version>)][, ...]'
depwait_build = self._setupSimpleDepwaitContext()
# None is not a valid dependency values.
self.assertRaisesUnparsableDependencies(depwait_build, None)
# Missing 'name'.
self.assertRaisesUnparsableDependencies(depwait_build, u'(>> version)')
# Missing 'version'.
self.assertRaisesUnparsableDependencies(depwait_build, u'name (>>)')
# Missing comma between dependencies.
self.assertRaisesUnparsableDependencies(depwait_build, u'name1 name2')
def testBug378828(self):
# `IBinaryPackageBuild.updateDependencies` copes with the
# scenario where the corresponding source publication is not
# active (deleted) and the source original component is not a
# valid ubuntu component.
depwait_build = self._setupSimpleDepwaitContext()
spr = depwait_build.source_package_release
depwait_build.current_source_publication.requestDeletion(spr.creator)
#.........這裏部分代碼省略.........
示例3: TestBuild
# 需要導入模塊: from lp.soyuz.tests.test_publishing import SoyuzTestPublisher [as 別名]
# 或者: from lp.soyuz.tests.test_publishing.SoyuzTestPublisher import getPubBinaries [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
#.........這裏部分代碼省略.........
示例4: ArchiveExpiryTestBase
# 需要導入模塊: from lp.soyuz.tests.test_publishing import SoyuzTestPublisher [as 別名]
# 或者: from lp.soyuz.tests.test_publishing.SoyuzTestPublisher import getPubBinaries [as 別名]
class ArchiveExpiryTestBase(TestCaseWithFactory):
"""base class for the expire-archive-files.py script tests."""
layer = LaunchpadZopelessLayer
dbuser = config.binaryfile_expire.dbuser
def setUp(self):
"""Set up some test publications."""
super(ArchiveExpiryTestBase, self).setUp()
# Configure the test publisher.
switch_dbuser("launchpad")
self.stp = SoyuzTestPublisher()
self.stp.prepareBreezyAutotest()
# Prepare some date properties for the tests to use.
self.now = datetime.now(pytz.UTC)
self.under_threshold_date = self.now - timedelta(days=29)
self.over_threshold_date = self.now - timedelta(days=31)
def getScript(self, test_args=None):
"""Return a ArchiveExpirer instance."""
if test_args is None:
test_args = []
test_args.extend(['--expire-after', '30'])
script = ArchiveExpirer("test expirer", test_args=test_args)
script.logger = BufferLogger()
script.txn = self.layer.txn
return script
def runScript(self):
"""Run the expiry script and return."""
script = self.getScript()
switch_dbuser(self.dbuser)
script.main()
def _setUpExpirablePublications(self, archive=None):
"""Helper to set up two publications that are both expirable."""
if archive is None:
archive = self.archive
pkg5 = self.stp.getPubSource(
sourcename="pkg5", architecturehintlist="i386", archive=archive,
dateremoved=self.over_threshold_date)
other_source = pkg5.copyTo(
pkg5.distroseries, pkg5.pocket, self.archive2)
other_source.dateremoved = self.over_threshold_date
[pub] = self.stp.getPubBinaries(
pub_source=pkg5, dateremoved=self.over_threshold_date,
archive=archive)
[other_binary] = pub.copyTo(
pub.distroarchseries.distroseries, pub.pocket, self.archive2)
other_binary.dateremoved = self.over_threshold_date
return pkg5, pub
def assertBinaryExpired(self, publication):
self.assertNotEqual(
publication.binarypackagerelease.files[0].libraryfile.expires,
None,
"lfa.expires should be set, but it's not.")
def assertBinaryNotExpired(self, publication):
self.assertEqual(
publication.binarypackagerelease.files[0].libraryfile.expires,
None,
"lfa.expires should be None, but it's not.")
def assertSourceExpired(self, publication):
self.assertNotEqual(
publication.sourcepackagerelease.files[0].libraryfile.expires,
None,
"lfa.expires should be set, but it's not.")
def assertSourceNotExpired(self, publication):
self.assertEqual(
publication.sourcepackagerelease.files[0].libraryfile.expires,
None,
"lfa.expires should be None, but it's not.")
示例5: TestBuildDepWait
# 需要導入模塊: from lp.soyuz.tests.test_publishing import SoyuzTestPublisher [as 別名]
# 或者: from lp.soyuz.tests.test_publishing.SoyuzTestPublisher import getPubBinaries [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)
示例6: TestScriptRunning
# 需要導入模塊: from lp.soyuz.tests.test_publishing import SoyuzTestPublisher [as 別名]
# 或者: from lp.soyuz.tests.test_publishing.SoyuzTestPublisher import getPubBinaries [as 別名]
class TestScriptRunning(TestCaseWithFactory):
"""Run parse-ppa-apache-access-logs.py and test its outcome."""
layer = LaunchpadZopelessLayer
def setUp(self):
super(TestScriptRunning, self).setUp()
self.publisher = SoyuzTestPublisher()
self.publisher.prepareBreezyAutotest()
self.store = IStore(BinaryPackageReleaseDownloadCount)
self.archive = getUtility(IPersonSet).getByName('cprov').archive
self.archive.require_virtualized = False
self.foo_i386, self.foo_hppa = self.publisher.getPubBinaries(
archive=self.archive, architecturespecific=True)
self.bar_i386, self.bar_hppa = self.publisher.getPubBinaries(
binaryname='bar-bin', archive=self.archive,
architecturespecific=False)
# Commit so the script can see our changes.
import transaction
transaction.commit()
def test_script_run(self):
# Before we run the script, there are no binary package
# downloads in the database.
# After the script's run, we will check that the results in the
# database match the sample log files we use for this test:
# lib/lp/soyuz/scripts/tests/ppa-apache-log-files
# In addition to the wanted access log file, there is also an
# error log that will be skipped by the configured glob.
self.assertEqual(
0, self.store.find(BinaryPackageReleaseDownloadCount).count())
process = subprocess.Popen(
'cronscripts/parse-ppa-apache-access-logs.py', shell=True,
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(out, err) = process.communicate()
self.assertEqual(
process.returncode, 0, "stdout:%s, stderr:%s" % (out, err))
# The error log does not match the glob, so it is not processed,
# and no OOPS is generated.
self.oops_capture.sync()
self.assertEqual([], self.oopses)
# Must commit because the changes were done in another transaction.
import transaction
transaction.commit()
results = self.store.find(BinaryPackageReleaseDownloadCount)
australia = getUtility(ICountrySet)['AU']
austria = getUtility(ICountrySet)['AT']
self.assertEqual(
[(self.foo_hppa.binarypackagerelease,
self.archive,
date(2008, 6, 13),
australia,
1),
(self.foo_i386.binarypackagerelease,
self.archive,
date(2008, 6, 13),
australia,
1),
(self.foo_i386.binarypackagerelease,
self.archive,
date(2008, 6, 13),
austria,
1),
(self.bar_i386.binarypackagerelease,
self.archive,
date(2008, 6, 14),
None,
1),
(self.bar_i386.binarypackagerelease,
self.archive,
date(2008, 6, 14),
austria,
1)],
sorted(
[(result.binary_package_release, result.archive, result.day,
result.country, result.count) for result in results],
key=lambda r: (r[0].id, r[2], r[3].name if r[3] else None)))
示例7: TestDistroSeriesBinaryPackage
# 需要導入模塊: from lp.soyuz.tests.test_publishing import SoyuzTestPublisher [as 別名]
# 或者: from lp.soyuz.tests.test_publishing.SoyuzTestPublisher import getPubBinaries [as 別名]
class TestDistroSeriesBinaryPackage(TestCaseWithFactory):
layer = LaunchpadZopelessLayer
def setUp(self):
"""Create a distroseriesbinarypackage to play with."""
super(TestDistroSeriesBinaryPackage, self).setUp()
self.publisher = SoyuzTestPublisher()
self.publisher.prepareBreezyAutotest()
self.distroseries = self.publisher.distroseries
self.distribution = self.distroseries.distribution
binaries = self.publisher.getPubBinaries(
binaryname='foo-bin', summary='Foo is the best')
binary_pub = binaries[0]
self.binary_package_name = (
binary_pub.binarypackagerelease.binarypackagename)
self.distroseries_binary_package = DistroSeriesBinaryPackage(
self.distroseries, self.binary_package_name)
def test_cache_attribute_when_two_cache_objects(self):
# We have situations where there are cache objects for each
# distro archive - we need to handle this situation without
# OOPSing - see bug 580181.
distro_archive_1 = self.distribution.main_archive
distro_archive_2 = self.distribution.all_distro_archives[1]
# Publish the same binary in another distro archive.
self.publisher.getPubBinaries(
binaryname='foo-bin', summary='Foo is the best',
archive=distro_archive_2)
logger = BufferLogger()
with dbuser(config.statistician.dbuser):
DistroSeriesPackageCache._update(
self.distroseries, self.binary_package_name, distro_archive_1,
logger)
DistroSeriesPackageCache._update(
self.distroseries, self.binary_package_name, distro_archive_2,
logger)
self.failUnlessEqual(
'Foo is the best', self.distroseries_binary_package.summary)
def test_none_cache_passed_at_init_counts_as_cached(self):
# If the value None is passed as the constructor parameter
# "cache", it is considered as a valid value.
# Accesing the property DistroSeriesBinaryPackage.cache
# later does not lead to the execution of an SQL query to
# retrieve a DistroSeriesPackageCache record.
binary_package = DistroSeriesBinaryPackage(
self.distroseries, self.binary_package_name, cache=None)
with StormStatementRecorder() as recorder:
binary_package.cache
self.assertThat(recorder, HasQueryCount(Equals(0)))
# If the parameter "cache" was not passed, accessing
# DistroSeriesBinaryPackage.cache for the first time requires
# at least one SQL query.
with StormStatementRecorder() as recorder:
self.distroseries_binary_package.cache
self.assertThat(recorder, HasQueryCount(NotEquals(0)))