Skip to content

Instantly share code, notes, and snippets.

@paulgoetze
Last active February 19, 2019 05:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulgoetze/971edee21fbdd29d175f1c65c9bde585 to your computer and use it in GitHub Desktop.
Save paulgoetze/971edee21fbdd29d175f1c65c9bde585 to your computer and use it in GitHub Desktop.
Testing Your Python API App with JSON Schema - test_get_user()
def test_get_user(client):
# Do whatever is necessary to create a user here…
response = client.get('/users/1')
json_data = json.loads(response.data)
assert 'data' in json_data
assert 'type' in json_data['data']
assert 'id' in json_data['data']
assert 'attributes' in json_data['data']
assert 'email' in json_data['data']['attributes']
assert 'username' in json_data['email']['attributes']
@ecukalla
Copy link

You have a typo on line 12. It should be:
assert 'username' in json_data['data']['attributes']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment