Spaces:
Paused
Paused
Download tests/dbutil.py from Mega-Evolutions/ButtonBot: direct link, hf CLI and curl.
- Browser
- Download file 469 Bytes
-
https://huggingface.co/spaces/Mega-Evolutions/ButtonBot/resolve/main/tests/dbutil.py
- Command line
-
hf download hf://spaces/Mega-Evolutions/ButtonBot/tests/dbutil.py
-
curl -L -o dbutil.py https://huggingface.co/spaces/Mega-Evolutions/ButtonBot/resolve/main/tests/dbutil.py
469 Bytes
| """Tests run on SQLite by default; set TEST_DATABASE_URL to run the very same tests on PostgreSQL.""" | |
| import os | |
| from app.db import Base, Database | |
| def db_url_for(tmp_path, name="t.db"): | |
| return os.getenv("TEST_DATABASE_URL") or f"sqlite+aiosqlite:///{tmp_path}/{name}" | |
| async def fresh_db(url: str) -> Database: | |
| db = Database(url) | |
| async with db.engine.begin() as conn: | |
| await conn.run_sync(Base.metadata.drop_all) | |
| await db.init() | |
| return db | |