[test] cleanup stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 24 Feb 2010 11:04:28 +0100
branchstable
changeset 4681 5f72584ab1d7
parent 4680 8a6bee838464
child 4682 4994901b7379
[test] cleanup
devtools/testlib.py
hooks/test/unittest_syncschema.py
server/test/unittest_migractions.py
test/unittest_cwconfig.py
test/unittest_entity.py
--- a/devtools/testlib.py	Wed Feb 24 10:56:47 2010 +0100
+++ b/devtools/testlib.py	Wed Feb 24 11:04:28 2010 +0100
@@ -71,8 +71,8 @@
     as key with their version as value, including cubicweb version. This is a
     public method, not requiring a session id.
 
-    replace Repository.get_versions by this method if you don't want versions
-    checking
+    replace Repository.get_versions by this method if you want to get versions
+    from code instead of from the database
     """
     vcconf = {'cubicweb': self.config.cubicweb_version()}
     self.config.bootstrap_cubes()
--- a/hooks/test/unittest_syncschema.py	Wed Feb 24 10:56:47 2010 +0100
+++ b/hooks/test/unittest_syncschema.py	Wed Feb 24 11:04:28 2010 +0100
@@ -134,7 +134,7 @@
         self.execute('DELETE X read_permission Y WHERE X is CWEType, X name "CWUser", Y name "users"')
         self.assertEquals(schema['CWUser'].get_groups('read'), set(('managers', 'users', )))
         self.commit()
-        self.assertEquals(schema['CWUser'].get_groups('read'), set(('managers', )))
+        self.assertEquals(schema['CWUser'].get_groups('read'), set(('managers',)))
         self.execute('SET X read_permission Y WHERE X is CWEType, X name "CWUser", Y name "users"')
         self.commit()
         self.assertEquals(schema['CWUser'].get_groups('read'), set(('managers', 'users',)))
--- a/server/test/unittest_migractions.py	Wed Feb 24 10:56:47 2010 +0100
+++ b/server/test/unittest_migractions.py	Wed Feb 24 11:04:28 2010 +0100
@@ -29,6 +29,7 @@
     @classmethod
     def init_config(cls, config):
         super(MigrationCommandsTC, cls).init_config(config)
+        # we have to read schema from the database to get eid for schema entities
         config._cubes = None
         cls.repo.fill_schema()
         cls.origschema = deepcopy(cls.repo.schema)
@@ -345,8 +346,6 @@
         self.assertEquals(len(self._erqlexpr_rset('delete', 'Affaire')), 1)
         self.assertEquals(len(self._erqlexpr_rset('add', 'Affaire')), 1)
         # no change for rqlexpr to add and delete concerne relation
-        for rdef in self.schema['concerne'].rdefs.values():
-            print rdef, rdef.permissions
         self.assertEquals(len(self._rrqlexpr_rset('delete', 'concerne')), len(delete_concerne_rqlexpr))
         self.assertEquals(len(self._rrqlexpr_rset('add', 'concerne')), len(add_concerne_rqlexpr))
         # * migrschema involve:
--- a/test/unittest_cwconfig.py	Wed Feb 24 10:56:47 2010 +0100
+++ b/test/unittest_cwconfig.py	Wed Feb 24 11:04:28 2010 +0100
@@ -21,6 +21,9 @@
             return '/'.join(parts[i+1:])
     raise Exception('duh? %s' % path)
 
+CUSTOM_CUBES_DIR = abspath(join(dirname(__file__), 'data', 'cubes'))
+
+
 class CubicWebConfigurationTC(TestCase):
     def setUp(self):
         self.config = ApptestConfiguration('data')
@@ -86,16 +89,14 @@
         # make sure we don't import the email cube, but the stdlib email package
         import email
         self.assertNotEquals(dirname(email.__file__), self.config.CUBES_DIR)
-        os.environ['CW_CUBES_PATH'] = join(dirname(__file__), 'data', 'cubes')
+        os.environ['CW_CUBES_PATH'] = CUSTOM_CUBES_DIR
         self.assertEquals(self.config.cubes_search_path(),
-                          [abspath(join(dirname(__file__), 'data', 'cubes')),
-                           self.config.CUBES_DIR])
-        os.environ['CW_CUBES_PATH'] = '%s%s%s%s%s' % (join(dirname(__file__), 'data', 'cubes'),
-                                                      os.pathsep, self.config.CUBES_DIR,
-                                                      os.pathsep, 'unexistant')
+                          [CUSTOM_CUBES_DIR, self.config.CUBES_DIR])
+        os.environ['CW_CUBES_PATH'] = os.pathsep.join([
+            CUSTOM_CUBES_DIR, self.config.CUBES_DIR, 'unexistant'])
         # filter out unexistant and duplicates
         self.assertEquals(self.config.cubes_search_path(),
-                          [abspath(join(dirname(__file__), 'data', 'cubes')),
+                          [CUSTOM_CUBES_DIR,
                            self.config.CUBES_DIR])
         self.failUnless('mycube' in self.config.available_cubes())
         # test cubes python path
@@ -104,12 +105,12 @@
         self.assertEquals(cubes.__path__, self.config.cubes_search_path())
         # this import should succeed once path is adjusted
         from cubes import mycube
-        self.assertEquals(mycube.__path__, [abspath(join(dirname(__file__), 'data', 'cubes', 'mycube'))])
+        self.assertEquals(mycube.__path__, [join(CUSTOM_CUBES_DIR, 'mycube')])
         # file cube should be overriden by the one found in data/cubes
         sys.modules.pop('cubes.file', None)
         del cubes.file
         from cubes import file
-        self.assertEquals(file.__path__, [abspath(join(dirname(__file__), 'data', 'cubes', 'file'))])
+        self.assertEquals(file.__path__, [join(CUSTOM_CUBES_DIR, 'file')])
 
 
 if __name__ == '__main__':
--- a/test/unittest_entity.py	Wed Feb 24 10:56:47 2010 +0100
+++ b/test/unittest_entity.py	Wed Feb 24 11:04:28 2010 +0100
@@ -189,14 +189,12 @@
         # XXX
         self.assertEquals(p.related_rql('evaluee'),
                           'Any X,AA ORDERBY AA DESC '
-                          'WHERE E eid %(x)s, E evaluee X, '
-                          'X modification_date AA')
+                          'WHERE E eid %(x)s, E evaluee X, X modification_date AA')
 
         tag = self.vreg['etypes'].etype_class('Tag')(self.request())
         self.assertEquals(tag.related_rql('tags', 'subject'),
                           'Any X,AA ORDERBY AA DESC '
-                          'WHERE E eid %(x)s, E tags X, '
-                          'X modification_date AA')
+                          'WHERE E eid %(x)s, E tags X, X modification_date AA')
         self.assertEquals(tag.related_rql('tags', 'subject', ('Personne',)),
                           'Any X,AA,AB ORDERBY AA ASC '
                           'WHERE E eid %(x)s, E tags X, X is IN (Personne), X nom AA, '