Merge lp:~nataliabidart/ubuntu-webcatalog/fix-constraints into lp:ubuntu-webcatalog

Proposed by Natalia Bidart
Status: Merged
Approved by: Anthony Lenton
Approved revision: 108
Merged at revision: 108
Proposed branch: lp:~nataliabidart/ubuntu-webcatalog/fix-constraints
Merge into: lp:ubuntu-webcatalog
Diff against target: 43 lines (+22/-1)
2 files modified
src/webcatalog/management/commands/import_app_install_data.py (+1/-1)
src/webcatalog/tests/test_commands.py (+21/-0)
To merge this branch: bzr merge lp:~nataliabidart/ubuntu-webcatalog/fix-constraints
Reviewer Review Type Date Requested Status
Anthony Lenton (community) Approve
Review via email: mp+102768@code.launchpad.net

Commit message

- While running import_app_install_data, commit the saving of an
  ApplicationForm to avoid IntegrityError (LP: #985901).

To post a comment you must log in.
Revision history for this message
Anthony Lenton (elachuni) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/webcatalog/management/commands/import_app_install_data.py'
--- src/webcatalog/management/commands/import_app_install_data.py 2012-04-18 21:27:46 +0000
+++ src/webcatalog/management/commands/import_app_install_data.py 2012-04-19 21:37:20 +0000
@@ -189,7 +189,7 @@
189 form = ApplicationForm.get_form_from_desktop_data(data, distroseries)189 form = ApplicationForm.get_form_from_desktop_data(data, distroseries)
190190
191 if form.is_valid():191 if form.is_valid():
192 app = form.save(commit=False)192 app = form.save()
193 app.distroseries = distroseries193 app.distroseries = distroseries
194 app.save()194 app.save()
195 app.update_departments()195 app.update_departments()
196196
=== modified file 'src/webcatalog/tests/test_commands.py'
--- src/webcatalog/tests/test_commands.py 2012-04-18 21:27:46 +0000
+++ src/webcatalog/tests/test_commands.py 2012-04-19 21:37:20 +0000
@@ -411,6 +411,27 @@
411 firefox = Application.objects.get(package_name='firefox')411 firefox = Application.objects.get(package_name='firefox')
412 self.assertEqual(self.FIREFOX_DESCRIPTION, firefox.description)412 self.assertEqual(self.FIREFOX_DESCRIPTION, firefox.description)
413413
414 def test_process_desktop_file_with_screenshot_url(self):
415 """When processing a desktop file, handle if screenshot_url is set."""
416 command = import_app_install_data.Command()
417 desktop_file = tempfile.mktemp()
418 self.addCleanup(os.remove, desktop_file)
419
420 with open(desktop_file, 'w') as f:
421 f.write("""[Desktop Entry]
422X-AppInstall-Package=foo
423X-AppInstall-Popcon=149803
424X-AppInstall-Section=main
425Version=1.0
426Name=Foo Bar Baz
427X-AppInstall-Screenshot-Url=http://foo.com
428X-Ubuntu-Gettext-Domain=app-install-data
429""")
430
431 distroseries = self.factory.make_distroseries()
432 command.process_desktop_file(desktop_file, '', distroseries)
433 # no breakage!
434
414435
415class ImportForPurchaseAppsTestCase(TestCaseWithFactory):436class ImportForPurchaseAppsTestCase(TestCaseWithFactory):
416437

Subscribers

People subscribed via source and target branches