Esempio n. 1
0
    def setUp(self):
        if not hasattr(settings, '_global_test_state'):
            settings._global_test_state = True
            destroy_db()
            db.create_all()
            delete_index()
            upgrade_search()

        kv.flushall()
        clear_index()
        for table in reversed(db.metadata.sorted_tables):
            q = 'TRUNCATE %s RESTART IDENTITY CASCADE;' % table.name
            db.engine.execute(q)
        create_system_roles()
Esempio n. 2
0
File: util.py Progetto: pudo/aleph
    def setUp(self):
        if not hasattr(settings, '_global_test_state'):
            settings._global_test_state = True
            destroy_db()
            db.create_all()
            delete_index()
            upgrade_search()

        kv.flushall()
        clear_index()
        for table in reversed(db.metadata.sorted_tables):
            q = 'TRUNCATE %s RESTART IDENTITY CASCADE;' % table.name
            db.engine.execute(q)
        create_system_roles()
Esempio n. 3
0
    def setUp(self):
        self.flush_index()
        if not hasattr(TestCase, '_global_test_state'):
            TestCase._global_test_state = True
            delete_index()
            upgrade_search()
        else:
            es.delete_by_query(index=all_indexes(),
                               body={'query': {'match_all': {}}},
                               refresh=True,
                               conflicts='proceed')

        destroy_db()
        db.create_all()
        create_system_roles()
Esempio n. 4
0
    def setUp(self):
        if not hasattr(settings, '_global_test_state'):
            settings._global_test_state = True
            destroy_db()
            db.create_all()
            delete_index()
            upgrade_search()

        # self.flush_index()
        es.delete_by_query(index=all_indexes(),
                           body={'query': {'match_all': {}}},
                           refresh=True,
                           conflicts='proceed')

        for table in reversed(db.metadata.sorted_tables):
            q = 'TRUNCATE %s RESTART IDENTITY CASCADE;' % table.name
            db.engine.execute(q)
        create_system_roles()
Esempio n. 5
0
def evilshit():
    """EVIL: Delete all data and recreate the database."""
    delete_index()
    from sqlalchemy import MetaData, inspect
    from sqlalchemy.exc import InternalError
    from sqlalchemy.dialects.postgresql import ENUM
    metadata = MetaData()
    metadata.bind = db.engine
    metadata.reflect()
    tables = list(metadata.sorted_tables)
    while len(tables):
        for table in tables:
            try:
                table.drop(checkfirst=True)
                tables.remove(table)
            except InternalError:
                pass
    for enum in inspect(db.engine).get_enums():
        enum = ENUM(name=enum['name'])
        enum.drop(bind=db.engine, checkfirst=True)
    upgrade()
Esempio n. 6
0
def evilshit():
    """EVIL: Delete all data and recreate the database."""
    delete_index()
    destroy_db()
    upgrade()
Esempio n. 7
0
def resetindex():
    """Re-create the ES index configuration, dropping all data."""
    delete_index()
    upgrade()