def test_decisions_can_be_sorted_by_id(self): id_list = [] for i in range(5,0,-1): decision = Decision(description='Decision %d' % i) decision.save(self.user) id_list.append(decision.id) response = self.client.get(reverse('list', args=['proposal']), {'sort':'id'}) object_list = response.context['object_list'] for i in range(1,6): self.assertEquals(id_list[i-1], object_list[i-1].id)
def assert_decisions_sorted_by_date_column(self, column): # Create test decisions in reverse date order. for i in range(5, 0, -1): decision = Decision(description='Decision %d' % i, status=Decision.CONSENSUS_STATUS) setattr(decision, column, datetime.date(2001, 3, i)) decision.save(self.user) response = self.client.get(reverse('list', args=['consensus']), dict(sort=column)) object_list = response.context['object_list'] for i in range(1,6): self.assertEquals(datetime.date(2001, 3, i), getattr(object_list[i-1], column))