Skip to content

Commit

Permalink
Merge a87b448 into 768f20c
Browse files Browse the repository at this point in the history
  • Loading branch information
jfinkels committed Jun 9, 2016
2 parents 768f20c + a87b448 commit 98dc18e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
2 changes: 2 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@
``python setup.py test``).
"""
import warnings
warnings.simplefilter('error')
8 changes: 7 additions & 1 deletion tests/test_filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from datetime import datetime
from datetime import time
from unittest2 import skip
import sys

# This import is unused but is required for testing on PyPy. CPython can
# use psycopg2, but PyPy can only use psycopg2cffi.
Expand All @@ -40,6 +41,11 @@
from .helpers import loads
from .helpers import ManagerTestBase

if sys.version_info < (3, 0):
to_string = unicode
else:
to_string = str


#: The PostgreSQL class used to create a temporary database for testing.
#:
Expand Down Expand Up @@ -949,7 +955,7 @@ def test_to_many_filter_by_relation(self):
self.session.add(article)
for i in range(1, 3):
comment = self.Comment(id=i)
tag = self.Tag(name=str(i))
tag = self.Tag(name=to_string(i))
comment.article = article
comment.tag = tag
self.session.add_all([comment, tag])
Expand Down
23 changes: 5 additions & 18 deletions tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,9 @@ 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()
print(response)
print(response.data)
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 +318,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 +355,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 98dc18e

Please sign in to comment.