added sql model to db

This commit is contained in:
Jun-te Kim 2026-03-31 11:27:23 +00:00
parent b991ab73f7
commit a946eb2959

View file

@ -2,6 +2,8 @@ import pytest
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from backend.app.db.base import Base
from sqlmodel import SQLModel
import backend.app.db.models.organisation # noqa: F401 — registers Organisation with SQLModel.metadata
@pytest.fixture(scope="function")
@ -25,12 +27,14 @@ def engine(postgresql):
# Create tables once per test session
Base.metadata.create_all(engine)
SQLModel.metadata.create_all(engine)
# Yeild will split this function into two phase. 1) setup and 2) teardown, the latter of which will run after all
# tests have completed
yield engine
# Clean-up after entire test session
SQLModel.metadata.drop_all(engine)
Base.metadata.drop_all(engine)
engine.dispose()