Skip to content

Commit

Permalink
Adds test for sorting on relationship attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
jfinkels committed Mar 25, 2017
1 parent 8c2c83a commit a676e4d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/test_fetching.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,25 @@ def test_case_insensitive_sorting(self):
self.assertEqual(person2['id'], u'1')
self.assertEqual(person2['attributes']['name'], u'B')

def test_case_insensitive_sorting_relationship_attributes(self):
"""Test for case-insensitive sorting on relationship attributes."""
person1 = self.Person(id=1, name=u'B')
person2 = self.Person(id=2, name=u'a')
article1 = self.Article(id=1, author=person1)
article2 = self.Article(id=2, author=person2)
self.session.add_all([article1, article2, person1, person2])
self.session.commit()
query_string = {'sort': 'author.name', 'ignorecase': 1}
response = self.app.get('/api/article', query_string=query_string)
# The ASCII character code for the uppercase letter 'B' comes
# before the ASCII character code for the lowercase letter 'a',
# but in case-insensitive sorting, the 'a' should precede the
# 'B'.
document = loads(response.data)
article1, article2 = document['data']
self.assertEqual(article1['id'], u'2')
self.assertEqual(article2['id'], u'1')


class TestFetchResource(ManagerTestBase):

Expand Down

0 comments on commit a676e4d

Please sign in to comment.