Esempio n. 1
0
def test_check_schema_version_false_when_multiple_entries(session):
    _setup_schema(session)

    assert _check_schema_version(session) is True

    session.add(SchemaVersion(version='unknown'))
    session.commit()

    assert _check_schema_version(session) is False
Esempio n. 2
0
def test_check_schema_version_false_when_no_entry(session):
    _setup_schema(session)
    assert _check_schema_version(session) is True

    # delete the entry
    schema_version = session.query(SchemaVersion).one()
    session.delete(schema_version)
    session.commit()

    assert _check_schema_version(session) is False
Esempio n. 3
0
def test_get_tracking_db_from_valid_existing(db_path):
    session_a = get_tracking_database(db_path)
    assert _check_schema_version(session_a) is True
    del session_a

    # ensure the session was persisted to disk
    session_b = _get_session(db_path)
    assert _check_schema_version(session_b) is True
    del session_b

    session_c = get_tracking_database(db_path)
    assert _check_schema_version(session_c) is True
Esempio n. 4
0
def test_check_schema_version_false_when_wrong_version(session):
    _setup_schema(session)

    assert _check_schema_version(session) is True

    # change version to unknown value
    schema_version = session.query(SchemaVersion).one()
    schema_version.version = 'unknown'

    session.add(schema_version)
    session.commit()

    assert _check_schema_version(session) is False
Esempio n. 5
0
def test_get_tracking_db_errors_bad_schema_version(db_path):
    session_a = get_tracking_database(db_path)
    assert _check_schema_version(session_a) is True

    # change version to unknown value
    schema_version = session_a.query(SchemaVersion).one()
    schema_version.version = 'unknown'

    session_a.add(schema_version)
    session_a.commit()
    del session_a

    # ensure the session was persisted to disk
    session_b = _get_session(db_path)
    assert _check_schema_version(session_b) is False
    del session_b

    with pytest.raises(BadDatabaseError):
        get_tracking_database(db_path)
Esempio n. 6
0
def test_check_schema_version_false_when_no_tables(session):
    assert _check_is_empty(session)
    assert _check_schema_version(session) is False
Esempio n. 7
0
def test_setup_schema(session):
    assert _check_schema_version(session) is False
    _setup_schema(session)
    assert _check_schema_version(session) is True
Esempio n. 8
0
def test_get_tracking_db_from_empty():
    session = get_tracking_database(Path(':memory:'))
    assert _check_schema_version(session) is True