Exemple #1
0
def test_init_database_same_version(statify_directory, sql_spy):
    with open(str(database_client.DATABASE_VERSION_PATH), 'w') as version_file:
        version_file.write(config.VERSION)

    database_client.StatifyDatabase(':memory')

    assert sql_spy.mock_calls == []
Exemple #2
0
def in_memory_database(mocker, statify_directory):
    database = database_client.StatifyDatabase(':memory:')
    mocker.patch(
        'statify.statify.database_client.StatifyDatabase',
        return_value=database,
    )
    yield database
    database.close()
def test_init_database_without_any_additional_sql(statify_directory, sql_spy,
                                                  mocker):
    with open(str(database_client.DATABASE_VERSION_PATH), 'w') as version_file:
        version_file.write('1.1.0')

    mocker.patch.object(config, 'VERSION', '1.2.0')

    database_client.StatifyDatabase(':memory')

    assert sql_spy.mock_calls == []
Exemple #4
0
def test_init_from_database_from_up_version(statify_directory):
    with open(str(database_client.DATABASE_VERSION_PATH), 'w') as version_file:
        version_file.write('42424242.42.42')

    with pytest.raises(database_client.DowngradeVersionError):
        database_client.StatifyDatabase(':memory')
Exemple #5
0
def test_init_database_from_nothing(statify_directory, sql_spy, mocker):
    database_client.StatifyDatabase(':memory')

    assert sql_spy.mock_calls == [
        mocker.call(stmt) for stmt in database_client.V1_0_STATEMENTS
    ]