From 0e22872892f250eb7852ce5cc1a518bc9b2e6c66 Mon Sep 17 00:00:00 2001 From: Jacob Coffee Date: Sun, 23 Nov 2025 15:33:10 -0600 Subject: [PATCH 1/5] fix: remove transaction commit from full guild lifecycle test The db_session fixture uses a transaction context manager that auto-rolls back. Calling commit() within the transaction context closes the transaction and breaks subsequent queries. Fixed by relying on flush() for within-transaction visibility. - Remove commit() call after delete operation - Database queries see flushed changes within transaction - Test verifies cascade delete behavior correctly Fixes test: TestFullGuildLifecycleWithAllConfigs::test_full_guild_with_all_configs_lifecycle --- tests/integration/test_api_endpoints.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/integration/test_api_endpoints.py b/tests/integration/test_api_endpoints.py index cb1c31d4..8edce392 100644 --- a/tests/integration/test_api_endpoints.py +++ b/tests/integration/test_api_endpoints.py @@ -296,7 +296,6 @@ async def test_full_guild_with_all_configs_lifecycle( # DELETE guild (should cascade) await db_session.delete(guild) await db_session.flush() - await db_session.commit() # VERIFY cascade deleted all configs guild_check = await db_session.execute(select(Guild).where(Guild.guild_id == 9999)) From c1fe78a63a5a0e277c4174a57d3311630dc67765 Mon Sep 17 00:00:00 2001 From: Jacob Coffee Date: Sun, 23 Nov 2025 15:33:37 -0600 Subject: [PATCH 2/5] fix: remove transaction commit from multiple SO tags test Remove commit() call that closes transaction prematurely. Flush() provides sufficient visibility for verification queries within the same transaction context. Fixes test: TestFullGuildLifecycleWithAllConfigs::test_guild_with_multiple_sotags_and_users --- tests/integration/test_api_endpoints.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/integration/test_api_endpoints.py b/tests/integration/test_api_endpoints.py index 8edce392..47b11bec 100644 --- a/tests/integration/test_api_endpoints.py +++ b/tests/integration/test_api_endpoints.py @@ -332,7 +332,6 @@ async def test_guild_with_multiple_sotags_and_users( db_session.add(so_tag) await db_session.flush() - await db_session.commit() # Verify all tags exist result = await db_session.execute(select(SOTagsConfig).where(SOTagsConfig.guild_id == 8888)) From 4e74d54235d6f01a9e96e827d4331a6315aa1a60 Mon Sep 17 00:00:00 2001 From: Jacob Coffee Date: Sun, 23 Nov 2025 15:34:06 -0600 Subject: [PATCH 3/5] fix: remove transaction commit from duplicate guild ID test Database integrity constraints are enforced during flush(), not just on commit(). Remove unnecessary commit() and rollback() calls - the fixture handles transaction cleanup. Fixes test: TestDatabaseIntegrity::test_duplicate_guild_id_rejected --- tests/integration/test_api_endpoints.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/integration/test_api_endpoints.py b/tests/integration/test_api_endpoints.py index 47b11bec..c973ea2b 100644 --- a/tests/integration/test_api_endpoints.py +++ b/tests/integration/test_api_endpoints.py @@ -526,7 +526,6 @@ async def test_duplicate_guild_id_rejected( guild1 = Guild(guild_id=5555, guild_name="First Guild") db_session.add(guild1) await db_session.flush() - await db_session.commit() # Try to create duplicate - should raise integrity error from sqlalchemy.exc import IntegrityError @@ -537,8 +536,6 @@ async def test_duplicate_guild_id_rejected( with pytest.raises(IntegrityError): await db_session.flush() - await db_session.rollback() - async def test_foreign_key_constraint_enforced( self, db_session: AsyncSession, From eb9cd450b7b67f138a764ee69232093a1e6dc3c1 Mon Sep 17 00:00:00 2001 From: Jacob Coffee Date: Sun, 23 Nov 2025 15:34:34 -0600 Subject: [PATCH 4/5] fix: remove transaction commits from cascade delete test Cascade delete behavior works within transactions after flush(). Remove commit() calls that close transaction prematurely. Fixes test: TestDatabaseIntegrity::test_cascade_delete_all_related_configs --- tests/integration/test_api_endpoints.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/integration/test_api_endpoints.py b/tests/integration/test_api_endpoints.py index c973ea2b..ed7d569c 100644 --- a/tests/integration/test_api_endpoints.py +++ b/tests/integration/test_api_endpoints.py @@ -592,12 +592,10 @@ async def test_cascade_delete_all_related_configs( db_session.add_all([github, forum, so_tag]) await db_session.flush() - await db_session.commit() # Delete guild await db_session.delete(guild) await db_session.flush() - await db_session.commit() # Verify all configs deleted github_check = await db_session.execute(select(GitHubConfig).where(GitHubConfig.guild_id == 4444)) From 05a848a93e376fdb89ab55df1ad0c1216c02b18f Mon Sep 17 00:00:00 2001 From: Jacob Coffee Date: Sun, 23 Nov 2025 15:35:04 -0600 Subject: [PATCH 5/5] fix: use correct pagination parameter in list guilds test The guilds list endpoint uses 'limit' and 'offset' parameters, not 'pageSize' and 'currentPage'. Update test to match API contract. This test was sending pageSize=5 but the endpoint ignored it and used the default limit of 20, causing the assertion to fail. Also remove unnecessary commit() call from test setup. Fixes test: TestAPIPaginationConsistency::test_pagination_offset_and_limit --- tests/integration/test_api_endpoints.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/integration/test_api_endpoints.py b/tests/integration/test_api_endpoints.py index ed7d569c..8185313b 100644 --- a/tests/integration/test_api_endpoints.py +++ b/tests/integration/test_api_endpoints.py @@ -487,10 +487,9 @@ async def test_pagination_offset_and_limit( db_session.add(guild) await db_session.flush() - await db_session.commit() # Test with explicit limit - response = await api_client.get("/api/guilds/list?pageSize=5") + response = await api_client.get("/api/guilds/list?limit=5") if response.status_code == HTTP_200_OK: data = response.json() # Should respect page size limit