Exemplo n.º 1
0
def fresh_database_config(config_with_sqlite_database):
    """Create new database structure using database config.

    :param config_with_sqlite_database: path to database config.
    :returns: instance of :class:`DatabaseConfig
        <autostorage.database.database_config.DatabaseConfig>`.
    """
    database_config = get_database_config(config_with_sqlite_database)
    create_all(database_config)
    return database_config
Exemplo n.º 2
0
def test_method_creation_explicit(config_with_sqlite_database):
    """Check method to create database.

    1. Provide database config explicitly to the method to create database.
    2. Check that tables exist.
    3. Check that database is populated.
    """
    database_config = get_database_config(config_with_sqlite_database)
    create_all(database_config)
    engine = create_engine(database_config.get_connection_string())
    assert set(engine.table_names()) == _get_expected_tables_names(), "Wrong tables set"
    _check_initial_records(engine)
Exemplo n.º 3
0
def test_method_creation_implicit(config_with_sqlite_database, monkeypatch):
    """Check method to create database.

    1. Provide database config implicitly to the method to create database.
    2. Check that tables exist.
    3. Check that database is populated.
    """
    monkeypatch.setenv(ENV_DB_CONFIG_PATH, config_with_sqlite_database)
    create_all()
    database_config = get_database_config(config_with_sqlite_database)
    engine = create_engine(database_config.get_connection_string())
    assert set(engine.table_names()) == _get_expected_tables_names(), "Wrong tables set"
    _check_initial_records(engine)