mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 17:36:27 +00:00
api/delete-queue: Make fixtures/examples testable.
api/delete-queue now uses the Markdown extension in bugdown/api_code_examples to generate code examples and fixtures from tests.
This commit is contained in:
@@ -25,17 +25,7 @@ curl -X "DELETE" {{ api_url }}/v1/events \
|
|||||||
|
|
||||||
<div data-language="python" markdown="1">
|
<div data-language="python" markdown="1">
|
||||||
|
|
||||||
```python
|
{generate_code_example|delete-queue|example}
|
||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
import zulip
|
|
||||||
|
|
||||||
# Download ~/zuliprc-dev from your dev server
|
|
||||||
client = zulip.Client(config_file="~/zuliprc-dev")
|
|
||||||
|
|
||||||
# Delete a queue
|
|
||||||
print(client.deregister(queue_id="1515096410:1"))
|
|
||||||
```
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -80,12 +70,7 @@ zulip(config).then((client) => {
|
|||||||
|
|
||||||
A typical successful JSON response may look like:
|
A typical successful JSON response may look like:
|
||||||
|
|
||||||
```
|
{generate_code_example|delete-queue|fixture}
|
||||||
{
|
|
||||||
'msg':'',
|
|
||||||
'result':'success'
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
A typical JSON response for when the `queue_id` is non-existent or the
|
A typical JSON response for when the `queue_id` is non-existent or the
|
||||||
associated queue has already been deleted:
|
associated queue has already been deleted:
|
||||||
|
|||||||
@@ -234,5 +234,9 @@
|
|||||||
"msg":"",
|
"msg":"",
|
||||||
"queue_id":"1517975029:0",
|
"queue_id":"1517975029:0",
|
||||||
"result":"success"
|
"result":"success"
|
||||||
|
},
|
||||||
|
"delete-queue": {
|
||||||
|
"msg":"",
|
||||||
|
"result":"success"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -327,6 +327,18 @@ def register_queue(client):
|
|||||||
|
|
||||||
return result['queue_id']
|
return result['queue_id']
|
||||||
|
|
||||||
|
def deregister_queue(client, queue_id):
|
||||||
|
# type: (Client, str) -> None
|
||||||
|
|
||||||
|
# {code_example|start}
|
||||||
|
# Delete a queue (queue_id is the ID of the queue
|
||||||
|
# to be removed)
|
||||||
|
result = client.deregister(queue_id)
|
||||||
|
# {code_example|end}
|
||||||
|
|
||||||
|
fixture = FIXTURES['delete-queue']
|
||||||
|
test_against_fixture(result, fixture)
|
||||||
|
|
||||||
def test_invalid_api_key(client_with_invalid_key):
|
def test_invalid_api_key(client_with_invalid_key):
|
||||||
# type: (Client) -> None
|
# type: (Client) -> None
|
||||||
result = client_with_invalid_key.list_subscriptions()
|
result = client_with_invalid_key.list_subscriptions()
|
||||||
@@ -348,6 +360,7 @@ TEST_FUNCTIONS = {
|
|||||||
'remove-subscriptions': remove_subscriptions,
|
'remove-subscriptions': remove_subscriptions,
|
||||||
'get-all-users': get_members,
|
'get-all-users': get_members,
|
||||||
'register-queue': register_queue,
|
'register-queue': register_queue,
|
||||||
|
'delete-queue': deregister_queue,
|
||||||
}
|
}
|
||||||
|
|
||||||
# SETUP METHODS FOLLOW
|
# SETUP METHODS FOLLOW
|
||||||
@@ -396,7 +409,8 @@ def test_streams(client):
|
|||||||
def test_queues(client):
|
def test_queues(client):
|
||||||
# type: (Client) -> None
|
# type: (Client) -> None
|
||||||
|
|
||||||
register_queue(client)
|
queue_id = register_queue(client)
|
||||||
|
deregister_queue(client, queue_id)
|
||||||
|
|
||||||
def test_the_api(client):
|
def test_the_api(client):
|
||||||
# type: (Client) -> None
|
# type: (Client) -> None
|
||||||
|
|||||||
Reference in New Issue
Block a user