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
=== modified file 'src/webcatalog/forms.py'
--- src/webcatalog/forms.py 2012-06-13 08:55:00 +0000
+++ src/webcatalog/forms.py 2012-06-20 07:57:20 +0000
@@ -62,7 +62,7 @@
6262
63 class Meta:63 class Meta:
64 model = Application64 model = Application
65 exclude = ('for_purchase', 'archive_id', 'price')65 exclude = ('for_purchase', 'archive_id', 'price', 'version')
6666
67 @classmethod67 @classmethod
68 def get_form_from_desktop_data(cls, str_data, distroseries):68 def get_form_from_desktop_data(cls, str_data, distroseries):
6969
=== modified file 'src/webcatalog/tests/test_commands.py'
--- src/webcatalog/tests/test_commands.py 2012-06-19 16:52:32 +0000
+++ src/webcatalog/tests/test_commands.py 2012-06-20 07:57:20 +0000
@@ -454,27 +454,48 @@
454 firefox = Application.objects.get(package_name='firefox')454 firefox = Application.objects.get(package_name='firefox')
455 self.assertEqual(self.FIREFOX_DESCRIPTION, firefox.description)455 self.assertEqual(self.FIREFOX_DESCRIPTION, firefox.description)
456456
457 def test_process_desktop_file_with_screenshot_url(self):457 def _make_desktop_file(self, package_name,
458 """When processing a desktop file, handle if screenshot_url is set."""458 screenshot_url='http://example.com',
459 command = import_app_install_data.Command()459 desktop_file_version="1.0"):
460 desktop_file = tempfile.mktemp()460 desktop_file = tempfile.mktemp()
461 self.addCleanup(os.remove, desktop_file)461 self.addCleanup(os.remove, desktop_file)
462462
463 with open(desktop_file, 'w') as f:463 with open(desktop_file, 'w') as f:
464 f.write("""[Desktop Entry]464 f.write("""[Desktop Entry]
465X-AppInstall-Package=foo465X-AppInstall-Package=%s
466X-AppInstall-Popcon=149803466X-AppInstall-Popcon=149803
467X-AppInstall-Section=main467X-AppInstall-Section=main
468Version=1.0468Version=%s
469Name=Foo Bar Baz469Name=Foo Bar Baz
470X-AppInstall-Screenshot-Url=http://foo.com470X-AppInstall-Screenshot-Url=%s
471X-Ubuntu-Gettext-Domain=app-install-data471X-Ubuntu-Gettext-Domain=app-install-data
472""")472""" % (package_name, desktop_file_version, screenshot_url))
473 return desktop_file
474
475 def test_process_desktop_file_with_screenshot_url(self):
476 """When processing a desktop file, handle if screenshot_url is set."""
477 command = import_app_install_data.Command()
478 desktop_file = self._make_desktop_file(
479 'foo', screenshot_url='http://foo.com')
473480
474 distroseries = self.factory.make_distroseries()481 distroseries = self.factory.make_distroseries()
475 command.process_desktop_file(desktop_file, '', distroseries)482 command.process_desktop_file(desktop_file, '', distroseries)
476 # no breakage!483 # no breakage!
477484
485 def test_process_desktop_file_doesnt_override_version(self):
486 distroseries=self.factory.make_distroseries(code_name='natty')
487 app = self.factory.make_application(
488 package_name='inkscape', version="1.6.3a123",
489 distroseries=distroseries)
490 desktop_file = self._make_desktop_file('inkscape',
491 desktop_file_version="1.0")
492
493 command = import_app_install_data.Command()
494 command.process_desktop_file(desktop_file, '', distroseries)
495
496 app = Application.objects.get(id=app.id)
497 self.assertEqual("1.6.3a123", app.version)
498
478 @patch('urllib.urlopen')499 @patch('urllib.urlopen')
479 def test_fetch_icon_from_extras(self, mock_urlopen):500 def test_fetch_icon_from_extras(self, mock_urlopen):
480 mock_urlopen.return_value.getcode.return_value = 200501 mock_urlopen.return_value.getcode.return_value = 200

Subscribers

People subscribed via source and target branches