Esempio n. 1
0
def db() -> t.Generator[Database, None, None]:
    uri = "sqlite://"
    echo = False
    _db = Database(uri, model_class=Model, echo=echo)
    _db.create_all()
    yield _db
    _db.close()
Esempio n. 2
0
def filedb(tmp_path: Path) -> t.Generator[Database, None, None]:
    dbpath = tmp_path / "test.db"
    uri = f"sqlite:///{dbpath}"
    _db = Database(uri, model_class=Model)
    _db.create_all()
    yield _db
    _db.close()
Esempio n. 3
0
def test_database_close__disposes_engine(filedb: Database):
    with mock_db(filedb):
        filedb.close()
        assert filedb.engine.dispose.called  # type: ignore