api/get-subscribed-streams: Make code examples/fixtures testable.

This commit uses the Markdown extension defined in
zerver/lib/bugdown/api_generate_examples to generate the
example fixture and code example, so that both are tested
in tools/lib/api_tests.
This commit is contained in:
Eeshan Garg
2018-01-27 20:09:16 -03:30
committed by showell
parent 6c634d6847
commit dcf3a9cd18
3 changed files with 94 additions and 60 deletions

View File

@@ -96,8 +96,15 @@ def get_user_agent(client):
def list_subscriptions(client):
# type: (Client) -> None
# {code_example|start}
# Get all streams that the user is subscribed to
result = client.list_subscriptions()
assert result['result'] == 'success'
# {code_example|end}
fixture = FIXTURES['get-subscribed-streams']
test_against_fixture(result, fixture, check_if_equal=['msg', 'result'],
check_if_exists=['subscriptions'])
streams = [s for s in result['subscriptions'] if s['name'] == 'new stream']
assert streams[0]['description'] == 'New stream for testing'
@@ -218,6 +225,7 @@ TEST_FUNCTIONS = {
'private-message': private_message,
'update-message': update_message,
'get-stream-id': get_stream_id,
'get-subscribed-streams': list_subscriptions,
}
# SETUP METHODS FOLLOW