-
Notifications
You must be signed in to change notification settings - Fork 16
Get requests is sorted according to last_modified #662
Get requests is sorted according to last_modified #662
Conversation
We should definitely add a test that should have been failling without your patch so that if someones removes this line in the future we will have a test for that. |
Is my solution to this bug correct ? Should I write test case for this ? Guide me for that. |
Thanks @ayusharma for taking the time to investigate this! I think we can just modify the
Yes, tests are the specifications of the application behaviour, therefore we should add a test that makes the default sorting behaviour explicit. Add a method here like You can also add another test to assert the behaviour when a sort order field is given (e.g. Good luck and enjoy :) Let us know if you have any question ! |
Thanks a lot :) In short I have to remove the limit parameter and make this function work on every condition.
and this would get transform to
Is it right ? |
Yep ! Then update tests and changelog :) |
How can I write the another test to assert the behaviour when a sort order field is given (e.g. -title) and several records have the same value for that field ? means we have different testdata in records with different titles. (We need same titles to perform test operation) and what does this function do |
You can just add the items to the storage yourself using the The way I would do it is by adding a new method to the class that inserts a specific record given its it def _add_record(self, i):
record = {
'title': 'MoFo #{0:02}'.format(i),
'status': i % 4,
'unread': (i % 2 == 0)
}
self.model.create_crecord(record) and then call it where you need, with an title that already exists ( |
If you look at the You can use a sort on status to assert that records are sorted by status and when two records have the same status, they will be sorted by last modified. |
Great! I merged it :) I just made a small adjustment about an assertion in the tests |
This solves the issue Kinto/kinto#434 and sorts the records according to the
last_modified
attribute.