[test] don't display progress bar when testing checkintegrity stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 24 Feb 2010 10:32:22 +0100
branchstable
changeset 4675 9233a8350420
parent 4674 3d509dbb473a
child 4676 b0937a191f94
[test] don't display progress bar when testing checkintegrity
server/checkintegrity.py
server/test/unittest_checkintegrity.py
--- a/server/checkintegrity.py	Wed Feb 24 10:30:31 2010 +0100
+++ b/server/checkintegrity.py	Wed Feb 24 10:32:22 2010 +0100
@@ -64,7 +64,7 @@
     else:
         yield eschema
 
-def reindex_entities(schema, session):
+def reindex_entities(schema, session, withpb=True):
     """reindex all entities in the repository"""
     # deactivate modification_date hook since we don't want them
     # to be updated due to the reindexation
@@ -92,20 +92,23 @@
             etypes.add(container)
     print 'Reindexing entities of type %s' % \
           ', '.join(sorted(str(e) for e in etypes))
-    pb = ProgressBar(len(etypes) + 1)
+    if withpb:
+        pb = ProgressBar(len(etypes) + 1)
     # first monkey patch Entity.check to disable validation
     from cubicweb.entity import Entity
     _check = Entity.check
     Entity.check = lambda self, creation=False: True
     # clear fti table first
     session.system_sql('DELETE FROM %s' % session.repo.system_source.dbhelper.fti_table)
-    pb.update()
+    if withpb:
+        pb.update()
     # reindex entities by generating rql queries which set all indexable
     # attribute to their current value
     for eschema in etypes:
         for entity in session.execute('Any X WHERE X is %s' % eschema).entities():
             FTIndexEntityOp(session, entity=entity)
-        pb.update()
+        if withpb:
+            pb.update()
     # restore Entity.check
     Entity.check = _check
 
@@ -276,7 +279,7 @@
                 print >> sys.stderr
 
 
-def check(repo, cnx, checks, reindex, fix):
+def check(repo, cnx, checks, reindex, fix, withpb=True):
     """check integrity of instance's repository,
     using given user and password to locally connect to the repository
     (no running cubicweb server needed)
@@ -297,5 +300,5 @@
     if reindex:
         cnx.rollback()
         session.set_pool()
-        reindex_entities(repo.schema, session)
+        reindex_entities(repo.schema, session, withpb=withpb)
         cnx.commit()
--- a/server/test/unittest_checkintegrity.py	Wed Feb 24 10:30:31 2010 +0100
+++ b/server/test/unittest_checkintegrity.py	Wed Feb 24 10:32:22 2010 +0100
@@ -20,7 +20,7 @@
         sys.stderr = sys.stdout = StringIO()
         try:
             check(repo, cnx, ('entities', 'relations', 'text_index', 'metadata'),
-                  True, True)
+                  reindex=True, fix=True, withpb=False)
         finally:
             sys.stderr = sys.__stderr__
             sys.stdout = sys.__stdout__