Skip to content

Commit

Permalink
Order TestPlan objects when searching them and when testing
Browse files Browse the repository at this point in the history
this fixes test failures on Postgres which are due to DB returning
the records in non-deterministic order.
  • Loading branch information
atodorov committed Nov 3, 2017
1 parent f592a94 commit cb21646
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tcms/testplans/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def list(cls, query=None):
Q(name__icontains=new_query['search']))
del new_query['search']

return q.filter(**new_query).distinct()
return q.filter(**new_query).order_by('pk').distinct()

def confirmed_case(self):
return self.case.filter(case_status__name='CONFIRMED')
Expand Down
2 changes: 1 addition & 1 deletion tcms/testplans/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ def test_search_all_runs(self):
self.assertEqual(0, data['sEcho'])
self.assertEqual(TestPlan.objects.count(), data['iTotalRecords'])
self.assertEqual(TestPlan.objects.count(), data['iTotalDisplayRecords'])
for i, plan in enumerate(TestPlan.objects.all()):
for i, plan in enumerate(TestPlan.objects.all().order_by('pk')):
self.assertEqual(
"<a href='{}'>{}</a>".format(plan.get_absolute_url(), plan.pk),
data['aaData'][i]['1'])
Expand Down

0 comments on commit cb21646

Please sign in to comment.