Skip to content

Commit

Permalink
Uses the check_sole_error test helper.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfinkels committed Jun 9, 2016
1 parent 2c54f59 commit c7f4b27
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,7 @@ def test_create_absent(self):
"""
data = dict(data=dict(type='person'))
response = self.app.post('/api/person', data=dumps(data))
assert response.status_code == 400
document = loads(response.data)
errors = document['errors']
error = errors[0]
assert 'validation' in error['title'].lower()
assert 'email' in error['detail'].lower()
check_sole_error(response, 400, ['validation', 'email'])
# Check that the person was not created.
assert self.session.query(self.Person).count() == 0

Expand All @@ -321,12 +316,7 @@ def test_create_invalid(self):
}
}
response = self.app.post('/api/person', data=dumps(data))
assert response.status_code == 400
document = loads(response.data)
errors = document['errors']
error = errors[0]
assert 'validation' in error['title'].lower()
assert 'email' in error['detail'].lower()
check_sole_error(response, 400, ['validation', 'email'])
# Check that the person was not created.
assert self.session.query(self.Person).count() == 0

Expand Down Expand Up @@ -363,11 +353,6 @@ def test_update_invalid(self):
}
}
response = self.app.patch('/api/person/1', data=dumps(data))
assert response.status_code == 400
document = loads(response.data)
errors = document['errors']
error = errors[0]
assert 'validation' in error['title'].lower()
assert 'email' in error['detail'].lower()
check_sole_error(response, 400, ['validation', 'email'])
# Check that the person was not updated.
assert person.email == u'example@example.com'

0 comments on commit c7f4b27

Please sign in to comment.