mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
test helpers: Tweak common_subscribe_to_streams.
We assert that the post was successful, to give more immediate feedback for tests that don't bother to check the return value and may be implicitly assuming this method just works in all cases. And we also make it more convenient for tests that are happy-path tests--they don't have to do the assertion themselves. (And they're still free to do deeper checks on the json.) We opt out with allow_fail=True. We probably want a more direct API eventually for tests that are clearly trying to test the failure path for subscribing to streams. It's possible that a couple tests here that I added allow_fail=True to just have flawed data setup-- I don't have time to investigate all cases, but hopefully they will at least stand out more.
This commit is contained in:
@@ -756,11 +756,14 @@ class ZulipTestCase(TestCase):
|
||||
# Subscribe to a stream by making an API request
|
||||
def common_subscribe_to_streams(self, user: UserProfile, streams: Iterable[str],
|
||||
extra_post_data: Dict[str, Any]={}, invite_only: bool=False,
|
||||
allow_fail: bool=False,
|
||||
**kwargs: Any) -> HttpResponse:
|
||||
post_data = {'subscriptions': ujson.dumps([{"name": stream} for stream in streams]),
|
||||
'invite_only': ujson.dumps(invite_only)}
|
||||
post_data.update(extra_post_data)
|
||||
result = self.api_post(user, "/api/v1/users/me/subscriptions", post_data, **kwargs)
|
||||
if not allow_fail:
|
||||
self.assert_json_success(result)
|
||||
return result
|
||||
|
||||
def check_user_subscribed_only_to_streams(self, user_name: str,
|
||||
|
||||
Reference in New Issue
Block a user