From b841ebf2b9274e6f59eb79602b4068ce3a83a963 Mon Sep 17 00:00:00 2001 From: Yurii Karabas <1998uriyyo@gmail.com> Date: Sun, 29 Dec 2024 11:04:06 +0100 Subject: [PATCH] Add gino tests --- fastapi_pagination/ext/sqlalchemy.py | 7 +++++-- scripts/ci-test.sh | 12 +++++++----- tests/ext/test_gino.py | 2 ++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/fastapi_pagination/ext/sqlalchemy.py b/fastapi_pagination/ext/sqlalchemy.py index 67f1c0be..a8eb0a7c 100644 --- a/fastapi_pagination/ext/sqlalchemy.py +++ b/fastapi_pagination/ext/sqlalchemy.py @@ -12,12 +12,11 @@ import warnings from collections.abc import Sequence from contextlib import suppress -from typing import Any, Optional, TypeVar, Union, cast, overload +from typing import TYPE_CHECKING, Any, Optional, TypeVar, Union, cast, overload from sqlalchemy import func, select, text from sqlalchemy.engine import Connection from sqlalchemy.exc import InvalidRequestError -from sqlalchemy.ext.asyncio import AsyncConnection, AsyncSession from sqlalchemy.orm import Query, Session, noload, scoped_session from sqlalchemy.sql import CompoundSelect, Select from sqlalchemy.sql.elements import TextClause @@ -30,6 +29,10 @@ from .utils import generic_query_apply_params, unwrap_scalars +if TYPE_CHECKING: + from sqlalchemy.ext.asyncio import AsyncConnection, AsyncSession + + try: from sqlalchemy.orm import FromStatement except ImportError: diff --git a/scripts/ci-test.sh b/scripts/ci-test.sh index cec0d5a1..54afe443 100755 --- a/scripts/ci-test.sh +++ b/scripts/ci-test.sh @@ -55,15 +55,17 @@ if [[ "$PYDANTIC_V2" == true ]]; then _pip uninstall -y ormar fi -#echo "Running tests GINO tests" -#_pip install -U "gino[starlette]" -#_pytest tests -m gino -#_pip uninstall -y gino gino-starlette - echo "Running orm tests" _pip install "databases<0.9.0" orm _pytest tests/ext -m orm _pip uninstall -y orm +if [[ "$PYDANTIC_V2" == true ]]; then + echo "Running tests GINO tests" + _pip install -U "gino[starlette]" "sqlalchemy<1.4" "asyncpg" + _pytest tests -m gino + _pip uninstall -y gino gino-starlette +fi + echo "Restore env" poetry install -E all --sync diff --git a/tests/ext/test_gino.py b/tests/ext/test_gino.py index d23a11f3..1cf6d41b 100644 --- a/tests/ext/test_gino.py +++ b/tests/ext/test_gino.py @@ -43,6 +43,8 @@ def query(request, user_cls): class TestGino(BasePaginationTestSuite): @pytest.fixture(scope="session") def app(self, builder, db, query): + builder = builder.new() + @builder.both.default async def route(): return await paginate(query)