diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index dc01da3..dfff33c 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -17,10 +17,10 @@ jobs: options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 steps: - uses: actions/checkout@v2 - - name: Set up Python 3.9 + - name: Set up Python 3.10 uses: actions/setup-python@v2 with: - python-version: 3.9 + python-version: "3.10" - name: Cache pip uses: actions/cache@v2 with: @@ -47,10 +47,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Set up Python 3.9 + - name: Set up Python 3.10 uses: actions/setup-python@v2 with: - python-version: 3.9 + python-version: "3.10" - name: Cache pip uses: actions/cache@v2 with: diff --git a/backend/Dockerfile b/backend/Dockerfile index 06441cd..42dc174 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.9-slim +FROM python:3.10-slim COPY . /opt/aimaas RUN pip3 install -r /opt/aimaas/requirements.txt; \ diff --git a/backend/database.py b/backend/database.py index 56eb7d8..913fab6 100644 --- a/backend/database.py +++ b/backend/database.py @@ -1,8 +1,7 @@ from fastapi import HTTPException from starlette.status import HTTP_503_SERVICE_UNAVAILABLE from sqlalchemy import create_engine, text -from sqlalchemy.ext.declarative import declarative_base -from sqlalchemy.orm import sessionmaker +from sqlalchemy.orm import declarative_base, sessionmaker from .config import SQLALCHEMY_DATABASE_URL diff --git a/backend/requirements.txt b/backend/requirements.txt index ad3a30f..9cc40cb 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -9,5 +9,5 @@ pydantic<1.9.1 python-dotenv python-jose[cryptography] python-multipart -SQLAlchemy<2 +SQLAlchemy uvicorn diff --git a/backend/tests/conftest.py b/backend/tests/conftest.py index 27c65d9..2079fd0 100644 --- a/backend/tests/conftest.py +++ b/backend/tests/conftest.py @@ -4,7 +4,7 @@ from alembic.config import Config from httpx._client import USE_CLIENT_DEFAULT import pytest -from sqlalchemy import create_engine +from sqlalchemy import create_engine, text from sqlalchemy.orm import sessionmaker from fastapi.testclient import TestClient @@ -304,14 +304,16 @@ def engine(): pool_timeout=5) Base.metadata.drop_all(engine) with engine.connect() as conn: - conn.execute("drop table if exists alembic_version") + conn.execute(text("drop table if exists alembic_version")) + conn.commit() cfg = Config("alembic.ini") command.upgrade(cfg, "head") yield engine Base.metadata.drop_all(engine) with engine.connect() as conn: - conn.execute("drop table if exists alembic_version") + conn.execute(text("drop table if exists alembic_version")) + conn.commit() engine.dispose() diff --git a/backend/tests/test_crud_entity.py b/backend/tests/test_crud_entity.py index 940ffc7..128bb61 100644 --- a/backend/tests/test_crud_entity.py +++ b/backend/tests/test_crud_entity.py @@ -18,15 +18,21 @@ def asserts_after_entities_create(self, db: Session): jack = self.get_default_entity(db) persons = db.execute(select(Entity).where(Entity.schema_id == jack.schema_id)).scalars().all() + persons = {p.slug: p for p in persons} + assert len(persons) == 5 - assert persons[-2].name == 'John' - assert persons[-2].slug == 'John' - assert persons[-2].get('nickname', db).value == 'john' - assert persons[-2].get('age', db).value == 10 - assert persons[-2].get('born', db).value == born - assert isinstance(persons[-2].get('age', db), ValueInt) - assert {i.value for i in persons[-2].get('friends', db)} == {jack.id, persons[-3].id} - assert persons[-1].get('born', db).value.astimezone(timezone.utc) == tz_born.astimezone( + + john = persons["John"] + mike = persons["Mike"] + pumpkin_jack = persons["pumpkin-jack"] + + assert john.name == 'John' + assert john.get('nickname', db).value == 'john' + assert john.get('age', db).value == 10 + assert john.get('born', db).value == born + assert isinstance(john.get('age', db), ValueInt) + assert {i.value for i in john.get('friends', db)} == {jack.id, mike.id} + assert pumpkin_jack.get('born', db).value.astimezone(timezone.utc) == tz_born.astimezone( timezone.utc) def test_create(self, dbsession):