Merge lp:~stevenk/launchpad/archive-empty-description-vocab into lp:launchpad

Proposed by Steve Kowalik on 2012-06-19
Status: Merged
Approved by: Steve Kowalik on 2012-06-20
Approved revision: no longer in the source branch.
Merged at revision: 15452
Proposed branch: lp:~stevenk/launchpad/archive-empty-description-vocab
Merge into: lp:launchpad
Diff against target: 45 lines (+29/-1)
2 files modified
lib/lp/soyuz/tests/test_vocabularies.py (+28/-0)
lib/lp/soyuz/vocabularies.py (+1/-1)
To merge this branch: bzr merge lp:~stevenk/launchpad/archive-empty-description-vocab
Reviewer Review Type Date Requested Status
Ian Booth (community) 2012-06-19 Approve on 2012-06-20
Review via email: mp+111118@code.launchpad.net

Commit Message

Deal correctly with a PPA's description being the empty string rather than only unset in the PPA vocab.

Description of the Change

If a PPA's description is "" (IE, the empty string), rather than None, the PPA Vocab tosses an IndexError, which just results in an OOPS inside the picker, which is just awesome. Even more awesome, it seems to me that none of the Soyuz vocabs have any tests at all. I have added a test for this case, and fixed it.

To post a comment you must log in.
Ian Booth (wallyworld) wrote :

Looks ok. SHame about there being no other soyuz vocab test cases to add the new test to.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'lib/lp/soyuz/tests/test_vocabularies.py'
2--- lib/lp/soyuz/tests/test_vocabularies.py 1970-01-01 00:00:00 +0000
3+++ lib/lp/soyuz/tests/test_vocabularies.py 2012-06-19 23:15:28 +0000
4@@ -0,0 +1,28 @@
5+# Copyright 2012 Canonical Ltd. This software is licensed under the
6+# GNU Affero General Public License version 3 (see the file LICENSE).
7+
8+"""Test Soyuz vocabularies."""
9+
10+__metaclass__ = type
11+
12+from zope.schema.vocabulary import SimpleTerm
13+
14+from testtools.matchers import MatchesStructure
15+
16+from lp.soyuz.vocabularies import PPAVocabulary
17+from lp.testing import TestCaseWithFactory
18+from lp.testing.layers import DatabaseFunctionalLayer
19+
20+
21+class TestPPAVocabulary(TestCaseWithFactory):
22+
23+ layer = DatabaseFunctionalLayer
24+
25+ def test_toTerm_empty_description(self):
26+ archive = self.factory.makeArchive(description='')
27+ vocab = PPAVocabulary()
28+ term = vocab.toTerm(archive)
29+ self.assertThat(term, MatchesStructure.byEquality(
30+ value=archive,
31+ token='%s/%s' % (archive.owner.name, archive.name),
32+ title='No description available'))
33
34=== modified file 'lib/lp/soyuz/vocabularies.py'
35--- lib/lp/soyuz/vocabularies.py 2011-12-30 06:14:56 +0000
36+++ lib/lp/soyuz/vocabularies.py 2012-06-19 23:15:28 +0000
37@@ -101,7 +101,7 @@
38 def toTerm(self, archive):
39 """See `IVocabulary`."""
40 description = archive.description
41- if description is not None:
42+ if description:
43 summary = description.splitlines()[0]
44 else:
45 summary = "No description available"