Merge lp:~rvb/launchpad/bug-803482 into lp:launchpad

Proposed by Raphaël Badin
Status: Merged
Approved by: Raphaël Badin
Approved revision: no longer in the source branch.
Merged at revision: 13328
Proposed branch: lp:~rvb/launchpad/bug-803482
Merge into: lp:launchpad
Diff against target: 41 lines (+15/-2)
2 files modified
lib/lp/registry/tests/test_distroseries_vocabularies.py (+13/-0)
lib/lp/registry/vocabularies.py (+2/-2)
To merge this branch: bzr merge lp:~rvb/launchpad/bug-803482
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+66329@code.launchpad.net

Commit message

[r=allenap][bug=803482] Remove duplicates from DistroSeriesDerivationVocabulary.

Description of the change

This branches fixes the DistroSeriesDerivationVocabulary to remove duplicates in it.

= Test =

./bin/test -cvv test_distroseries_vocabularies test_no_duplicates

= Q/A =

- Go to: https://dogfood.launchpad.net/demodist/demoseries/+initseries;
- Click add a parent a look for "Natt";
- Only one instance of Natty should show up.

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/tests/test_distroseries_vocabularies.py'
2--- lib/lp/registry/tests/test_distroseries_vocabularies.py 2011-06-16 16:28:28 +0000
3+++ lib/lp/registry/tests/test_distroseries_vocabularies.py 2011-06-29 15:06:14 +0000
4@@ -226,3 +226,16 @@
5 with StormStatementRecorder() as recorder:
6 DistroSeriesDerivationVocabulary(distroseries).terms
7 self.assertThat(recorder, HasQueryCount(Equals(2)))
8+
9+ def test_no_duplicates(self):
10+ # No duplicates are present in the returned vocabulary.
11+ distroseries = self.makeDistroSeriesWithDistroArch()
12+ vocabulary = DistroSeriesDerivationVocabulary(distroseries)
13+ expected_distroseries = (
14+ set(self.all_series_with_arch).difference(
15+ distroseries.distribution.series))
16+ observed_distroseries = [term.value for term in vocabulary]
17+
18+ self.assertContentEqual(
19+ expected_distroseries,
20+ observed_distroseries)
21
22=== modified file 'lib/lp/registry/vocabularies.py'
23--- lib/lp/registry/vocabularies.py 2011-06-24 13:40:28 +0000
24+++ lib/lp/registry/vocabularies.py 2011-06-29 15:06:14 +0000
25@@ -1819,7 +1819,7 @@
26 *where)
27 query = query.order_by(
28 Distribution.displayname,
29- Desc(DistroSeries.date_created))
30+ Desc(DistroSeries.date_created)).config(distinct=True)
31 return [series for (series, distribution) in query]
32
33 def searchParents(self, query=None):
34@@ -1962,7 +1962,7 @@
35 # package names are always lowercase.
36 return super(SourcePackageNameVocabulary, self).getTermByToken(
37 token.lower())
38-
39+
40
41 class DistributionSourcePackageVocabulary:
42