Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ __pycache__
node_modules
.mypy_cache
.venv

# test data
data/

# AI
.codex
31 changes: 31 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import asyncio
import os

import pytest

os.environ.setdefault("DEBUG", "false")

from lnbits.core.db import db as core_db
from lnbits.core.helpers import run_migration

import tpos.migrations as ext_migrations # type: ignore[import]
from tpos.crud import db # type: ignore[import]


@pytest.fixture(scope="session", autouse=True)
def init_ext():
async def _init():
async with core_db.connect() as core_conn:
await core_conn.execute("""
CREATE TABLE IF NOT EXISTS dbversions (
db TEXT PRIMARY KEY,
version INTEGER NOT NULL
);
""")
await core_conn.execute("DELETE FROM dbversions WHERE db = 'tpos'")
async with db.connect() as conn:
for table in ("payments", "withdraws", "pos", "tposs"):
await conn.execute(f"DROP TABLE IF EXISTS tpos.{table}")
await run_migration(conn, ext_migrations, "tpos")

asyncio.run(_init())
Loading
Loading