added object count to my_products
This commit is contained in:
@@ -947,7 +947,8 @@ class MyProductsViewTest(APITestCase):
|
||||
|
||||
# Assert forbidden code
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
self.assertEquals(len(user_instances), len(payload))
|
||||
self.assertEquals(payload['count'], len(payload['results']))
|
||||
self.assertEquals(len(user_instances), payload['count'])
|
||||
|
||||
def test_auth_user_can_paginate_instances(self):
|
||||
"""authenticated user can paginate instances
|
||||
@@ -967,7 +968,8 @@ class MyProductsViewTest(APITestCase):
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
# assert only 2 instances in response
|
||||
payload = response.json()
|
||||
self.assertEquals(2, len(payload))
|
||||
self.assertEquals(payload['count'], len(payload['results']))
|
||||
self.assertEquals(2, payload['count'])
|
||||
|
||||
def test_anon_user_cannot_access(self):
|
||||
# send in request
|
||||
|
||||
@@ -68,7 +68,11 @@ def my_products(request):
|
||||
elif limit is not None:
|
||||
limit = int(limit)
|
||||
data = data[:limit]
|
||||
return Response(data=data)
|
||||
# prepare response payload
|
||||
payload = {}
|
||||
payload['results'] = data
|
||||
payload['count'] = len(payload['results'])
|
||||
return Response(data=payload)
|
||||
|
||||
|
||||
@api_view(['POST',])
|
||||
|
||||
Reference in New Issue
Block a user