api/get-profile: 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 zerver/lib/api_test_helpers.
This commit is contained in:
Eeshan Garg
2018-01-31 01:36:56 -03:30
committed by showell
parent 2bea4b70de
commit 162f34f0d0
3 changed files with 27 additions and 30 deletions

View File

@@ -60,10 +60,18 @@ def get_members(client):
def get_profile(client):
# type: (Client) -> None
# {code_example|start}
# Get the profile of the user/bot that requests this endpoint,
# which is `client` in this case:
result = client.get_profile()
assert result['is_admin']
assert result['email'] == 'iago@zulip.com'
assert result['full_name'] == 'Iago'
# {code_example|end}
fixture = FIXTURES['get-profile']
check_if_equal = ['email', 'full_name', 'msg', 'result', 'short_name']
check_if_exists = ['client_id', 'is_admin', 'is_bot', 'max_message_id',
'pointer', 'user_id']
test_against_fixture(result, fixture, check_if_equal=check_if_equal,
check_if_exists=check_if_exists)
def get_stream_id(client):
# type: (Client) -> None
@@ -245,6 +253,7 @@ TEST_FUNCTIONS = {
'get-subscribed-streams': list_subscriptions,
'get-all-streams': get_streams,
'create-user': create_user,
'get-profile': get_profile,
}
# SETUP METHODS FOLLOW