def test_fresh_install(db):
    """ Test table creation if the uses never had encryption_state table
        installed (i.e. user skiped gajim-omemo plugin version 0.3)
    """
    assert user_version(db) == 0
    assert not table_exists(db, 'encryption_state')
    encryption.migrate(db)
    assert db is not None
    assert table_exists(db, 'encryption_state')
    assert user_version(db) == 1
def test_fresh_install(db):
    """ Test table creation if the uses never had encryption_state table
        installed (i.e. user skiped gajim-omemo plugin version 0.3)
    """
    assert user_version(db) == 0
    assert not table_exists(db, 'encryption_state')
    encryption.migrate(db)
    assert db is not None
    assert table_exists(db, 'encryption_state')
    assert user_version(db) == 1
def test_downgrade(db):
    """ This test asserts a smooth downgrade of sqlite to pre-3.8.2 version.

        Gajim on Windows and TravisCi use an old sqlite version which does not
        support `WITHOUT ROW ID` which was added in *6bf2187*. This test make sure
        that we can gracefully backup data from the `encryption_state` before
        droping the table and reacreating it with an ID column with
        `AUTO_INCREMENT`.
    """
    q = """ CREATE TABLE encryption_state (
                jid TEXT PRIMARY KEY,
                encryption INTEGER,
                timestamp NUMBER DEFAULT CURRENT_TIMESTAMP
                );
        """
    db.execute(q)
    q = """ SELECT name FROM sqlite_master
            WHERE type='table' AND name='encryption_state';
        """

    encryption.migrate(db)
    assert db is not None
    assert table_exists(db, 'encryption_state')
    assert user_version(db) == 1
def test_downgrade(db):
    """ This test asserts a smooth downgrade of sqlite to pre-3.8.2 version.

        Gajim on Windows and TravisCi use an old sqlite version which does not
        support `WITHOUT ROW ID` which was added in *6bf2187*. This test make sure
        that we can gracefully backup data from the `encryption_state` before
        droping the table and reacreating it with an ID column with
        `AUTO_INCREMENT`.
    """
    q = """ CREATE TABLE encryption_state (
                jid TEXT PRIMARY KEY,
                encryption INTEGER,
                timestamp NUMBER DEFAULT CURRENT_TIMESTAMP
                );
        """
    db.execute(q)
    q = """ SELECT name FROM sqlite_master
            WHERE type='table' AND name='encryption_state';
        """

    encryption.migrate(db)
    assert db is not None
    assert table_exists(db, 'encryption_state')
    assert user_version(db) == 1
Пример #5
0
def test_table_exists():
    db = sqlite3.connect(':memory:', check_same_thread=False)
    assert not db_helpers.table_exists(db, 'foo')

    db.execute('CREATE TABLE foo (a TEXT, b INTEGER);')
    assert db_helpers.table_exists(db, 'foo')
Пример #6
0
def test_table_exists():
    db = sqlite3.connect(':memory:', check_same_thread=False)
    assert not db_helpers.table_exists(db, 'foo')

    db.execute('CREATE TABLE foo (a TEXT, b INTEGER);')
    assert db_helpers.table_exists(db, 'foo')