diff --git a/templates/zerver/api/add-subscriptions.md b/templates/zerver/api/add-subscriptions.md index 4e7dd6467e..4c7a389745 100644 --- a/templates/zerver/api/add-subscriptions.md +++ b/templates/zerver/api/add-subscriptions.md @@ -105,21 +105,7 @@ A typical successful JSON response may look like: A typical successful JSON response when the user is already subscribed to the streams specified: -``` -{ - 'subscribed':{ - - }, - 'msg':'', - 'result':'success', - 'already_subscribed':{ - 'sample-bot@localhost':[ - 'Nonexistent', - 'Verona' - ] - } -} -``` +{generate_code_example|add-subscriptions|fixture(already_subscribed)} A typical response for when the requesting user does not have access to a private stream and `authorization_errors_fatal` is `True`: diff --git a/templates/zerver/api/fixtures.json b/templates/zerver/api/fixtures.json index 60be5fd43b..8ea5571e0c 100644 --- a/templates/zerver/api/fixtures.json +++ b/templates/zerver/api/fixtures.json @@ -177,7 +177,19 @@ "new stream" ] } - } + }, + "already_subscribed": { + "already_subscribed":{ + "newbie@zulip.com":[ + "new stream" + ] + }, + "msg":"", + "result":"success", + "subscribed":{ + + } + }, }, "remove-subscriptions": { "msg":"", diff --git a/zerver/lib/api_test_helpers.py b/zerver/lib/api_test_helpers.py index 72f40bb22f..3ca5859213 100644 --- a/zerver/lib/api_test_helpers.py +++ b/zerver/lib/api_test_helpers.py @@ -47,6 +47,18 @@ def add_subscriptions(client): assert result['result'] == 'success' assert 'newbie@zulip.com' in result['subscribed'] +def test_add_subscriptions_already_subscribed(client): + # type: (Client) -> None + result = client.add_subscriptions( + streams=[ + {'name': 'new stream', 'description': 'New stream for testing'} + ], + principals=['newbie@zulip.com'] + ) + + fixture = FIXTURES['add-subscriptions']['already_subscribed'] + test_against_fixture(result, fixture) + def create_user(client): # type: (Client) -> None @@ -465,6 +477,7 @@ def test_streams(client): # type: (Client) -> None add_subscriptions(client) + test_add_subscriptions_already_subscribed(client) list_subscriptions(client) get_stream_id(client) get_streams(client)