entities/test/unittest_base.py
changeset 10974 6557833657d6
parent 10973 0939ad2edf63
child 11044 00c5ee272a6d
--- a/entities/test/unittest_base.py	Tue Dec 15 08:55:58 2015 +0100
+++ b/entities/test/unittest_base.py	Wed Dec 09 16:32:57 2015 +0100
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2015 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -46,13 +46,13 @@
             self.assertEqual(entity.dc_creator(), u'member')
 
     def test_type(self):
-        #dc_type may be translated
+        # dc_type may be translated
         with self.admin_access.client_cnx() as cnx:
             member = cnx.entity_from_eid(self.membereid)
             self.assertEqual(member.dc_type(), 'CWUser')
 
     def test_cw_etype(self):
-        #cw_etype is never translated
+        # cw_etype is never translated
         with self.admin_access.client_cnx() as cnx:
             member = cnx.entity_from_eid(self.membereid)
             self.assertEqual(member.cw_etype, 'CWUser')
@@ -62,15 +62,17 @@
         self.assertEqual(self.schema['CWUser'].meta_attributes(), {})
         self.assertEqual(dict((str(k), v)
                               for k, v in self.schema['State'].meta_attributes().items()),
-                          {'description_format': ('format', 'description')})
+                         {'description_format': ('format', 'description')})
 
     def test_fti_rql_method(self):
         class EmailAddress(AnyEntity):
             __regid__ = 'EmailAddress'
             __select__ = AnyEntity.__select__ & yes(2)
+
             @classmethod
             def cw_fti_index_rql_queries(cls, req):
                 return ['EmailAddress Y']
+
         with self.admin_access.web_request() as req:
             req.create_entity('EmailAddress', address=u'foo@bar.com')
             eclass = self.vreg['etypes'].etype_class('EmailAddress')
@@ -107,14 +109,16 @@
             self.assertEqual(email3.prefered.eid, email3.eid)
 
     def test_mangling(self):
+        query = 'INSERT EmailAddress X: X address "maarten.ter.huurne@philips.com"'
         with self.admin_access.repo_cnx() as cnx:
-            email = cnx.execute('INSERT EmailAddress X: X address "maarten.ter.huurne@philips.com"').get_entity(0, 0)
+            email = cnx.execute(query).get_entity(0, 0)
             self.assertEqual(email.display_address(), 'maarten.ter.huurne@philips.com')
             self.assertEqual(email.printable_value('address'), 'maarten.ter.huurne@philips.com')
             self.vreg.config.global_set_option('mangle-emails', True)
             try:
                 self.assertEqual(email.display_address(), 'maarten.ter.huurne at philips dot com')
-                self.assertEqual(email.printable_value('address'), 'maarten.ter.huurne at philips dot com')
+                self.assertEqual(email.printable_value('address'),
+                                 'maarten.ter.huurne at philips dot com')
                 email = cnx.execute('INSERT EmailAddress X: X address "syt"').get_entity(0, 0)
                 self.assertEqual(email.display_address(), 'syt')
                 self.assertEqual(email.printable_value('address'), 'syt')
@@ -130,6 +134,7 @@
             self.assertEqual(email.printable_value('address', format='text/plain'),
                              'maarten&ter@philips.com')
 
+
 class CWUserTC(BaseEntityTC):
 
     def test_complete(self):
@@ -167,10 +172,11 @@
         with self.admin_access.repo_cnx() as cnx:
             e = cnx.execute('CWUser U WHERE U login "member"').get_entity(0, 0)
             # Bytes/Password attributes should be omitted
-            self.assertEqual(e.cw_adapt_to('IEmailable').allowed_massmail_keys(),
-                              set(('surname', 'firstname', 'login', 'last_login_time',
-                                   'creation_date', 'modification_date', 'cwuri', 'eid'))
-                              )
+            self.assertEqual(
+                e.cw_adapt_to('IEmailable').allowed_massmail_keys(),
+                set(('surname', 'firstname', 'login', 'last_login_time',
+                     'creation_date', 'modification_date', 'cwuri', 'eid'))
+            )
 
     def test_cw_instantiate_object_relation(self):
         """ a weird non regression test """
@@ -213,7 +219,7 @@
         # no specific class for Subdivisions, the default one should be selected
         eclass = self.select_eclass('SubDivision')
         self.assertTrue(eclass.__autogenerated__)
-        #self.assertEqual(eclass.__bases__, (AnyEntity,))
+        # self.assertEqual(eclass.__bases__, (AnyEntity,))
         # build class from most generic to most specific and make
         # sure the most specific is always selected
         self.vreg._loadedmods[__name__] = {}