mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
test_subs: Use 'common_subscribe_to_streams' helper function.
In 'test_subs' we were making POST request to add subscrption using 'self.api_post'. This commit updates the code to use the test helper function 'common_subscribe_to_streams' instead. This prep commit will also help us to avoid adding 'transaction.atomic' context manager to these API calls individually in the case of error response in the next commit.
This commit is contained in:
committed by
Tim Abbott
parent
b0dbfc96a3
commit
9c614531fb
@@ -12,7 +12,6 @@ from typing import (
|
||||
Callable,
|
||||
Collection,
|
||||
Dict,
|
||||
Iterable,
|
||||
Iterator,
|
||||
List,
|
||||
Mapping,
|
||||
@@ -1439,15 +1438,22 @@ Output:
|
||||
def common_subscribe_to_streams(
|
||||
self,
|
||||
user: UserProfile,
|
||||
streams: Iterable[str],
|
||||
subscriptions_raw: List[str] | List[Dict[str, str]],
|
||||
extra_post_data: Mapping[str, Any] = {},
|
||||
invite_only: bool = False,
|
||||
is_web_public: bool = False,
|
||||
allow_fail: bool = False,
|
||||
**extra: str,
|
||||
) -> "TestHttpResponse":
|
||||
subscriptions: List[Dict[str, str]] = []
|
||||
for entry in subscriptions_raw:
|
||||
if isinstance(entry, str):
|
||||
subscriptions.append({"name": entry})
|
||||
else:
|
||||
subscriptions.append(entry)
|
||||
|
||||
post_data = {
|
||||
"subscriptions": orjson.dumps([{"name": stream} for stream in streams]).decode(),
|
||||
"subscriptions": orjson.dumps(subscriptions).decode(),
|
||||
"is_web_public": orjson.dumps(is_web_public).decode(),
|
||||
"invite_only": orjson.dumps(invite_only).decode(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user