mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 10:26:28 +00:00
transaction: Add 'savepoint=True' explicitly in tests, if used.
We create savepoint at a couple of places in backend tests to avoid rollback due to error raised within test's transaction. This commit explicitly adds 'savepoint=True' at those places.
This commit is contained in:
committed by
Tim Abbott
parent
fdcd518e26
commit
62b3e49075
@@ -1462,10 +1462,10 @@ Output:
|
||||
"invite_only": orjson.dumps(invite_only).decode(),
|
||||
}
|
||||
post_data.update(extra_post_data)
|
||||
# We wrap the API call with a 'transaction.atomic()' context
|
||||
# We wrap the API call with a 'transaction.atomic' context
|
||||
# manager as it helps us with NOT rolling back the entire
|
||||
# test transaction due to error responses.
|
||||
with transaction.atomic():
|
||||
with transaction.atomic(savepoint=True):
|
||||
result = self.api_post(
|
||||
user,
|
||||
"/api/v1/users/me/subscriptions",
|
||||
|
||||
@@ -4124,7 +4124,7 @@ class SubscriptionRestApiTest(ZulipTestCase):
|
||||
def thunk2() -> HttpResponse:
|
||||
raise JsonableError("random failure")
|
||||
|
||||
with transaction.atomic(), self.assertRaises(JsonableError):
|
||||
with transaction.atomic(savepoint=True), self.assertRaises(JsonableError):
|
||||
# The atomic() wrapper helps to avoid JsonableError breaking
|
||||
# the test's transaction.
|
||||
compose_views([thunk1, thunk2])
|
||||
|
||||
Reference in New Issue
Block a user