launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #04282
[Merge] lp:~stevenk/launchpad/dsp-vocab-use-spn into lp:launchpad
Steve Kowalik has proposed merging lp:~stevenk/launchpad/dsp-vocab-use-spn into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~stevenk/launchpad/dsp-vocab-use-spn/+merge/68046
Rejig the DistributionSourcePackage vocab so that it uses DSPes internally only and expects (and returns) SourcePackageNames.
--
https://code.launchpad.net/~stevenk/launchpad/dsp-vocab-use-spn/+merge/68046
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/dsp-vocab-use-spn into lp:launchpad.
=== modified file 'lib/lp/registry/tests/test_dsp_vocabularies.py'
--- lib/lp/registry/tests/test_dsp_vocabularies.py 2011-06-24 09:28:46 +0000
+++ lib/lp/registry/tests/test_dsp_vocabularies.py 2011-07-15 06:36:39 +0000
@@ -16,19 +16,18 @@
expected."""
layer = DatabaseFunctionalLayer
- def setUp(self):
- super(TestDistributionSourcePackageVocabulary, self).setUp()
- self.vocabulary = DistributionSourcePackageVocabulary()
def test_provides_ihugevocabulary(self):
- self.assertProvides(self.vocabulary, IHugeVocabulary)
+ vocabulary = DistributionSourcePackageVocabulary()
+ self.assertProvides(vocabulary, IHugeVocabulary)
def test_toTerm_unbuilt_dsp(self):
# If the source has no built binaries, the term's value contains a
# string to that effect.
dsp = self.factory.makeDistributionSourcePackage(
sourcepackagename='foo')
- term = self.vocabulary.toTerm(dsp)
+ vocabulary = DistributionSourcePackageVocabulary(dsp.distribution)
+ term = vocabulary.toTerm(dsp.name)
self.assertEqual(dsp.sourcepackagename.name, term.title)
expected_token = '%s-%s' % (dsp.distribution.name, dsp.name)
self.assertEqual(expected_token, term.token)
@@ -41,7 +40,8 @@
dsp = self.factory.makeDistributionSourcePackage(
sourcepackagename=spr.sourcepackagename,
distribution=bpph.distroseries.distribution)
- term = self.vocabulary.toTerm(dsp)
+ vocabulary = DistributionSourcePackageVocabulary(dsp.distribution)
+ term = vocabulary.toTerm(spr.sourcepackagename)
expected_token = '%s-%s' % (dsp.distribution.name, dsp.name)
self.assertEqual(expected_token, term.token)
self.assertEqual(bpph.binary_package_name, term.value)
@@ -61,14 +61,16 @@
self.factory.makeBinaryPackagePublishingHistory(
binarypackagerelease=bpr, distroarchseries=das)
dsp = spr.distrosourcepackage
- term = self.vocabulary.toTerm(dsp)
+ vocabulary = DistributionSourcePackageVocabulary(dsp.distribution)
+ term = vocabulary.toTerm(spr.sourcepackagename)
expected_token = '%s-%s' % (dsp.distribution.name, dsp.name)
self.assertEqual(expected_token, term.token)
self.assertEqual(', '.join(expected_names), term.value)
def test_searchForTerms_None(self):
# Searching for nothing gets you that.
- results = self.vocabulary.searchForTerms()
+ vocabulary = DistributionSourcePackageVocabulary()
+ results = vocabulary.searchForTerms()
self.assertIs(None, results)
def assertTermsEqual(self, expected, actual):
@@ -78,16 +80,14 @@
self.assertEqual(expected.value, actual.value)
def test_searchForTerms_published_source(self):
- # When we search for a source package name that is published, a DSP
- # is returned.
+ # When we search for a source package name that is published, it is
+ # returned.
spph = self.factory.makeSourcePackagePublishingHistory()
vocabulary = DistributionSourcePackageVocabulary(
context=spph.distroseries.distribution)
results = vocabulary.searchForTerms(query=spph.source_package_name)
- dsp = self.factory.makeDistributionSourcePackage(
- sourcepackagename=spph.source_package_name,
- distribution=spph.distroseries.distribution)
- self.assertTermsEqual(vocabulary.toTerm(dsp), results[0])
+ self.assertTermsEqual(
+ vocabulary.toTerm(spph.source_package_name), results[0])
def test_searchForTerms_unpublished_source(self):
# If the source package name isn't published in the distribution,
@@ -108,19 +108,18 @@
self.assertEqual([], list(results))
def test_searchForTerms_published_binary(self):
- # We can search for a binary package name, which returns the DSP.
+ # We can search for a binary package name, which returns the
+ # relevant SPN.
bpph = self.factory.makeBinaryPackagePublishingHistory()
distribution = bpph.distroarchseries.distroseries.distribution
vocabulary = DistributionSourcePackageVocabulary(
context=distribution)
spn = bpph.binarypackagerelease.build.source_package_release.name
- dsp = self.factory.makeDistributionSourcePackage(
- sourcepackagename=spn, distribution=distribution)
results = vocabulary.searchForTerms(query=bpph.binary_package_name)
- self.assertTermsEqual(vocabulary.toTerm(dsp), results[0])
+ self.assertTermsEqual(vocabulary.toTerm(spn), results[0])
def test_searchForTerms_published_multiple_binaries(self):
- # Searching for a subset of a binary package name returns the DSP
+ # Searching for a subset of a binary package name returns the SPN
# that built the binary package.
spn = self.factory.getOrMakeSourcePackageName('xorg')
spr = self.factory.makeSourcePackageRelease(sourcepackagename=spn)
@@ -135,10 +134,7 @@
binarypackagename=bpn, build=bpb)
bpph = self.factory.makeBinaryPackagePublishingHistory(
binarypackagerelease=bpr, distroarchseries=das)
- dsp = self.factory.makeDistributionSourcePackage(
- distribution=das.distroseries.distribution,
- sourcepackagename=spn)
vocabulary = DistributionSourcePackageVocabulary(
context=das.distroseries.distribution)
results = vocabulary.searchForTerms(query='xorg-se')
- self.assertTermsEqual(vocabulary.toTerm(dsp), results[0])
+ self.assertTermsEqual(vocabulary.toTerm(spn), results[0])
=== modified file 'lib/lp/registry/vocabularies.py'
--- lib/lp/registry/vocabularies.py 2011-07-13 11:43:42 +0000
+++ lib/lp/registry/vocabularies.py 2011-07-15 06:36:39 +0000
@@ -1995,9 +1995,9 @@
def __len__(self):
pass
- def toTerm(self, dsp):
+ def toTerm(self, spn):
"""See `IVocabulary`."""
- # SimpleTerm(value, token=None, title=None)
+ dsp = self.context.getSourcePackage(spn)
if dsp.publishing_history:
binaries = dsp.publishing_history[0].getBuiltBinaries()
summary = ', '.join(
@@ -2007,9 +2007,9 @@
token = '%s-%s' % (dsp.distribution.name, dsp.name)
return SimpleTerm(summary, token, dsp.name)
- def getTerm(self, dsp):
+ def getTerm(self, spn):
"""See `IBaseVocabulary`."""
- return self.toTerm(dsp)
+ return self.toTerm(spn)
def getTermByToken(self, token):
"""See `IVocabularyTokenized`."""
@@ -2059,5 +2059,4 @@
SourcePackageName.name.contains_string(search_term),
BinaryPackageName.name.contains_string(
search_term))).config(distinct=True)
- return [
- self.toTerm(distribution.getSourcePackage(spn)) for spn in spns]
+ return [self.toTerm(spn) for spn in spns]