Flatten budget-app contents into repo root
This commit is contained in:
@@ -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"]
|
||||
Reference in New Issue
Block a user