Fix validation issues and test setup

This commit is contained in:
steve-w
2026-04-06 02:09:36 +00:00
parent dd6b76e665
commit 18af835645
3 changed files with 32 additions and 15 deletions

View File

@@ -1,16 +1,27 @@
import os
import tempfile
import pytest
from fastapi.testclient import TestClient
from main import app, init_db
import sqlite3
import os
client = TestClient(app)
def setup_module(module):
# Use an in-memory database for tests
os.environ["DB_PATH"] = ":memory:"
fd, path = tempfile.mkstemp(suffix=".db")
os.close(fd)
module.TEST_DB_PATH = path
os.environ["DB_PATH"] = path
init_db()
def teardown_module(module):
path = getattr(module, "TEST_DB_PATH", None)
if path and os.path.exists(path):
os.remove(path)
client = TestClient(app)
def test_root():
r = client.get("/")
assert r.status_code == 200