api/add-subscriptions: Test fixture for "already_subscribed".

In templates/zerver/api/add-subscriptions, we have a sample fixture
for when the user being subscribed is already subscribed to a
stream. This commit tests that fixture against a running server.
This commit is contained in:
Eeshan Garg
2018-02-16 18:11:29 -03:30
committed by Tim Abbott
parent 06bf47d2f5
commit 806476173f
3 changed files with 27 additions and 16 deletions

View File

@@ -105,21 +105,7 @@ A typical successful JSON response may look like:
A typical successful JSON response when the user is already subscribed to A typical successful JSON response when the user is already subscribed to
the streams specified: the streams specified:
``` {generate_code_example|add-subscriptions|fixture(already_subscribed)}
{
'subscribed':{
},
'msg':'',
'result':'success',
'already_subscribed':{
'sample-bot@localhost':[
'Nonexistent',
'Verona'
]
}
}
```
A typical response for when the requesting user does not have access to A typical response for when the requesting user does not have access to
a private stream and `authorization_errors_fatal` is `True`: a private stream and `authorization_errors_fatal` is `True`:

View File

@@ -177,8 +177,20 @@
"new stream" "new stream"
] ]
} }
},
"already_subscribed": {
"already_subscribed":{
"newbie@zulip.com":[
"new stream"
]
},
"msg":"",
"result":"success",
"subscribed":{
} }
}, },
},
"remove-subscriptions": { "remove-subscriptions": {
"msg":"", "msg":"",
"not_subscribed":[ "not_subscribed":[

View File

@@ -47,6 +47,18 @@ def add_subscriptions(client):
assert result['result'] == 'success' assert result['result'] == 'success'
assert 'newbie@zulip.com' in result['subscribed'] 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): def create_user(client):
# type: (Client) -> None # type: (Client) -> None
@@ -465,6 +477,7 @@ def test_streams(client):
# type: (Client) -> None # type: (Client) -> None
add_subscriptions(client) add_subscriptions(client)
test_add_subscriptions_already_subscribed(client)
list_subscriptions(client) list_subscriptions(client)
get_stream_id(client) get_stream_id(client)
get_streams(client) get_streams(client)