Merge lp:~michael.nelson/ubuntu-webcatalog/1009734-wrong-version into lp:ubuntu-webcatalog

Proposed by Michael Nelson
Status: Merged
Approved by: Danny Tamez
Approved revision: 148
Merged at revision: 147
Proposed branch: lp:~michael.nelson/ubuntu-webcatalog/1009734-wrong-version
Merge into: lp:ubuntu-webcatalog
Diff against target: 72 lines (+29/-8)
2 files modified
src/webcatalog/forms.py (+1/-1)
src/webcatalog/tests/test_commands.py (+28/-7)
To merge this branch: bzr merge lp:~michael.nelson/ubuntu-webcatalog/1009734-wrong-version
Reviewer Review Type Date Requested Status
Danny Tamez (community) Approve
Review via email: mp+111165@code.launchpad.net

Commit message

Don't overwrite correct version with desktop file format version.

Description of the change

Overview
========

After getting the correct apt version of a package from the apt-cache, processing a desktop file was overwriting this with the desktop file format version, as the model-form wasn't excluding the 'version' attribute from the fields to be updated.

`fab test`

To post a comment you must log in.
Revision history for this message
Danny Tamez (zematynnad) wrote :

Looks good noodles

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/webcatalog/forms.py'
2--- src/webcatalog/forms.py 2012-06-13 08:55:00 +0000
3+++ src/webcatalog/forms.py 2012-06-20 07:57:20 +0000
4@@ -62,7 +62,7 @@
5
6 class Meta:
7 model = Application
8- exclude = ('for_purchase', 'archive_id', 'price')
9+ exclude = ('for_purchase', 'archive_id', 'price', 'version')
10
11 @classmethod
12 def get_form_from_desktop_data(cls, str_data, distroseries):
13
14=== modified file 'src/webcatalog/tests/test_commands.py'
15--- src/webcatalog/tests/test_commands.py 2012-06-19 16:52:32 +0000
16+++ src/webcatalog/tests/test_commands.py 2012-06-20 07:57:20 +0000
17@@ -454,27 +454,48 @@
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+ def _make_desktop_file(self, package_name,
25+ screenshot_url='http://example.com',
26+ desktop_file_version="1.0"):
27 desktop_file = tempfile.mktemp()
28 self.addCleanup(os.remove, desktop_file)
29
30 with open(desktop_file, 'w') as f:
31 f.write("""[Desktop Entry]
32-X-AppInstall-Package=foo
33+X-AppInstall-Package=%s
34 X-AppInstall-Popcon=149803
35 X-AppInstall-Section=main
36-Version=1.0
37+Version=%s
38 Name=Foo Bar Baz
39-X-AppInstall-Screenshot-Url=http://foo.com
40+X-AppInstall-Screenshot-Url=%s
41 X-Ubuntu-Gettext-Domain=app-install-data
42-""")
43+""" % (package_name, desktop_file_version, screenshot_url))
44+ return desktop_file
45+
46+ def test_process_desktop_file_with_screenshot_url(self):
47+ """When processing a desktop file, handle if screenshot_url is set."""
48+ command = import_app_install_data.Command()
49+ desktop_file = self._make_desktop_file(
50+ 'foo', screenshot_url='http://foo.com')
51
52 distroseries = self.factory.make_distroseries()
53 command.process_desktop_file(desktop_file, '', distroseries)
54 # no breakage!
55
56+ def test_process_desktop_file_doesnt_override_version(self):
57+ distroseries=self.factory.make_distroseries(code_name='natty')
58+ app = self.factory.make_application(
59+ package_name='inkscape', version="1.6.3a123",
60+ distroseries=distroseries)
61+ desktop_file = self._make_desktop_file('inkscape',
62+ desktop_file_version="1.0")
63+
64+ command = import_app_install_data.Command()
65+ command.process_desktop_file(desktop_file, '', distroseries)
66+
67+ app = Application.objects.get(id=app.id)
68+ self.assertEqual("1.6.3a123", app.version)
69+
70 @patch('urllib.urlopen')
71 def test_fetch_icon_from_extras(self, mock_urlopen):
72 mock_urlopen.return_value.getcode.return_value = 200

Subscribers

People subscribed via source and target branches