api/get-stream-id: Make code examples and 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 19:36:45 -03:30
committed by showell
parent d46753c26d
commit 6c634d6847
3 changed files with 15 additions and 18 deletions

View File

@@ -63,9 +63,15 @@ def get_profile(client):
def get_stream_id(client):
# type: (Client) -> None
# {code_example|start}
# Get the ID of a given stream
stream_name = 'new stream'
result = client.get_stream_id(stream_name)
assert int(result['stream_id'])
# {code_example|end}
fixture = FIXTURES['get-stream-id']
test_against_fixture(result, fixture, check_if_equal=['msg', 'result'],
check_if_exists=['stream_id'])
def get_streams(client):
# type: (Client) -> None
@@ -211,6 +217,7 @@ TEST_FUNCTIONS = {
'stream-message': stream_message,
'private-message': private_message,
'update-message': update_message,
'get-stream-id': get_stream_id,
}
# SETUP METHODS FOLLOW