[entities] fix dc_title output for bool(value) == False
Closes #5194853.
--- a/entities/__init__.py Fri May 15 18:06:03 2015 +0200
+++ b/entities/__init__.py Wed Apr 15 22:48:20 2015 +0200
@@ -68,7 +68,7 @@
if rschema.meta:
continue
value = self.cw_attr_value(rschema.type)
- if value:
+ if value is not None:
# make the value printable (dates, floats, bytes, etc.)
return self.printable_value(rschema.type, value, attrschema.type,
format='text/plain')
--- a/entities/test/data/schema.py Fri May 15 18:06:03 2015 +0200
+++ b/entities/test/data/schema.py Wed Apr 15 22:48:20 2015 +0200
@@ -17,10 +17,11 @@
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
"""entities tests schema"""
-from yams.buildobjs import EntityType, String, RichString
+from yams.buildobjs import EntityType, String, RichString, Int
from cubicweb.schema import make_workflowable
class Company(EntityType):
+ order = Int()
name = String()
description = RichString()
--- a/entities/test/unittest_base.py Fri May 15 18:06:03 2015 +0200
+++ b/entities/test/unittest_base.py Wed Apr 15 22:48:20 2015 +0200
@@ -137,6 +137,12 @@
self.assertEqual(e.dc_title(), 'member')
self.assertEqual(e.name(), u'bouah lôt')
+ def test_falsey_dc_title(self):
+ with self.admin_access.repo_cnx() as cnx:
+ e = cnx.create_entity('Company', order=0, name=u'pythonian')
+ cnx.commit()
+ self.assertEqual(u'0', e.dc_title())
+
def test_allowed_massmail_keys(self):
with self.admin_access.repo_cnx() as cnx:
e = cnx.execute('CWUser U WHERE U login "member"').get_entity(0, 0)