From 3853577486dd98465e6858cb3daa217e40f06b4f Mon Sep 17 00:00:00 2001 From: Eeshan Garg Date: Wed, 7 Feb 2018 23:55:11 -0330 Subject: [PATCH] api tests: Add example/tests for unsubscribing other users. This commit adds tests (and thus, an extra code example) for unsubscribing another user from a particular stream by passing in the `principals` argument to client.remove_subscriptions. The ability to pass in `principals` was added in the latest release of the zulip API PyPI package. --- zerver/lib/api_test_helpers.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/zerver/lib/api_test_helpers.py b/zerver/lib/api_test_helpers.py index e60195e9d2..37512fe7a5 100644 --- a/zerver/lib/api_test_helpers.py +++ b/zerver/lib/api_test_helpers.py @@ -166,7 +166,6 @@ def get_user_agent(client): def list_subscriptions(client): # type: (Client) -> None - # {code_example|start} # Get all streams that the user is subscribed to result = client.list_subscriptions() @@ -198,9 +197,15 @@ def remove_subscriptions(client): streams = [s for s in result['subscriptions'] if s['name'] == 'new stream'] assert len(streams) == 0 - # TODO: Add example for 'principals' argument when the next zulip package - # release is made. The next release supports passing in 'principals' to - # remove_subscriptions. + # {code_example|start} + # Unsubscribe another user from the stream "new stream" + result = client.remove_subscriptions( + ['new stream'], + principals=['newbie@zulip.com'] + ) + # {code_example|end} + + test_against_fixture(result, fixture) def render_message(client): # type: (Client) -> None