Merge lp:~canonical-ca-hackers/ubuntu-webcatalog/1010655-several-issues-with-qreator into lp:ubuntu-webcatalog

Proposed by Łukasz Czyżykowski
Status: Merged
Approved by: Anthony Lenton
Approved revision: 142
Merged at revision: 141
Proposed branch: lp:~canonical-ca-hackers/ubuntu-webcatalog/1010655-several-issues-with-qreator
Merge into: lp:ubuntu-webcatalog
Diff against target: 52 lines (+19/-2)
3 files modified
src/webcatalog/forms.py (+6/-0)
src/webcatalog/tests/test_commands.py (+2/-2)
src/webcatalog/tests/test_forms.py (+11/-0)
To merge this branch: bzr merge lp:~canonical-ca-hackers/ubuntu-webcatalog/1010655-several-issues-with-qreator
Reviewer Review Type Date Requested Status
Anthony Lenton (community) Approve
Review via email: mp+110258@code.launchpad.net

Commit message

Fix problem with importing apps with archive_id = ''.

Description of the change

Overview
========
This branch fixes problem for apps which are pulled from MyApps in the case when they are missing archive_id. Until this branch, there could be only one app per distroseries with archive_id = '', which caused all following import tries to fail due to unique_together constrain. Making sure this field is always None in those cases makes it possible to successfully import them.

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/forms.py'
--- src/webcatalog/forms.py 2012-06-06 17:42:04 +0000
+++ src/webcatalog/forms.py 2012-06-14 08:38:18 +0000
@@ -128,6 +128,12 @@
128 screenshot_urls = MultiURLField(required=False)128 screenshot_urls = MultiURLField(required=False)
129 video_embedded_html_urls = MultiURLField(required=False)129 video_embedded_html_urls = MultiURLField(required=False)
130130
131 def clean_archive_id(self):
132 archive_id = self.cleaned_data.get('archive_id')
133 if not archive_id:
134 return None
135 return archive_id
136
131 class Meta:137 class Meta:
132 model = Application138 model = Application
133 exclude = ('section', 'popcon')139 exclude = ('section', 'popcon')
134140
=== modified file 'src/webcatalog/tests/test_commands.py'
--- src/webcatalog/tests/test_commands.py 2012-06-06 18:00:26 +0000
+++ src/webcatalog/tests/test_commands.py 2012-06-14 08:38:18 +0000
@@ -623,8 +623,8 @@
623623
624 arb_apps = Application.objects.filter(package_name='eg_arb_app')624 arb_apps = Application.objects.filter(package_name='eg_arb_app')
625 self.assertEqual(2, arb_apps.count())625 self.assertEqual(2, arb_apps.count())
626 self.assertEqual('', arb_apps[0].archive_id)626 self.assertEqual(None, arb_apps[0].archive_id)
627 self.assertEqual('', arb_apps[1].archive_id)627 self.assertEqual(None, arb_apps[1].archive_id)
628628
629 def test_import_arb_app_handle_existing_none_archive_id(self):629 def test_import_arb_app_handle_existing_none_archive_id(self):
630 precise = self.factory.make_distroseries(code_name='precise')630 precise = self.factory.make_distroseries(code_name='precise')
631631
=== modified file 'src/webcatalog/tests/test_forms.py'
--- src/webcatalog/tests/test_forms.py 2012-06-06 18:00:26 +0000
+++ src/webcatalog/tests/test_forms.py 2012-06-14 08:38:18 +0000
@@ -274,6 +274,17 @@
274 app_reloaded = Application.objects.get(id=existing_app.id)274 app_reloaded = Application.objects.get(id=existing_app.id)
275 self.assertEqual(21, app_reloaded.application_id)275 self.assertEqual(21, app_reloaded.application_id)
276276
277 def test_archive_id_is_set_to_none_when_supplied_as_empty_str(self):
278 """Check that bug 1010655 is not happening again."""
279 precise = self.factory.make_distroseries(code_name='precise')
280 self.factory.make_application(archive_id='', distroseries=precise)
281
282 data = self.make_valid_data(archive_id='')
283
284 form = ForPurchaseApplicationForm.from_api_data(data, precise)
285
286 self.assertTrue(form.is_valid())
287
277288
278class MultiURLFieldTestCase(TestCase):289class MultiURLFieldTestCase(TestCase):
279290

Subscribers

People subscribed via source and target branches