Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
add_subscriptions_backend: Add 'transaction.atomic' decorator.
Prakhar Pratyushd92eb77c9840
diff --git a/zerver/lib/test_classes.py b/zerver/lib/test_classes.pyindex 5684cd2af09..3269234381d 100644--- a/zerver/lib/test_classes.py+++ b/zerver/lib/test_classes.py@@ -32,7 +32,7 @@ from django.apps import appsfrom django.conf import settingsfrom django.core.mail import EmailMessagefrom django.core.signals import got_request_exception-from django.db import connection+from django.db import connection, transactionfrom django.db.migrations.executor import MigrationExecutorfrom django.db.migrations.state import StateAppsfrom django.db.utils import IntegrityError@@ -1458,13 +1458,17 @@ Output:"invite_only": orjson.dumps(invite_only).decode(),}post_data.update(extra_post_data)- result = self.api_post(- user,- "/api/v1/users/me/subscriptions",- post_data,- intentionally_undocumented=False,- **extra,- )+ # 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():+ result = self.api_post(+ user,+ "/api/v1/users/me/subscriptions",+ post_data,+ intentionally_undocumented=False,+ **extra,+ )if not allow_fail:self.assert_json_success(result)return resultdiff --git a/zerver/views/streams.py b/zerver/views/streams.pyindex 36891ce3427..b0a5488c843 100644--- a/zerver/views/streams.py+++ b/zerver/views/streams.py@@ -533,6 +533,7 @@ RETENTION_DEFAULT: Union[str, int] = "realm_default"EMPTY_PRINCIPALS: Union[Sequence[str], Sequence[int]] = [][email protected](savepoint=False)@require_non_guest_user@has_request_variablesdef add_subscriptions_backend(