Skip to content

Commit b5a15be

Browse files
JacobCoffeeclaude
andcommitted
test: fix transaction management in integration tests
Remove explicit commit() calls that close transactions within test fixtures. The db_session fixture uses session.begin() context manager which expects commits to happen on context exit, not manually within the test. Fixed tests: - test_full_guild_with_all_configs_lifecycle - test_cascade_delete_all_related_configs - test_guild_with_multiple_sotags_and_users - test_duplicate_guild_id_rejected 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 7008e68 commit b5a15be

File tree

1 file changed

+0
-6
lines changed

1 file changed

+0
-6
lines changed

tests/integration/test_api_endpoints.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ async def test_full_guild_with_all_configs_lifecycle(
282282
)
283283
db_session.add(forum_config)
284284
await db_session.flush()
285-
await db_session.commit()
286285

287286
# VERIFY all configs exist in DB
288287
github_result = await db_session.execute(select(GitHubConfig).where(GitHubConfig.guild_id == 9999))
@@ -297,7 +296,6 @@ async def test_full_guild_with_all_configs_lifecycle(
297296
# DELETE guild (should cascade)
298297
await db_session.delete(guild)
299298
await db_session.flush()
300-
await db_session.commit()
301299

302300
# VERIFY cascade deleted all configs
303301
guild_check = await db_session.execute(select(Guild).where(Guild.guild_id == 9999))
@@ -334,7 +332,6 @@ async def test_guild_with_multiple_sotags_and_users(
334332
db_session.add(so_tag)
335333

336334
await db_session.flush()
337-
await db_session.commit()
338335

339336
# Verify all tags exist
340337
result = await db_session.execute(select(SOTagsConfig).where(SOTagsConfig.guild_id == 8888))
@@ -532,7 +529,6 @@ async def test_duplicate_guild_id_rejected(
532529
guild1 = Guild(guild_id=5555, guild_name="First Guild")
533530
db_session.add(guild1)
534531
await db_session.flush()
535-
await db_session.commit()
536532

537533
# Try to create duplicate
538534
guild2 = Guild(guild_id=5555, guild_name="Duplicate Guild")
@@ -600,12 +596,10 @@ async def test_cascade_delete_all_related_configs(
600596

601597
db_session.add_all([github, forum, so_tag])
602598
await db_session.flush()
603-
await db_session.commit()
604599

605600
# Delete guild
606601
await db_session.delete(guild)
607602
await db_session.flush()
608-
await db_session.commit()
609603

610604
# Verify all configs deleted
611605
github_check = await db_session.execute(select(GitHubConfig).where(GitHubConfig.guild_id == 4444))

0 commit comments

Comments
 (0)