Exemplo n.º 1
0
def test_store_generated_schema_matches_base(tmpdir, db_url):
    # Create a SQLAlchemyStore against tmpfile, directly verify that tmpfile contains a
    # database with a valid schema
    SqlAlchemyStore(db_url, tmpdir.join("ARTIFACTS").strpath)
    engine = sqlalchemy.create_engine(db_url)
    mc = MigrationContext.configure(engine.connect())
    diff = compare_metadata(mc, Base.metadata)
    assert len(diff) == 0
Exemplo n.º 2
0
def test_sqlalchemystore_idempotently_generates_up_to_date_schema(
        tmpdir, db_url, expected_schema_file):
    generated_schema_file = tmpdir.join("generated-schema.sql").strpath
    # Repeatedly initialize a SQLAlchemyStore against the same DB URL. Initialization should
    # succeed and the schema should be the same.
    for _ in range(3):
        SqlAlchemyStore(db_url, tmpdir.join("ARTIFACTS").strpath)
        dump_db_schema(db_url, dst_file=generated_schema_file)
        _assert_schema_files_equal(generated_schema_file, expected_schema_file)
Exemplo n.º 3
0
def sqlite_store():
    fd, temp_dbfile = tempfile.mkstemp()
    # Close handle immediately so that we can remove the file later on in Windows
    os.close(fd)
    db_uri = "sqlite:///%s" % temp_dbfile
    store = SqlAlchemyStore(db_uri, 'artifact_folder')
    yield (store, db_uri)
    os.remove(temp_dbfile)
    shutil.rmtree('artifact_folder')
Exemplo n.º 4
0
def dump_sqlalchemy_store_schema(dst_file):
    db_tmpdir = tempfile.mkdtemp()
    try:
        path = os.path.join(db_tmpdir, "db_file")
        db_url = "sqlite:///%s" % path
        SqlAlchemyStore(db_url, db_tmpdir)
        dump_db_schema(db_url, dst_file)
    finally:
        shutil.rmtree(db_tmpdir)
Exemplo n.º 5
0
def _get_sqlalchemy_store(store_uri, artifact_uri):
    from kiwi.store.tracking.sqlalchemy_store import SqlAlchemyStore
    if artifact_uri is None:
        artifact_uri = DEFAULT_LOCAL_FILE_AND_ARTIFACT_PATH
    return SqlAlchemyStore(store_uri, artifact_uri)
Exemplo n.º 6
0
 def _get_sqlalchemy_store(cls, store_uri):
     from kiwi.store.model_registry.sqlalchemy_store import SqlAlchemyStore
     return SqlAlchemyStore(store_uri)
Exemplo n.º 7
0
 def _get_sqlalchemy_store(cls, store_uri, artifact_uri):
     from kiwi.store.tracking.sqlalchemy_store import SqlAlchemyStore
     return SqlAlchemyStore(store_uri, artifact_uri)