diff --git a/templates/zerver/api/create-user.md b/templates/zerver/api/create-user.md index a113712421..9053beb04f 100644 --- a/templates/zerver/api/create-user.md +++ b/templates/zerver/api/create-user.md @@ -72,15 +72,9 @@ zulip(config).then((client) => { A typical successful JSON response may look like: -{generate_code_example|create-user|fixture} - +{generate_code_example|create-user|fixture(successful_response)} A typical JSON response for when another user with the same email address already exists in the realm: -``` -{ - 'msg':"Email 'newbie@zulip.com' already in use", - 'result':'error' -} -``` +{generate_code_example|create-user|fixture(email_already_used_error)} diff --git a/templates/zerver/api/fixtures.json b/templates/zerver/api/fixtures.json index 87c9b3b57a..a6003e35a9 100644 --- a/templates/zerver/api/fixtures.json +++ b/templates/zerver/api/fixtures.json @@ -149,8 +149,14 @@ ] }, "create-user": { - "msg":"", - "result":"success" + "successful_response": { + "msg":"", + "result":"success" + }, + "email_already_used_error": { + "msg": "Email 'newbie@zulip.com' already in use", + "result": "error" + } }, "get-profile": { "client_id":"74c768b081076fdb3c4326256c17467e", diff --git a/zerver/lib/api_test_helpers.py b/zerver/lib/api_test_helpers.py index 886a6622af..7aabf499b5 100644 --- a/zerver/lib/api_test_helpers.py +++ b/zerver/lib/api_test_helpers.py @@ -108,7 +108,13 @@ def create_user(client): result = client.create_user(request) # {code_example|end} - fixture = FIXTURES['create-user'] + fixture = FIXTURES['create-user']['successful_response'] + test_against_fixture(result, fixture) + + # Test "Email already used error" + result = client.create_user(request) + + fixture = FIXTURES['create-user']['email_already_used_error'] test_against_fixture(result, fixture) def get_members(client):