diff --git a/backend/app/app/conftest.py b/backend/app/app/conftest.py index af5d244..bb792ef 100644 --- a/backend/app/app/conftest.py +++ b/backend/app/app/conftest.py @@ -8,15 +8,20 @@ from app.web.application import get_app -@pytest.fixture(name="session") -def session_fixture(): +@pytest.fixture(scope="session") +def engine_fixture(): engine = create_engine( - f"postgresql+psycopg://{settings.POSTGRES_USER}:{settings.POSTGRES_PASSWORD}@bemore-db/{settings.POSTGRES_DB}", + f"postgresql+psycopg://{settings.POSTGRES_USER}:{settings.POSTGRES_PASSWORD}@bemore-db/test", ) SQLModel.metadata.create_all(engine) - with Session(engine) as session: init_db(session) + yield engine + + +@pytest.fixture(name="session") +def session_fixture(engine_fixture): + with Session(engine_fixture) as session: yield session diff --git a/backend/app/app/models.py b/backend/app/app/models.py index 1f59f8d..07f02dd 100644 --- a/backend/app/app/models.py +++ b/backend/app/app/models.py @@ -84,7 +84,7 @@ def convert_without_saving( update: Optional[dict] = None, ) -> SQLModel: if isinstance(source, SQLModel): - obj = cls.from_orm(source, update=update) # type: ignore + obj = cls.model_validate(source, update=update) # type: ignore elif isinstance(source, dict): obj = cls.parse_obj(source, update=update) # type: ignore return obj diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml index ec876b7..3aef9c4 100644 --- a/docker-compose.ci.yml +++ b/docker-compose.ci.yml @@ -9,6 +9,7 @@ services: - .env environment: - PGDATA=/var/lib/postgresql/data/pgdata + - POSTGRES_DB=test networks: - default