Skip to content

Commit

Permalink
Use unicode strings in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jfinkels committed Mar 7, 2016
1 parent e02495b commit a024ccc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions tests/test_fetching.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ def test_sorting_null_field(self):
"""
person1 = self.Person(id=1)
person2 = self.Person(id=2, name='foo')
person3 = self.Person(id=3, name='bar')
person2 = self.Person(id=2, name=u'foo')
person3 = self.Person(id=3, name=u'bar')
person4 = self.Person(id=4)
self.session.add_all([person1, person2, person3, person4])
self.session.commit()
Expand Down
22 changes: 11 additions & 11 deletions tests/test_updating.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def test_wrong_content_type(self):
with a :http:status:`415`.
"""
person = self.Person(id=1, name='foo')
person = self.Person(id=1, name=u'foo')
self.session.add(person)
self.session.commit()
headers = {'Content-Type': 'application/json'}
Expand All @@ -138,15 +138,15 @@ def test_wrong_content_type(self):
response = self.app.patch('/api/person/1', data=dumps(data),
headers=headers)
assert response.status_code == 415
assert person.name == 'foo'
assert person.name == u'foo'

def test_wrong_accept_header(self):
"""Tests that if a client specifies only :http:header:`Accept`
headers with non-JSON API media types, then the server responds
with a :http:status:`406`.
"""
person = self.Person(id=1, name='foo')
person = self.Person(id=1, name=u'foo')
self.session.add(person)
self.session.commit()
headers = {'Accept': 'application/json'}
Expand All @@ -162,7 +162,7 @@ def test_wrong_accept_header(self):
response = self.app.patch('/api/person/1', data=dumps(data),
headers=headers)
assert response.status_code == 406
assert person.name == 'foo'
assert person.name == u'foo'

def test_related_resource_url_forbidden(self):
"""Tests that :http:method:`patch` requests to a related resource URL
Expand Down Expand Up @@ -331,7 +331,7 @@ def test_rollback_on_integrity_error(self):
data = {'data':
{'type': 'person',
'id': '2',
'attributes': {'name': 'foo'}
'attributes': {'name': u'foo'}
}
}
response = self.app.patch('/api/person/2', data=dumps(data))
Expand Down Expand Up @@ -447,7 +447,7 @@ def test_collection_name(self):
}
response = self.app.patch('/api/people/1', data=dumps(data))
assert response.status_code == 204
assert person.name == 'foo'
assert person.name == u'foo'

def test_different_endpoints(self):
"""Tests for updating the same resource from different endpoints."""
Expand All @@ -464,7 +464,7 @@ def test_different_endpoints(self):
}
response = self.app.patch('/api/person/1', data=dumps(data))
assert response.status_code == 204
assert person.name == 'foo'
assert person.name == u'foo'
data = {'data':
{'type': 'person',
'id': '1',
Expand Down Expand Up @@ -682,7 +682,7 @@ def test_missing_type(self):
response = self.app.patch('/api/person/1', data=dumps(data))
assert response.status_code == 400
# TODO check error message here
assert person.name == 'foo'
assert person.name == u'foo'

def test_missing_id(self):
"""Tests that attempting to update a resource without providing an ID
Expand All @@ -700,7 +700,7 @@ def test_missing_id(self):
response = self.app.patch('/api/person/1', data=dumps(data))
assert response.status_code == 400
# TODO check error message here
assert person.name == 'foo'
assert person.name == u'foo'

def test_nonexistent_to_one_link(self):
"""Tests that an attempt to update a to-one relationship with a
Expand Down Expand Up @@ -855,7 +855,7 @@ def increment_id(resource_id=None, **kw):
}
response = self.app.patch('/api/person/0', data=dumps(data))
assert response.status_code == 204
assert person.name == 'foo'
assert person.name == u'foo'

def test_single_resource_processing_exception(self):
"""Tests for a preprocessor that raises a :exc:`ProcessingException`
Expand Down Expand Up @@ -885,7 +885,7 @@ def forbidden(**kw):
assert len(errors) == 1
error = errors[0]
assert 'forbidden' == error['detail']
assert person.name == 'foo'
assert person.name == u'foo'

def test_single_resource(self):
"""Tests :http:method:`patch` requests for a single resource with a
Expand Down
6 changes: 3 additions & 3 deletions tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,13 @@ def test_update_valid(self):
error response.
"""
person = self.Person(id=1, email='example@example.com')
person = self.Person(id=1, email=u'example@example.com')
self.session.add(person)
self.session.commit()
data = {'data':
{'id': '1',
'type': 'person',
'attributes': {'email': 'foo@example.com'}
'attributes': {'email': u'foo@example.com'}
}
}
response = self.app.patch('/api/person/1', data=dumps(data))
Expand All @@ -353,7 +353,7 @@ def test_update_invalid(self):
an error response.
"""
person = self.Person(id=1, email='example@example.com')
person = self.Person(id=1, email=u'example@example.com')
self.session.add(person)
self.session.commit()
data = {'data':
Expand Down

0 comments on commit a024ccc

Please sign in to comment.