launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #08982
[Merge] lp:~stevenk/launchpad/archive-empty-description-vocab into lp:launchpad
Steve Kowalik has proposed merging lp:~stevenk/launchpad/archive-empty-description-vocab into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~stevenk/launchpad/archive-empty-description-vocab/+merge/111118
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.
--
https://code.launchpad.net/~stevenk/launchpad/archive-empty-description-vocab/+merge/111118
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/archive-empty-description-vocab into lp:launchpad.
=== added file 'lib/lp/soyuz/tests/test_vocabularies.py'
--- lib/lp/soyuz/tests/test_vocabularies.py 1970-01-01 00:00:00 +0000
+++ lib/lp/soyuz/tests/test_vocabularies.py 2012-06-19 23:00:34 +0000
@@ -0,0 +1,30 @@
+# Copyright 2012 Canonical Ltd. This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Test Soyuz vocabularies."""
+
+__metaclass__ = type
+
+from zope.schema.vocabulary import SimpleTerm
+
+from testtools.matchers import MatchesStructure
+
+from lp.soyuz.vocabularies import PPAVocabulary
+from lp.testing import TestCaseWithFactory
+from lp.testing.layers import DatabaseFunctionalLayer
+
+
+class TestPPAVocabulary(TestCaseWithFactory):
+
+ layer = DatabaseFunctionalLayer
+
+ def test_toTerm_empty_description(self):
+ archive = self.factory.makeArchive(description='')
+ vocab = PPAVocabulary()
+ token = '%s/%s' % (archive.owner.name, archive.name)
+ description = 'No description available'
+ term = vocab.toTerm(archive)
+ self.assertThat(term, MatchesStructure.byEquality(
+ value=archive,
+ token=token,
+ title=description))
=== modified file 'lib/lp/soyuz/vocabularies.py'
--- lib/lp/soyuz/vocabularies.py 2011-12-30 06:14:56 +0000
+++ lib/lp/soyuz/vocabularies.py 2012-06-19 23:00:34 +0000
@@ -101,7 +101,7 @@
def toTerm(self, archive):
"""See `IVocabulary`."""
description = archive.description
- if description is not None:
+ if description:
summary = description.splitlines()[0]
else:
summary = "No description available"
Follow ups