Merge lp:~canonical-ca-hackers/ubuntu-webcatalog/1006442-double-distroseries into lp:ubuntu-webcatalog

Proposed by Łukasz Czyżykowski
Status: Merged
Approved by: Michael Nelson
Approved revision: 135
Merged at revision: 132
Proposed branch: lp:~canonical-ca-hackers/ubuntu-webcatalog/1006442-double-distroseries
Merge into: lp:ubuntu-webcatalog
Diff against target: 67 lines (+31/-4)
3 files modified
src/webcatalog/models/applications.py (+3/-2)
src/webcatalog/tests/test_views.py (+25/-0)
src/webcatalog/views.py (+3/-2)
To merge this branch: bzr merge lp:~canonical-ca-hackers/ubuntu-webcatalog/1006442-double-distroseries
Reviewer Review Type Date Requested Status
Michael Nelson (community) Approve
Review via email: mp+108937@code.launchpad.net

Commit message

Cope with doubled applications in the database.

Description of the change

Overview
========
This branch fixes bug 1006442. It does that by coping with a rather strange condition in the database, because I wasn't able to find the root cause of why the current state was reached.

To post a comment you must log in.
Revision history for this message
Michael Nelson (michael.nelson) wrote :

14:11 < noodles> lukasz: could lines 31 and 41 do the client.get consistently, or are they doing different things?
14:12 < noodles> lukasz: actually, if they're doing the same thing, why do we need the first test? The one test (the second one) ensures that the status is 200 already?
14:12 < lukasz> noodles, yup, one is for app detail within distroseries, second is for general app detail
14:12 < noodles> lukasz: as, got it. +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/webcatalog/models/applications.py'
2--- src/webcatalog/models/applications.py 2012-05-08 06:42:38 +0000
3+++ src/webcatalog/models/applications.py 2012-06-06 13:15:41 +0000
4@@ -140,8 +140,9 @@
5
6 def available_distroseries(self):
7 """Return the set of distroseries for which this app is available"""
8- return DistroSeries.objects.filter(
9- application__package_name=self.package_name).order_by('-code_name')
10+ return (DistroSeries.objects
11+ .filter(application__package_name=self.package_name)
12+ .distinct().order_by('-code_name'))
13
14 def update_departments(self):
15 """Update the list of departments for this app"""
16
17=== modified file 'src/webcatalog/tests/test_views.py'
18--- src/webcatalog/tests/test_views.py 2012-05-31 20:00:27 +0000
19+++ src/webcatalog/tests/test_views.py 2012-06-06 13:15:41 +0000
20@@ -377,6 +377,31 @@
21 self.assertContains(response,
22 '<iframe src="http://example.com/video_iframe.html"')
23
24+ def test_double_entry_in_the_db_is_displayed_sainely(self):
25+ """Make sure that bug:1006442 is fixed"""
26+ app = self.factory.make_application()
27+ self.factory.make_application(
28+ package_name=app.package_name,
29+ distroseries=app.distroseries
30+ )
31+ response = self.client.get(self.get_app_details_url(app))
32+
33+ self.assertEquals(response.status_code, 200)
34+
35+ def test_make_sure_doubled_entry_displays_only_one_distroseries(self):
36+ app = self.factory.make_application()
37+ self.factory.make_application(
38+ package_name=app.package_name,
39+ distroseries=app.distroseries
40+ )
41+ response = self.client.get(
42+ reverse('wc-package-detail', args=[app.package_name]))
43+
44+ ds = "Ubuntu {0} ({1})".format(
45+ app.distroseries.version, app.distroseries.code_name)
46+
47+ self.assertContains(response, ds, 1)
48+
49
50 class ApplicationDetailNoSeriesTestCase(TestCaseWithFactory):
51 def test_renders_latest(self):
52
53=== modified file 'src/webcatalog/views.py'
54--- src/webcatalog/views.py 2012-05-31 19:45:40 +0000
55+++ src/webcatalog/views.py 2012-06-06 13:15:41 +0000
56@@ -194,8 +194,9 @@
57 if distro is None:
58 app = Application.objects.find_best_or_404(package_name=package_name)
59 else:
60- app = get_object_or_404(Application, package_name=package_name,
61- distroseries__code_name=distro)
62+ app = Application.objects.find_best_or_404(
63+ package_name=package_name,
64+ distroseries__code_name=distro)
65 if request.POST:
66 form = EmailDownloadLinkForm(request.POST)
67 if form.is_valid():

Subscribers

People subscribed via source and target branches