# HG changeset patch # User Sylvain Thénault # Date 1267003942 -3600 # Node ID 9233a8350420ae502819636fa3a09d6bc30209d8 # Parent 3d509dbb473aac47e7932b1d6c9b40587d75c1ae [test] don't display progress bar when testing checkintegrity diff -r 3d509dbb473a -r 9233a8350420 server/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() diff -r 3d509dbb473a -r 9233a8350420 server/test/unittest_checkintegrity.py --- 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__