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
1=== modified file 'src/webcatalog/forms.py'
2--- src/webcatalog/forms.py 2012-06-06 17:42:04 +0000
3+++ src/webcatalog/forms.py 2012-06-14 08:38:18 +0000
4@@ -128,6 +128,12 @@
5 screenshot_urls = MultiURLField(required=False)
6 video_embedded_html_urls = MultiURLField(required=False)
7
8+ def clean_archive_id(self):
9+ archive_id = self.cleaned_data.get('archive_id')
10+ if not archive_id:
11+ return None
12+ return archive_id
13+
14 class Meta:
15 model = Application
16 exclude = ('section', 'popcon')
17
18=== modified file 'src/webcatalog/tests/test_commands.py'
19--- src/webcatalog/tests/test_commands.py 2012-06-06 18:00:26 +0000
20+++ src/webcatalog/tests/test_commands.py 2012-06-14 08:38:18 +0000
21@@ -623,8 +623,8 @@
22
23 arb_apps = Application.objects.filter(package_name='eg_arb_app')
24 self.assertEqual(2, arb_apps.count())
25- self.assertEqual('', arb_apps[0].archive_id)
26- self.assertEqual('', arb_apps[1].archive_id)
27+ self.assertEqual(None, arb_apps[0].archive_id)
28+ self.assertEqual(None, arb_apps[1].archive_id)
29
30 def test_import_arb_app_handle_existing_none_archive_id(self):
31 precise = self.factory.make_distroseries(code_name='precise')
32
33=== modified file 'src/webcatalog/tests/test_forms.py'
34--- src/webcatalog/tests/test_forms.py 2012-06-06 18:00:26 +0000
35+++ src/webcatalog/tests/test_forms.py 2012-06-14 08:38:18 +0000
36@@ -274,6 +274,17 @@
37 app_reloaded = Application.objects.get(id=existing_app.id)
38 self.assertEqual(21, app_reloaded.application_id)
39
40+ def test_archive_id_is_set_to_none_when_supplied_as_empty_str(self):
41+ """Check that bug 1010655 is not happening again."""
42+ precise = self.factory.make_distroseries(code_name='precise')
43+ self.factory.make_application(archive_id='', distroseries=precise)
44+
45+ data = self.make_valid_data(archive_id='')
46+
47+ form = ForPurchaseApplicationForm.from_api_data(data, precise)
48+
49+ self.assertTrue(form.is_valid())
50+
51
52 class MultiURLFieldTestCase(TestCase):
53

Subscribers

People subscribed via source and target branches