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
=== modified file 'src/webcatalog/models/applications.py'
--- src/webcatalog/models/applications.py 2012-05-08 06:42:38 +0000
+++ src/webcatalog/models/applications.py 2012-06-06 13:15:41 +0000
@@ -140,8 +140,9 @@
140140
141 def available_distroseries(self):141 def available_distroseries(self):
142 """Return the set of distroseries for which this app is available"""142 """Return the set of distroseries for which this app is available"""
143 return DistroSeries.objects.filter(143 return (DistroSeries.objects
144 application__package_name=self.package_name).order_by('-code_name')144 .filter(application__package_name=self.package_name)
145 .distinct().order_by('-code_name'))
145146
146 def update_departments(self):147 def update_departments(self):
147 """Update the list of departments for this app"""148 """Update the list of departments for this app"""
148149
=== modified file 'src/webcatalog/tests/test_views.py'
--- src/webcatalog/tests/test_views.py 2012-05-31 20:00:27 +0000
+++ src/webcatalog/tests/test_views.py 2012-06-06 13:15:41 +0000
@@ -377,6 +377,31 @@
377 self.assertContains(response,377 self.assertContains(response,
378 '<iframe src="http://example.com/video_iframe.html"')378 '<iframe src="http://example.com/video_iframe.html"')
379379
380 def test_double_entry_in_the_db_is_displayed_sainely(self):
381 """Make sure that bug:1006442 is fixed"""
382 app = self.factory.make_application()
383 self.factory.make_application(
384 package_name=app.package_name,
385 distroseries=app.distroseries
386 )
387 response = self.client.get(self.get_app_details_url(app))
388
389 self.assertEquals(response.status_code, 200)
390
391 def test_make_sure_doubled_entry_displays_only_one_distroseries(self):
392 app = self.factory.make_application()
393 self.factory.make_application(
394 package_name=app.package_name,
395 distroseries=app.distroseries
396 )
397 response = self.client.get(
398 reverse('wc-package-detail', args=[app.package_name]))
399
400 ds = "Ubuntu {0} ({1})".format(
401 app.distroseries.version, app.distroseries.code_name)
402
403 self.assertContains(response, ds, 1)
404
380405
381class ApplicationDetailNoSeriesTestCase(TestCaseWithFactory):406class ApplicationDetailNoSeriesTestCase(TestCaseWithFactory):
382 def test_renders_latest(self):407 def test_renders_latest(self):
383408
=== modified file 'src/webcatalog/views.py'
--- src/webcatalog/views.py 2012-05-31 19:45:40 +0000
+++ src/webcatalog/views.py 2012-06-06 13:15:41 +0000
@@ -194,8 +194,9 @@
194 if distro is None:194 if distro is None:
195 app = Application.objects.find_best_or_404(package_name=package_name)195 app = Application.objects.find_best_or_404(package_name=package_name)
196 else:196 else:
197 app = get_object_or_404(Application, package_name=package_name,197 app = Application.objects.find_best_or_404(
198 distroseries__code_name=distro)198 package_name=package_name,
199 distroseries__code_name=distro)
199 if request.POST:200 if request.POST:
200 form = EmailDownloadLinkForm(request.POST)201 form = EmailDownloadLinkForm(request.POST)
201 if form.is_valid():202 if form.is_valid():

Subscribers

People subscribed via source and target branches