Test settings drop ATOMIC_REQUESTS, so the suite never runs a view inside the request transaction production uses #572
Labels
No labels
accessibility
authentication
breaking change
bug
documentation
enhancement
interface
internationalisation
observability
performance
security
tier
1
tier
2
tier
3
tier/4
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Postulo/postulo#572
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found on 2026-09-29 in a read-only review of postulo at
95348908d, comparing the test settings' database with production's.Checked again on 2026-10-01 against
mainat0a5cad587: still present.config/settings/base.py:140turnsATOMIC_REQUESTSon, and Postulo's handling of slow work (#206, #220, #247) is written around it.config/settings/test.pythen replacesDATABASESwholesale, in both the in-memory branch and thePOSTULO_TEST_DATABASE_URL(PostgreSQL) branch, and sets it neither time. Under the test settingsconnections["default"].settings_dict["ATOMIC_REQUESTS"]isFalse. Most tests do not notice, because pytest-django wraps each test in a transaction of its own; the tests markeddjango_db(transaction=True)run views with no transaction at all.config/settings/test.py:13and:22-24(the twoDATABASESassignments);config/settings/base.py:140(DATABASES["default"].setdefault("ATOMIC_REQUESTS", True));tests/test_slow_requests.py:1-13(its docstring states thatATOMIC_REQUESTSis on);tests/test_backup.py:33(pytest.mark.django_db(transaction=True)).transaction=Truetests there is no enclosing transaction.core/backup.py:98-105refuses to run inside one (_not_in_a_transaction), so a Server settings view for backups (#242) that forgotnon_atomic_requestswould pass intests/test_backup.pyand answer "A backup cannot be taken or restored from inside a transaction" in production.tests/test_slow_requests.pychecks only each view's_non_atomic_requestsattribute, so a change that stopped base.py settingATOMIC_REQUESTSwould not fail it either.test.py, addDATABASES["default"]["ATOMIC_REQUESTS"] = True, and add a test intests/test_slow_requests.pyasserting thatconnection.settings_dict["ATOMIC_REQUESTS"]is true under the test settings and in the production settings read through the existing subprocess fixture intests/security/conftest.py.The reported scenario, a caught
IntegrityErrorleaving a PostgreSQL transaction aborted only in production, does not hold: the test's own transaction reproduces that state.Done when
tests/test_slow_requests.pyassertingATOMIC_REQUESTSis on for the default connection under the test settings, which fails today.Landed on main with a green Forgejo CI run. Its entry in the CHANGELOG's Unreleased section ends in (#572).