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:
Eeshan Garg 2018-02-07 23:24:20 -03:30 committed by Tim Abbott
parent 344cf2c8ee
commit ac5c355a60
3 changed files with 21 additions and 18 deletions

View File

@ -25,17 +25,7 @@ curl -X "DELETE" {{ api_url }}/v1/events \
<div data-language="python" markdown="1">
```python
#!/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"))
```
{generate_code_example|delete-queue|example}
</div>
@ -80,12 +70,7 @@ zulip(config).then((client) => {
A typical successful JSON response may look like:
```
{
'msg':'',
'result':'success'
}
```
{generate_code_example|delete-queue|fixture}
A typical JSON response for when the `queue_id` is non-existent or the
associated queue has already been deleted:

View File

@ -234,5 +234,9 @@
"msg":"",
"queue_id":"1517975029:0",
"result":"success"
},
"delete-queue": {
"msg":"",
"result":"success"
}
}

View File

@ -327,6 +327,18 @@ def register_queue(client):
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):
# type: (Client) -> None
result = client_with_invalid_key.list_subscriptions()
@ -348,6 +360,7 @@ TEST_FUNCTIONS = {
'remove-subscriptions': remove_subscriptions,
'get-all-users': get_members,
'register-queue': register_queue,
'delete-queue': deregister_queue,
}
# SETUP METHODS FOLLOW
@ -396,7 +409,8 @@ def test_streams(client):
def test_queues(client):
# type: (Client) -> None
register_queue(client)
queue_id = register_queue(client)
deregister_queue(client, queue_id)
def test_the_api(client):
# type: (Client) -> None