mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
added sql model to db
This commit is contained in:
parent
b991ab73f7
commit
a946eb2959
1 changed files with 4 additions and 0 deletions
|
|
@ -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()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue