mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 15:33:30 +00:00
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:
@@ -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`:
|
||||
|
||||
@@ -177,8 +177,20 @@
|
||||
"new stream"
|
||||
]
|
||||
}
|
||||
},
|
||||
"already_subscribed": {
|
||||
"already_subscribed":{
|
||||
"newbie@zulip.com":[
|
||||
"new stream"
|
||||
]
|
||||
},
|
||||
"msg":"",
|
||||
"result":"success",
|
||||
"subscribed":{
|
||||
|
||||
}
|
||||
},
|
||||
},
|
||||
"remove-subscriptions": {
|
||||
"msg":"",
|
||||
"not_subscribed":[
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user