def test_template_limit self for in range 10 self client get reverse i

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
def test_template_limit(self):
for i in range(10):
self.client.get(reverse('index'))
self.client.get(reverse('requests'))
requests = HttpRequest.objects.all()
self.assertEqual(requests.count(), 20)
response = self.client.get(reverse('requests'))
self.assertEqual(response.context['list'].count(), 10)
req = HttpRequest.objects.order_by('date_time')[:10]
for i in range(10):
self.assertEqual(response.context['list'].values_list('id', flat=True)[i],
req.values_list('id', flat=True)[i])