Unzip budget-app v7 into repo root

This commit is contained in:
jpmvaz
2026-10-29 20:40:02 +00:00
parent 2554e68315
commit c9fd26f1c7
94 changed files with 12098 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
import os
import sys
from pathlib import Path
import pytest
DB = Path(__file__).parent / "test.db"
os.environ["DATABASE_URL"] = f"sqlite:///{DB}"
os.environ["ADMIN_EMAIL"] = "admin@test.local"
os.environ["ADMIN_PASSWORD"] = "admin-pass-123"
sys.path.insert(0, str(Path(__file__).parent.parent))
from fastapi.testclient import TestClient # noqa: E402
from app.bootstrap import bootstrap # noqa: E402
from app.db import Base, engine # noqa: E402
from app.main import app # noqa: E402
FIXTURE = Path(__file__).parent / "fixtures" / "budget_2027.xlsx"
H = {"X-Requested-With": "budget-app"}
@pytest.fixture()
def client():
Base.metadata.drop_all(engine)
Base.metadata.create_all(engine)
bootstrap()
with TestClient(app) as c:
r = c.post("/api/auth/login", json={"email": "admin@test.local", "password": "admin-pass-123"}, headers=H)
assert r.status_code == 200
c.headers.update(H)
yield c
@pytest.fixture()
def imported(client):
with FIXTURE.open("rb") as f:
r = client.post("/api/years/import", files={"file": ("b.xlsx", f, "application/octet-stream")})
assert r.status_code == 200, r.text
return r.json()["year"]["id"]