launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #00460
[Merge] lp:~james-w/launchpad/soyuz-factory-improvements into lp:launchpad/devel
James Westby has proposed merging lp:~james-w/launchpad/soyuz-factory-improvements into lp:launchpad/devel.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Hi,
This makes some improvements to the Soyuz parts of the factory.
There are a couple of bugfixes, but mostly it is the addition of
new features.
There is also a change to make distributions and distroseries have
less generic names, which helped make some test failures more
readable.
This branch is laying the groundwork for my next, which will make
SoyuzTestPublisher use the factory.
No lint.
Thanks,
James
--
https://code.launchpad.net/~james-w/launchpad/soyuz-factory-improvements/+merge/31890
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~james-w/launchpad/soyuz-factory-improvements into lp:launchpad/devel.
=== modified file 'lib/lp/soyuz/configure.zcml'
--- lib/lp/soyuz/configure.zcml 2010-06-30 17:35:36 +0000
+++ lib/lp/soyuz/configure.zcml 2010-08-05 20:54:49 +0000
@@ -188,7 +188,8 @@
displayversion
is_delayed_copy
isPPA
- components"/>
+ components
+ isAutoSyncUpload"/>
<require
permission="launchpad.Edit"
attributes="
=== modified file 'lib/lp/soyuz/interfaces/binarypackagename.py'
--- lib/lp/soyuz/interfaces/binarypackagename.py 2010-01-12 19:02:09 +0000
+++ lib/lp/soyuz/interfaces/binarypackagename.py 2010-08-05 20:54:49 +0000
@@ -14,7 +14,7 @@
]
from zope.schema import Int, TextLine
-from zope.interface import Interface, Attribute
+from zope.interface import Interface
from canonical.launchpad import _
from canonical.launchpad.validators.name import name_validator
@@ -26,11 +26,6 @@
name = TextLine(title=_('Valid Binary package name'),
required=True, constraint=name_validator)
- binarypackages = Attribute('binarypackages')
-
- def nameSelector(sourcepackage=None, selected=None):
- """Return browser-ready HTML to select a Binary Package Name"""
-
def __unicode__():
"""Return the name"""
=== modified file 'lib/lp/soyuz/model/binarypackagename.py'
--- lib/lp/soyuz/model/binarypackagename.py 2010-08-02 02:13:52 +0000
+++ lib/lp/soyuz/model/binarypackagename.py 2010-08-05 20:54:49 +0000
@@ -8,7 +8,7 @@
'BinaryPackageName',
'BinaryPackageNameSet',
'BinaryPackageNameVocabulary',
- 'getBinaryPackageDescriptions'
+ 'getBinaryPackageDescriptions',
]
# Zope imports
@@ -17,7 +17,7 @@
# SQLObject/SQLBase
from sqlobject import (
- SQLObjectNotFound, StringCol, SQLMultipleJoin, CONTAINSSTRING)
+ SQLObjectNotFound, StringCol, CONTAINSSTRING)
from storm.store import EmptyResultSet
@@ -39,10 +39,6 @@
name = StringCol(dbName='name', notNull=True, unique=True,
alternateID=True)
- binarypackages = SQLMultipleJoin(
- 'BinaryPackage', joinColumn='binarypackagename'
- )
-
def __unicode__(self):
return self.name
@@ -125,6 +121,7 @@
Builds descriptions based on releases of that binary package name.
"""
+
def getTermsWithDescriptions(self, results):
# Prefill the descriptions dictionary with the latest
# description uploaded for that package name.
@@ -165,11 +162,10 @@
for release in releases:
binarypackagename = release.binarypackagename.name
- if not descriptions.has_key(binarypackagename):
+ if binarypackagename in descriptions:
description = release.description.strip().replace("\n", " ")
if len(description) > max_title_length:
description = (release.description[:max_title_length]
+ "...")
descriptions[binarypackagename] = description
return descriptions
-
=== modified file 'lib/lp/soyuz/scripts/tests/test_ppa_apache_log_parser.py'
--- lib/lp/soyuz/scripts/tests/test_ppa_apache_log_parser.py 2010-07-20 12:06:36 +0000
+++ lib/lp/soyuz/scripts/tests/test_ppa_apache_log_parser.py 2010-08-05 20:54:49 +0000
@@ -40,8 +40,8 @@
self.assertIs(None, get_ppa_file_key('/foo'))
def test_get_ppa_file_key_ignores_non_binary_path(self):
- # A path with extra path segments returns None, to indicate that
- # it should be ignored.
+ # A path pointing to a file not from a binary package returns
+ # None to indicate that it should be ignored.
self.assertIs(None, get_ppa_file_key(
'/cprov/ppa/ubuntu/pool/main/f/foo/foo_1.2.3-4.dsc'))
=== modified file 'lib/lp/testing/factory.py'
--- lib/lp/testing/factory.py 2010-08-04 00:47:20 +0000
+++ lib/lp/testing/factory.py 2010-08-05 20:54:49 +0000
@@ -143,6 +143,7 @@
from lp.soyuz.interfaces.archive import (
default_name_by_purpose, IArchiveSet, ArchivePurpose)
from lp.soyuz.interfaces.binarypackagebuild import IBinaryPackageBuildSet
+from lp.soyuz.interfaces.binarypackagename import IBinaryPackageNameSet
from lp.soyuz.interfaces.binarypackagerelease import (
BinaryPackageFileType, BinaryPackageFormat)
from lp.soyuz.interfaces.component import IComponentSet
@@ -150,9 +151,8 @@
from lp.soyuz.interfaces.processor import IProcessorFamilySet
from lp.soyuz.interfaces.publishing import (
IPublishingSet, PackagePublishingPriority, PackagePublishingStatus)
+from lp.soyuz.interfaces.queue import PackageUploadStatus
from lp.soyuz.interfaces.section import ISectionSet
-from lp.soyuz.model.binarypackagename import BinaryPackageName
-from lp.soyuz.model.binarypackagerelease import BinaryPackageRelease
from lp.soyuz.model.files import BinaryPackageFile, SourcePackageReleaseFile
from lp.soyuz.model.processor import ProcessorFamilySet
from lp.testing import (
@@ -1671,9 +1671,9 @@
members=None, title=None):
"""Make a new distribution."""
if name is None:
- name = self.getUniqueString()
+ name = self.getUniqueString(prefix="distribution")
if displayname is None:
- displayname = self.getUniqueString()
+ displayname = name.capitalize()
if title is None:
title = self.getUniqueString()
description = self.getUniqueString()
@@ -1694,7 +1694,7 @@
if distribution is None:
distribution = self.makeDistribution()
if name is None:
- name = self.getUniqueString()
+ name = self.getUniqueString(prefix="distroseries")
if displayname is None:
displayname = name.capitalize()
if version is None:
@@ -2267,6 +2267,35 @@
def getAnySourcePackageUrgency(self):
return SourcePackageUrgency.MEDIUM
+ def makePackageUpload(self, distroseries=None, archive=None,
+ pocket=None, changes_filename=None,
+ changes_file_content=None,
+ signing_key=None, status=None):
+ if archive is None:
+ archive = self.makeArchive()
+ if distroseries is None:
+ distroseries = self.makeDistroSeries(
+ distribution=archive.distribution)
+ if changes_filename is None:
+ changes_filename = self.getUniqueString("changesfilename")
+ if changes_file_content is None:
+ changes_file_content = self.getUniqueString("changesfilecontent")
+ if pocket is None:
+ pocket = PackagePublishingPocket.RELEASE
+ package_upload = distroseries.createQueueEntry(
+ pocket, changes_filename, changes_file_content, archive,
+ signing_key=signing_key)
+ if status is not None:
+ status_to_method = {
+ PackageUploadStatus.DONE: 'setDone',
+ PackageUploadStatus.ACCEPTED: 'setAccepted',
+ }
+ naked_package_upload = removeSecurityProxy(package_upload)
+ method = getattr(
+ naked_package_upload, status_to_method[status])
+ method()
+ return package_upload
+
def makeSourcePackageRelease(self, archive=None, sourcepackagename=None,
distroseries=None, maintainer=None,
creator=None, component=None,
@@ -2313,9 +2342,10 @@
if maintainer is None:
maintainer = self.makePerson()
- maintainer_email = '%s <%s>' % (
- maintainer.displayname,
- maintainer.preferredemail.email)
+ if dsc_maintainer_rfc822 is None:
+ dsc_maintainer_rfc822 = '%s <%s>' % (
+ maintainer.displayname,
+ maintainer.preferredemail.email)
if creator is None:
creator = self.makePerson()
@@ -2341,7 +2371,7 @@
dsc=None,
copyright=self.getUniqueString(),
dscsigningkey=dscsigningkey,
- dsc_maintainer_rfc822=maintainer_email,
+ dsc_maintainer_rfc822=dsc_maintainer_rfc822,
dsc_standards_version=dsc_standards_version,
dsc_format=dsc_format,
dsc_binaries=dsc_binaries,
@@ -2481,6 +2511,8 @@
naked_spph.datecreated = date_uploaded
naked_spph.dateremoved = dateremoved
naked_spph.scheduleddeletiondate = scheduleddeletiondate
+ if status == PackagePublishingStatus.PUBLISHED:
+ naked_spph.datepublished = UTC_NOW
return spph
def makeBinaryPackagePublishingHistory(self, binarypackagerelease=None,
@@ -2529,12 +2561,25 @@
naked_bpph.dateremoved = dateremoved
naked_bpph.scheduleddeletiondate = scheduleddeletiondate
naked_bpph.priority = priority
+ if status == PackagePublishingStatus.PUBLISHED:
+ naked_bpph.datepublished = UTC_NOW
return bpph
def makeBinaryPackageName(self, name=None):
+ """Make an `IBinaryPackageName`."""
if name is None:
name = self.getUniqueString("binarypackage")
- return BinaryPackageName(name=name)
+ return getUtility(IBinaryPackageNameSet).new(name)
+
+ def getOrMakeBinaryPackageName(self, name=None):
+ """Get an existing `IBinaryPackageName` or make a new one.
+
+ This method encapsulates getOrCreateByName so that tests can be kept
+ free of the getUtility(IBinaryPackageNameSet) noise.
+ """
+ if name is None:
+ return self.makeBinaryPackageName()
+ return getUtility(IBinaryPackageNameSet).getOrCreateByName(name)
def makeBinaryPackageFile(self, binarypackagerelease=None,
library_file=None, filetype=None):
@@ -2553,32 +2598,44 @@
binpackageformat=None, component=None,
section_name=None, priority=None,
architecturespecific=False,
- summary=None, description=None):
+ summary=None, description=None,
+ shlibdeps=None, depends=None,
+ recommends=None, suggests=None,
+ conflicts=None, replaces=None,
+ provides=None, pre_depends=None,
+ enhances=None, breaks=None,
+ essential=False, installed_size=None):
"""Make a `BinaryPackageRelease`."""
+ if build is None:
+ build = self.makeBinaryPackageBuild()
if binarypackagename is None:
binarypackagename = self.makeBinaryPackageName()
if version is None:
- version = self.getUniqueString("version")
- if build is None:
- build = self.makeBinaryPackageBuild()
+ version = build.source_package_release.version
if binpackageformat is None:
binpackageformat = BinaryPackageFormat.DEB
if component is None:
- component = self.makeComponent()
- section = self.makeSection(name=section_name)
+ component = build.source_package_release.component
+ section = build.source_package_release.section
if priority is None:
priority = PackagePublishingPriority.OPTIONAL
if summary is None:
summary = self.getUniqueString("summary")
if description is None:
description = self.getUniqueString("description")
- return ProxyFactory(
- BinaryPackageRelease(
+ if installed_size is None:
+ installed_size = self.getUniqueInteger()
+ return build.createBinaryPackageRelease(
binarypackagename=binarypackagename, version=version,
- build=build, binpackageformat=binpackageformat,
+ binpackageformat=binpackageformat,
component=component, section=section, priority=priority,
summary=summary, description=description,
- architecturespecific=architecturespecific))
+ architecturespecific=architecturespecific,
+ shlibdeps=shlibdeps, depends=depends, recommends=recommends,
+ suggests=suggests, conflicts=conflicts, replaces=replaces,
+ provides=provides, pre_depends=pre_depends,
+ enhances=enhances, breaks=breaks, essential=essential,
+ installedsize=installed_size)
def makeSection(self, name=None):
"""Make a `Section`."""
=== modified file 'lib/lp/testing/matchers.py'
--- lib/lp/testing/matchers.py 2010-08-02 20:56:25 +0000
+++ lib/lp/testing/matchers.py 2010-08-05 20:54:49 +0000
@@ -3,12 +3,14 @@
__metaclass__ = type
__all__ = [
+ 'DoesNotCorrectlyProvide',
'DoesNotProvide',
- 'DoesNotCorrectlyProvide',
+ 'DoesNotStartWith',
'IsNotProxied',
'IsProxied',
'Provides',
'ProvidesAndIsProxied',
+ 'StartsWith',
]
from zope.interface.verify import verifyObject
@@ -133,3 +135,39 @@
if mismatch is not None:
return mismatch
return IsProxied().match(matchee)
+
+
+class DoesNotStartWith(Mismatch):
+
+ def __init__(self, matchee, expected):
+ """Create a DoesNotStartWith Mismatch.
+
+ :param matchee: the string that did not match.
+ :param expected: the string that `matchee` was expected to start
+ with.
+ """
+ self.matchee = matchee
+ self.expected = expected
+
+ def describe(self):
+ return "'%s' does not start with '%s'." % (
+ self.matchee, self.expected)
+
+
+class StartsWith(Matcher):
+ """Checks whether one string starts with another."""
+
+ def __init__(self, expected):
+ """Create a StartsWith Matcher.
+
+ :param expected: the string that matchees should start with.
+ """
+ self.expected = expected
+
+ def __str__(self):
+ return "Starts with '%s'." % self.expected
+
+ def match(self, matchee):
+ if not matchee.startswith(self.expected):
+ return DoesNotStartWith(matchee, self.expected)
+ return None
=== modified file 'lib/lp/testing/tests/test_factory.py'
--- lib/lp/testing/tests/test_factory.py 2010-08-03 01:28:16 +0000
+++ lib/lp/testing/tests/test_factory.py 2010-08-05 20:54:49 +0000
@@ -17,26 +17,46 @@
DatabaseFunctionalLayer, LaunchpadZopelessLayer)
from lp.buildmaster.interfaces.buildbase import BuildStatus
from lp.code.enums import CodeImportReviewStatus
+from lp.registry.interfaces.distribution import IDistribution
+from lp.registry.interfaces.distroseries import IDistroSeries
from lp.registry.interfaces.sourcepackage import SourcePackageFileType
from lp.registry.interfaces.suitesourcepackage import ISuiteSourcePackage
from lp.services.worlddata.interfaces.language import ILanguage
from lp.soyuz.interfaces.binarypackagebuild import IBinaryPackageBuild
+from lp.soyuz.interfaces.binarypackagename import IBinaryPackageName
from lp.soyuz.interfaces.binarypackagerelease import (
BinaryPackageFileType, IBinaryPackageRelease)
from lp.soyuz.interfaces.files import (
IBinaryPackageFile, ISourcePackageReleaseFile)
from lp.soyuz.interfaces.publishing import (
IBinaryPackagePublishingHistory, ISourcePackagePublishingHistory,
- PackagePublishingPriority, PackagePublishingStatus)
+ PackagePublishingPriority, PackagePublishingPocket,
+ PackagePublishingStatus)
+from lp.soyuz.interfaces.queue import IPackageUpload, PackageUploadStatus
+from lp.soyuz.interfaces.sourcepackagerelease import ISourcePackageRelease
from lp.testing import TestCaseWithFactory
from lp.testing.factory import is_security_proxied_or_harmless
-from lp.testing.matchers import IsProxied, Provides, ProvidesAndIsProxied
+from lp.testing.matchers import (
+ IsProxied, Provides, ProvidesAndIsProxied, StartsWith)
class TestFactory(TestCaseWithFactory):
layer = DatabaseFunctionalLayer
+ # getOrMakeBinaryPackageName
+ def test_getOrMakeBinaryPackageName_returns_proxied_IBPN(self):
+ binarypackagename = self.factory.getOrMakeBinaryPackageName()
+ self.assertThat(
+ binarypackagename, ProvidesAndIsProxied(IBinaryPackageName))
+
+ def test_getOrMakeBinaryPackageName_returns_existing_name(self):
+ binarypackagename1 = self.factory.getOrMakeBinaryPackageName(
+ name="foo")
+ binarypackagename2 = self.factory.getOrMakeBinaryPackageName(
+ name="foo")
+ self.assertEqual(binarypackagename1, binarypackagename2)
+
# loginAsAnyone
def test_loginAsAnyone(self):
# Login as anyone logs you in as any user.
@@ -71,6 +91,12 @@
status=BuildStatus.FULLYBUILT)
self.assertEqual(BuildStatus.FULLYBUILT, bpb.status)
+ # makeBinaryPackageName
+ def test_makeBinaryPackageName_returns_proxied_IBinaryPackageName(self):
+ binarypackagename = self.factory.makeBinaryPackageName()
+ self.assertThat(
+ binarypackagename, ProvidesAndIsProxied(IBinaryPackageName))
+
# makeBinaryPackagePublishingHistory
def test_makeBinaryPackagePublishingHistory_returns_IBPPH(self):
bpph = self.factory.makeBinaryPackagePublishingHistory()
@@ -110,11 +136,153 @@
priority=PackagePublishingPriority.EXTRA)
self.assertEquals(PackagePublishingPriority.EXTRA, bpph.priority)
+ def test_makeBinaryPackagePublishingHistory_sets_datecreated(self):
+ bpph = self.factory.makeBinaryPackagePublishingHistory()
+ self.assertNotEqual(None, bpph.datecreated)
+
+ def test_makeBinaryPackagePublishingHistory_sets_datepub_PENDING(self):
+ bpph = self.factory.makeBinaryPackagePublishingHistory(
+ status=PackagePublishingStatus.PENDING)
+ self.assertEqual(None, bpph.datepublished)
+
+ def test_makeBinaryPackagePublishingHistory_sets_datepub_PUBLISHED(self):
+ bpph = self.factory.makeBinaryPackagePublishingHistory(
+ status=PackagePublishingStatus.PUBLISHED)
+ self.assertNotEqual(None, bpph.datepublished)
+
# makeBinaryPackageRelease
def test_makeBinaryPackageRelease_returns_IBinaryPackageRelease(self):
bpr = self.factory.makeBinaryPackageRelease()
self.assertThat(bpr, ProvidesAndIsProxied(IBinaryPackageRelease))
+ def test_makeBinaryPackageRelease_uses_build(self):
+ build = self.factory.makeBinaryPackageBuild()
+ bpr = self.factory.makeBinaryPackageRelease(build=build)
+ self.assertEqual(build, bpr.build)
+
+ def test_makeBinaryPackageRelease_uses_build_version(self):
+ build = self.factory.makeBinaryPackageBuild()
+ bpr = self.factory.makeBinaryPackageRelease(build=build)
+ self.assertEqual(
+ build.source_package_release.version, bpr.version)
+
+ def test_makeBinaryPackageRelease_uses_build_component(self):
+ build = self.factory.makeBinaryPackageBuild()
+ bpr = self.factory.makeBinaryPackageRelease(build=build)
+ self.assertEqual(
+ build.source_package_release.component, bpr.component)
+
+ def test_makeBinaryPackageRelease_uses_build_section(self):
+ build = self.factory.makeBinaryPackageBuild()
+ bpr = self.factory.makeBinaryPackageRelease(build=build)
+ self.assertEqual(
+ build.source_package_release.section, bpr.section)
+
+ def test_makeBinaryPackageRelease_matches_build_version(self):
+ bpr = self.factory.makeBinaryPackageRelease()
+ self.assertEqual(
+ bpr.build.source_package_release.version, bpr.version)
+
+ def test_makeBinaryPackageRelease_matches_build_component(self):
+ bpr = self.factory.makeBinaryPackageRelease()
+ self.assertEqual(
+ bpr.build.source_package_release.component, bpr.component)
+
+ def test_makeBinaryPackageRelease_matches_build_section(self):
+ bpr = self.factory.makeBinaryPackageRelease()
+ self.assertEqual(
+ bpr.build.source_package_release.section, bpr.section)
+
+ def test_makeBinaryPackageRelease_uses_shlibdeps(self):
+ bpr = self.factory.makeBinaryPackageRelease(shlibdeps="foo bar")
+ self.assertEqual("foo bar", bpr.shlibdeps)
+
+ def test_makeBinaryPackageRelease_allows_None_shlibdeps(self):
+ bpr = self.factory.makeBinaryPackageRelease(shlibdeps=None)
+ self.assertEqual(None, bpr.shlibdeps)
+
+ def test_makeBinaryPackageRelease_uses_depends(self):
+ bpr = self.factory.makeBinaryPackageRelease(depends="apt | bzr")
+ self.assertEqual("apt | bzr", bpr.depends)
+
+ def test_makeBinaryPackageRelease_allows_None_depends(self):
+ bpr = self.factory.makeBinaryPackageRelease(depends=None)
+ self.assertEqual(None, bpr.depends)
+
+ def test_makeBinaryPackageRelease_uses_recommends(self):
+ bpr = self.factory.makeBinaryPackageRelease(recommends="ssss")
+ self.assertEqual("ssss", bpr.recommends)
+
+ def test_makeBinaryPackageRelease_allows_None_recommends(self):
+ bpr = self.factory.makeBinaryPackageRelease(recommends=None)
+ self.assertEqual(None, bpr.recommends)
+
+ def test_makeBinaryPackageRelease_uses_suggests(self):
+ bpr = self.factory.makeBinaryPackageRelease(suggests="ssss")
+ self.assertEqual("ssss", bpr.suggests)
+
+ def test_makeBinaryPackageRelease_allows_None_suggests(self):
+ bpr = self.factory.makeBinaryPackageRelease(suggests=None)
+ self.assertEqual(None, bpr.suggests)
+
+ def test_makeBinaryPackageRelease_uses_conflicts(self):
+ bpr = self.factory.makeBinaryPackageRelease(conflicts="ssss")
+ self.assertEqual("ssss", bpr.conflicts)
+
+ def test_makeBinaryPackageRelease_allows_None_conflicts(self):
+ bpr = self.factory.makeBinaryPackageRelease(conflicts=None)
+ self.assertEqual(None, bpr.conflicts)
+
+ def test_makeBinaryPackageRelease_uses_replaces(self):
+ bpr = self.factory.makeBinaryPackageRelease(replaces="ssss")
+ self.assertEqual("ssss", bpr.replaces)
+
+ def test_makeBinaryPackageRelease_allows_None_replaces(self):
+ bpr = self.factory.makeBinaryPackageRelease(replaces=None)
+ self.assertEqual(None, bpr.replaces)
+
+ def test_makeBinaryPackageRelease_uses_provides(self):
+ bpr = self.factory.makeBinaryPackageRelease(provides="ssss")
+ self.assertEqual("ssss", bpr.provides)
+
+ def test_makeBinaryPackageRelease_allows_None_provides(self):
+ bpr = self.factory.makeBinaryPackageRelease(provides=None)
+ self.assertEqual(None, bpr.provides)
+
+ def test_makeBinaryPackageRelease_uses_pre_depends(self):
+ bpr = self.factory.makeBinaryPackageRelease(pre_depends="ssss")
+ self.assertEqual("ssss", bpr.pre_depends)
+
+ def test_makeBinaryPackageRelease_allows_None_pre_depends(self):
+ bpr = self.factory.makeBinaryPackageRelease(pre_depends=None)
+ self.assertEqual(None, bpr.pre_depends)
+
+ def test_makeBinaryPackageRelease_uses_enhances(self):
+ bpr = self.factory.makeBinaryPackageRelease(enhances="ssss")
+ self.assertEqual("ssss", bpr.enhances)
+
+ def test_makeBinaryPackageRelease_allows_None_enhances(self):
+ bpr = self.factory.makeBinaryPackageRelease(enhances=None)
+ self.assertEqual(None, bpr.enhances)
+
+ def test_makeBinaryPackageRelease_uses_breaks(self):
+ bpr = self.factory.makeBinaryPackageRelease(breaks="ssss")
+ self.assertEqual("ssss", bpr.breaks)
+
+ def test_makeBinaryPackageRelease_allows_None_breaks(self):
+ bpr = self.factory.makeBinaryPackageRelease(breaks=None)
+ self.assertEqual(None, bpr.breaks)
+
+ def test_makeBinaryPackageRelease_uses_essential(self):
+ bpr = self.factory.makeBinaryPackageRelease(essential=True)
+ self.assertEqual(True, bpr.essential)
+ bpr = self.factory.makeBinaryPackageRelease(essential=False)
+ self.assertEqual(False, bpr.essential)
+
+ def test_makeBinaryPackageRelease_uses_installed_size(self):
+ bpr = self.factory.makeBinaryPackageRelease(installed_size=110)
+ self.assertEqual(110, bpr.installedsize)
+
# makeCodeImport
def test_makeCodeImportNoStatus(self):
# If makeCodeImport is not given a review status, it defaults to NEW.
@@ -129,6 +297,52 @@
code_import = self.factory.makeCodeImport(review_status=status)
self.assertEqual(status, code_import.review_status)
+ # makeDistribution
+ def test_makeDistribution_returns_IDistribution(self):
+ distribution = self.factory.makeDistribution()
+ self.assertThat(
+ removeSecurityProxy(distribution), Provides(IDistribution))
+
+ def test_makeDistribution_returns_proxy(self):
+ distribution = self.factory.makeDistribution()
+ self.assertThat(distribution, IsProxied())
+
+ def test_makeDistribution_created_name_starts_with_distribution(self):
+ distribution = self.factory.makeDistribution()
+ self.assertThat(distribution.name, StartsWith("distribution"))
+
+ def test_makeDistribution_created_display_name_starts_Distribution(self):
+ distribution = self.factory.makeDistribution()
+ self.assertThat(distribution.displayname, StartsWith("Distribution"))
+
+ # makeDistroRelease
+ def test_makeDistroRelease_returns_IDistroSeries(self):
+ distroseries = self.factory.makeDistroRelease()
+ self.assertThat(
+ removeSecurityProxy(distroseries), Provides(IDistroSeries))
+
+ def test_makeDistroRelease_returns_proxy(self):
+ distroseries = self.factory.makeDistroRelease()
+ self.assertThat(distroseries, IsProxied())
+
+ # makeDistroSeries
+ def test_makeDistroSeries_returns_IDistroSeries(self):
+ distroseries = self.factory.makeDistroSeries()
+ self.assertThat(
+ removeSecurityProxy(distroseries), Provides(IDistroSeries))
+
+ def test_makeDistroSeries_returns_proxy(self):
+ distroseries = self.factory.makeDistroSeries()
+ self.assertThat(distroseries, IsProxied())
+
+ def test_makeDistroSeries_created_name_starts_with_distroseries(self):
+ distroseries = self.factory.makeDistroSeries()
+ self.assertThat(distroseries.name, StartsWith("distroseries"))
+
+ def test_makeDistroSeries_created_display_name_starts_Distroseries(self):
+ distroseries = self.factory.makeDistroSeries()
+ self.assertThat(distroseries.displayname, StartsWith("Distroseries"))
+
# makeLanguage
def test_makeLanguage(self):
# Without parameters, makeLanguage creates a language with code
@@ -199,6 +413,27 @@
scheduleddeletiondate=scheduleddeletiondate)
self.assertEquals(scheduleddeletiondate, spph.scheduleddeletiondate)
+ def test_makeSourcePackagePublishingHistory_datepublished_PENDING(self):
+ spph = self.factory.makeSourcePackagePublishingHistory(
+ status=PackagePublishingStatus.PENDING)
+ self.assertEquals(None, spph.datepublished)
+
+ def test_makeSourcePackagePublishingHistory_datepublished_PUBLISHED(self):
+ spph = self.factory.makeSourcePackagePublishingHistory(
+ status=PackagePublishingStatus.PUBLISHED)
+ self.assertNotEqual(None, spph.datepublished)
+
+ # makeSourcePackageRelease
+ def test_makeSourcePackageRelease_returns_proxied_ISPR(self):
+ spr = self.factory.makeSourcePackageRelease()
+ self.assertThat(spr, ProvidesAndIsProxied(ISourcePackageRelease))
+
+ def test_makeSourcePackageRelease_uses_dsc_maintainer_rfc822(self):
+ maintainer = "James Westby <james.westby@xxxxxxxxxxxxx>"
+ spr = self.factory.makeSourcePackageRelease(
+ dsc_maintainer_rfc822=maintainer)
+ self.assertEqual(maintainer, spr.dsc_maintainer_rfc822)
+
# makeSuiteSourcePackage
def test_makeSuiteSourcePackage_returns_ISuiteSourcePackage(self):
ssp = self.factory.makeSuiteSourcePackage()
@@ -234,6 +469,59 @@
filetype=BinaryPackageFileType.DDEB)
self.assertEqual(BinaryPackageFileType.DDEB, bpf.filetype)
+ # makePackageUpload
+ def test_makePackageUpload_returns_proxied_IPackageUpload(self):
+ pu = self.factory.makePackageUpload()
+ self.assertThat(pu, ProvidesAndIsProxied(IPackageUpload))
+
+ def test_makePackageUpload_uses_distroseries(self):
+ distroseries = self.factory.makeDistroSeries()
+ pu = self.factory.makePackageUpload(distroseries=distroseries)
+ self.assertEqual(distroseries, pu.distroseries)
+
+ def test_makePackageUpload_uses_archive(self):
+ archive = self.factory.makeArchive()
+ pu = self.factory.makePackageUpload(archive=archive)
+ self.assertEqual(archive, pu.archive)
+
+ def test_makePackageUpload_uses_distribution_of_archive(self):
+ archive = self.factory.makeArchive()
+ pu = self.factory.makePackageUpload(archive=archive)
+ self.assertEqual(archive.distribution, pu.distroseries.distribution)
+
+ def test_makePackageUpload_uses_changes_filename(self):
+ changes_filename = "foo"
+ pu = self.factory.makePackageUpload(changes_filename=changes_filename)
+ self.assertEqual(
+ changes_filename, removeSecurityProxy(pu).changesfile.filename)
+
+ def test_makePackageUpload_uses_pocket(self):
+ pu = self.factory.makePackageUpload(
+ pocket=PackagePublishingPocket.RELEASE)
+ self.assertEqual(PackagePublishingPocket.RELEASE, pu.pocket)
+ pu = self.factory.makePackageUpload(
+ pocket=PackagePublishingPocket.PROPOSED)
+ self.assertEqual(PackagePublishingPocket.PROPOSED, pu.pocket)
+
+ def test_makePackageUpload_uses_signing_key(self):
+ person = self.factory.makePerson()
+ signing_key = self.factory.makeGPGKey(person)
+ pu = self.factory.makePackageUpload(signing_key=signing_key)
+ self.assertEqual(signing_key, pu.signing_key)
+
+ def test_makePackageUpload_allows_None_signing_key(self):
+ pu = self.factory.makePackageUpload(signing_key=None)
+ self.assertEqual(None, pu.signing_key)
+
+ def test_makePackageUpload_sets_status_DONE(self):
+ pu = self.factory.makePackageUpload(status=PackageUploadStatus.DONE)
+ self.assertEqual(PackageUploadStatus.DONE, pu.status)
+
+ def test_makePackageUpload_sets_status_ACCEPTED(self):
+ pu = self.factory.makePackageUpload(
+ status=PackageUploadStatus.ACCEPTED)
+ self.assertEqual(PackageUploadStatus.ACCEPTED, pu.status)
+
# makeSourcePackageReleaseFile
def test_makeSourcePackageReleaseFile_returns_ISPRF(self):
spr_file = self.factory.makeSourcePackageReleaseFile()
=== modified file 'lib/lp/testing/tests/test_matchers.py'
--- lib/lp/testing/tests/test_matchers.py 2010-08-02 19:52:59 +0000
+++ lib/lp/testing/tests/test_matchers.py 2010-08-05 20:54:49 +0000
@@ -11,8 +11,8 @@
from lp.testing import TestCase
from lp.testing.matchers import (
- DoesNotCorrectlyProvide, DoesNotProvide, IsNotProxied, IsProxied,
- Provides, ProvidesAndIsProxied)
+ DoesNotCorrectlyProvide, DoesNotProvide, DoesNotStartWith, IsNotProxied,
+ IsProxied, Provides, ProvidesAndIsProxied, StartsWith)
class ITestInterface(Interface):
@@ -89,8 +89,10 @@
self.assertEqual(ITestInterface, mismatch.interface)
def match_does_not_verify(self):
+
class BadlyImplementedClass:
implements(ITestInterface)
+
obj = BadlyImplementedClass()
matcher = Provides(ITestInterface)
return obj, matcher.match(obj)
@@ -155,7 +157,7 @@
def test_match(self):
obj = ProxyFactory(
- Implementor(), checker=NamesChecker(names=("doFoo",)))
+ Implementor(), checker=NamesChecker(names=("doFoo", )))
matcher = ProvidesAndIsProxied(ITestInterface)
self.assertThat(obj, matcher)
self.assertEqual(None, matcher.match(obj))
@@ -169,3 +171,36 @@
obj = ProxyFactory(object(), checker=NamesChecker())
matcher = ProvidesAndIsProxied(ITestInterface)
self.assertIsInstance(matcher.match(obj), DoesNotProvide)
+
+
+class DoesNotStartWithTests(TestCase):
+
+ def test_describe(self):
+ mismatch = DoesNotStartWith("foo", "bar")
+ self.assertEqual(
+ "'foo' does not start with 'bar'.", mismatch.describe())
+
+
+class StartsWithTests(TestCase):
+
+ def test_str(self):
+ matcher = StartsWith("bar")
+ self.assertEqual("Starts with 'bar'.", str(matcher))
+
+ def test_match(self):
+ matcher = StartsWith("bar")
+ self.assertIs(None, matcher.match("barf"))
+
+ def test_mismatch_returns_does_not_start_with(self):
+ matcher = StartsWith("bar")
+ self.assertIsInstance(matcher.match("foo"), DoesNotStartWith)
+
+ def test_mismatch_sets_matchee(self):
+ matcher = StartsWith("bar")
+ mismatch = matcher.match("foo")
+ self.assertEqual("foo", mismatch.matchee)
+
+ def test_mismatch_sets_expected(self):
+ matcher = StartsWith("bar")
+ mismatch = matcher.match("foo")
+ self.assertEqual("bar", mismatch.expected)
Follow ups