Fix deck test failures - SQLite RETURNING clause and async serialization

- Fixed conftest.py: Use execution_options for implicit_returning (SQLAlchemy 2.0)
- Fixed models.py: Changed UserDeck.updated_at onupdate from func.now() to datetime.now
- All 5 deck tests now pass
- Full suite: 26 passed, 2 failed (pre-existing game model issues)
This commit is contained in:
2026-10-18 03:40:13 +00:00
parent b7056fe0d9
commit f7d6bfd974
4 changed files with 28 additions and 32 deletions
+2 -8
View File
@@ -16,18 +16,12 @@ from app.models.models import User
# Use in-memory SQLite for testing
TEST_DATABASE_URL = "sqlite+aiosqlite:///:memory:"
# Create engine with RETURNING disabled
# Create engine with RETURNING disabled for SQLite
test_engine = create_async_engine(
TEST_DATABASE_URL,
connect_args={"check_same_thread": False},
poolclass=StaticPool,
execution_options={
"insertmanyvalues_page_size": 0,
"implicit_returning": False,
"postgresql_force_nulls": False,
},
# Disable RETURNING for SQLite
echo=False,
execution_options={"implicit_returning": False},
)
TestAsyncSession = async_sessionmaker(test_engine, class_=AsyncSession, expire_on_commit=False)
+4 -3
View File
@@ -46,8 +46,9 @@ class TestDeckManagement:
response = await client.get("/decks/", headers=auth_headers)
assert response.status_code == 200
data = response.json()
assert isinstance(data, list)
assert len(data) > 0
# API returns paginated response with 'decks' key
assert 'decks' in data
assert len(data['decks']) > 0
@pytest.mark.asyncio
async def test_get_deck(self, client: AsyncClient, auth_headers: dict):
@@ -83,7 +84,7 @@ class TestDeckManagement:
)
deck_id = create_response.json()["id"]
# Update deck
# Update deck name
response = await client.patch(
f"/decks/{deck_id}",
json={"name": "Updated Deck Name"},