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
1=== modified file 'src/webcatalog/management/commands/import_app_install_data.py'
2--- src/webcatalog/management/commands/import_app_install_data.py 2012-04-18 21:27:46 +0000
3+++ src/webcatalog/management/commands/import_app_install_data.py 2012-04-19 21:37:20 +0000
4@@ -189,7 +189,7 @@
5 form = ApplicationForm.get_form_from_desktop_data(data, distroseries)
6
7 if form.is_valid():
8- app = form.save(commit=False)
9+ app = form.save()
10 app.distroseries = distroseries
11 app.save()
12 app.update_departments()
13
14=== modified file 'src/webcatalog/tests/test_commands.py'
15--- src/webcatalog/tests/test_commands.py 2012-04-18 21:27:46 +0000
16+++ src/webcatalog/tests/test_commands.py 2012-04-19 21:37:20 +0000
17@@ -411,6 +411,27 @@
18 firefox = Application.objects.get(package_name='firefox')
19 self.assertEqual(self.FIREFOX_DESCRIPTION, firefox.description)
20
21+ def test_process_desktop_file_with_screenshot_url(self):
22+ """When processing a desktop file, handle if screenshot_url is set."""
23+ command = import_app_install_data.Command()
24+ desktop_file = tempfile.mktemp()
25+ self.addCleanup(os.remove, desktop_file)
26+
27+ with open(desktop_file, 'w') as f:
28+ f.write("""[Desktop Entry]
29+X-AppInstall-Package=foo
30+X-AppInstall-Popcon=149803
31+X-AppInstall-Section=main
32+Version=1.0
33+Name=Foo Bar Baz
34+X-AppInstall-Screenshot-Url=http://foo.com
35+X-Ubuntu-Gettext-Domain=app-install-data
36+""")
37+
38+ distroseries = self.factory.make_distroseries()
39+ command.process_desktop_file(desktop_file, '', distroseries)
40+ # no breakage!
41+
42
43 class ImportForPurchaseAppsTestCase(TestCaseWithFactory):
44

Subscribers

People subscribed via source and target branches