mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 15:33:30 +00:00
api/get-all-streams: Render multiple examples from single test method.
api/get-all-streams - make use of the api_code_example Markdown extension's feature of recursively extracting multiple code examples from a single test method.
This commit is contained in:
@@ -92,20 +92,25 @@ def get_streams(client):
|
|||||||
# {code_example|start}
|
# {code_example|start}
|
||||||
# Get all streams that the user has access to
|
# Get all streams that the user has access to
|
||||||
result = client.get_streams()
|
result = client.get_streams()
|
||||||
|
|
||||||
# You may pass in one or more of the query parameters mentioned above
|
|
||||||
# as keyword arguments, like so:
|
|
||||||
result = client.get_streams(include_public=True)
|
|
||||||
# {code_example|end}
|
# {code_example|end}
|
||||||
|
|
||||||
fixture = FIXTURES['get-all-streams']
|
fixture = FIXTURES['get-all-streams']
|
||||||
test_against_fixture(result, fixture, check_if_equal=['msg', 'result'],
|
test_against_fixture(result, fixture, check_if_equal=['msg', 'result'],
|
||||||
check_if_exists=['streams'])
|
check_if_exists=['streams'])
|
||||||
assert len(result['streams']) == len(fixture['streams'])
|
assert len(result['streams']) == len(fixture['streams'])
|
||||||
|
|
||||||
streams = [s for s in result['streams'] if s['name'] == 'new stream']
|
streams = [s for s in result['streams'] if s['name'] == 'new stream']
|
||||||
assert streams[0]['description'] == 'New stream for testing'
|
assert streams[0]['description'] == 'New stream for testing'
|
||||||
|
|
||||||
|
# {code_example|start}
|
||||||
|
# You may pass in one or more of the query parameters mentioned above
|
||||||
|
# as keyword arguments, like so:
|
||||||
|
result = client.get_streams(include_public=False)
|
||||||
|
# {code_example|end}
|
||||||
|
|
||||||
|
test_against_fixture(result, fixture, check_if_equal=['msg', 'result'],
|
||||||
|
check_if_exists=['streams'])
|
||||||
|
assert len(result['streams']) == 4
|
||||||
|
|
||||||
def get_subscribers(client):
|
def get_subscribers(client):
|
||||||
# type: (Client) -> None
|
# type: (Client) -> None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user