Repository navigation
test(transaction): add comprehensive transaction mode and advanced feature tests - #20
Merged
vistart merged 3 commits intoApr 8, 2026
Merged
Conversation
…ature tests - Add test_transaction_mode_effect.py for READ ONLY/READ WRITE mode effects - Verify READ ONLY mode rejects INSERT/UPDATE/DELETE operations - Verify READ WRITE mode allows all write operations - Test mode persistence across transactions - Test mode combined with isolation level - Include both sync and async test coverage - Add test_transaction_advanced_features.py for advanced PostgreSQL features - Test DEFERRABLE transaction behavior with SERIALIZABLE isolation - Test SET TRANSACTION statement for isolation level and access mode - Test SESSION CHARACTERISTICS persistence and reset - Include async test counterparts - Fix test_transaction_deferrable.py to use public API - Replace _deferred_constraints private attribute access with get_deferred_constraints() All tests verify PostgreSQL transaction features work correctly with the transaction manager and expression system. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/v1.0.0.dev9 #20 +/- ##
=======================================================
+ Coverage 72.56% 72.89% +0.32%
=======================================================
Files 112 112
Lines 6008 6006 -2
Branches 991 991
=======================================================
+ Hits 4360 4378 +18
+ Misses 1338 1322 -16
+ Partials 310 306 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
PostgreSQL does not require explicit isolation level in BEGIN statement. When isolation_level is None (not explicitly set), BEGIN should not include ISOLATION LEVEL clause, allowing SESSION CHARACTERISTICS to take effect. Changes: - Remove default isolation_level initialization in PostgresTransactionManager - Remove default isolation_level initialization in AsyncPostgresTransactionManager - Update test_session_characteristics_with_isolation_level to verify that SESSION CHARACTERISTICS work when isolation_level is None - Add async counterpart test for sync/async parity This ensures: 1. BEGIN without explicit isolation level respects SESSION CHARACTERISTICS 2. Users can still set explicit isolation_level to override session defaults 3. Synchronous and asynchronous behaviors are equivalent Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
vistart
added a commit
that referenced
this pull request
Apr 8, 2026
…ature tests (#20) * test(transaction): add comprehensive transaction mode and advanced feature tests - Add test_transaction_mode_effect.py for READ ONLY/READ WRITE mode effects - Verify READ ONLY mode rejects INSERT/UPDATE/DELETE operations - Verify READ WRITE mode allows all write operations - Test mode persistence across transactions - Test mode combined with isolation level - Include both sync and async test coverage - Add test_transaction_advanced_features.py for advanced PostgreSQL features - Test DEFERRABLE transaction behavior with SERIALIZABLE isolation - Test SET TRANSACTION statement for isolation level and access mode - Test SESSION CHARACTERISTICS persistence and reset - Include async test counterparts - Fix test_transaction_deferrable.py to use public API - Replace _deferred_constraints private attribute access with get_deferred_constraints() All tests verify PostgreSQL transaction features work correctly with the transaction manager and expression system. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(transaction): respect PostgreSQL optional syntax for BEGIN statement PostgreSQL does not require explicit isolation level in BEGIN statement. When isolation_level is None (not explicitly set), BEGIN should not include ISOLATION LEVEL clause, allowing SESSION CHARACTERISTICS to take effect. Changes: - Remove default isolation_level initialization in PostgresTransactionManager - Remove default isolation_level initialization in AsyncPostgresTransactionManager - Update test_session_characteristics_with_isolation_level to verify that SESSION CHARACTERISTICS work when isolation_level is None - Add async counterpart test for sync/async parity This ensures: 1. BEGIN without explicit isolation level respects SESSION CHARACTERISTICS 2. Users can still set explicit isolation_level to override session defaults 3. Synchronous and asynchronous behaviors are equivalent Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: add changelog fragment for PR #20 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
14 of 21 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
Add comprehensive test coverage for PostgreSQL transaction features, including transaction access modes (READ ONLY/READ WRITE), DEFERRABLE transactions, SET TRANSACTION statement, and SESSION CHARACTERISTICS.
This PR supplements missing test coverage to ensure PostgreSQL backend's transaction capabilities are fully verified.
Type of change
test: Adding missing tests or correcting existing testsBreaking Change
Applicable
rhosocial-activerecordVersion Range:Related Repositories/Packages
python-activerecord- Core transaction expression supportpython-activerecord-postgres- PostgreSQL-specific transaction testsTesting
Test Plan:
pytest tests/rhosocial/activerecord_postgres_test/feature/backend/test_transaction_mode_effect.pypytest tests/rhosocial/activerecord_postgres_test/feature/backend/test_transaction_advanced_features.pypytest tests/rhosocial/activerecord_postgres_test/feature/backend/test_transaction_deferrable.pyTests added:
test_transaction_mode_effect.py(332 lines) - READ ONLY/READ WRITE mode effect teststest_transaction_advanced_features.py(460 lines) - DEFERRABLE, SET TRANSACTION, SESSION CHARACTERISTICS teststest_transaction_deferrable.pyto use public APIget_deferred_constraints()Checklist
Additional Notes
Test Coverage Summary
All 93 transaction-related tests pass.