Commit eb11b3c1 authored by Andreas Burbach's avatar Andreas Burbach
Browse files

add more tests

parent 0f5173d3
Pipeline #76048 passed with stages
in 1 minute and 1 second
...@@ -618,7 +618,7 @@ class TestGetStatementFeed(APITestCase): ...@@ -618,7 +618,7 @@ class TestGetStatementFeed(APITestCase):
def test_feed_contains_correct_data_pagination(self): def test_feed_contains_correct_data_pagination(self):
self.client.credentials(HTTP_AUTHORIZATION='Token ' + str(self.token_beate)) self.client.credentials(HTTP_AUTHORIZATION='Token ' + str(self.token_beate))
response: Response = self.client.get(path="/contents/statements/feed/pagination/?page=1&size=5") response: Response = self.client.get(path="/contents/statements/feed/pagination/?page=1&size=3")
result = response.data["data"] result = response.data["data"]
result_total = response.data["total"] result_total = response.data["total"]
self.assertTrue(len(result), 3) self.assertTrue(len(result), 3)
...@@ -630,6 +630,22 @@ class TestGetStatementFeed(APITestCase): ...@@ -630,6 +630,22 @@ class TestGetStatementFeed(APITestCase):
self.assertTrue(result[0].get("created") > result[1].get("created")) self.assertTrue(result[0].get("created") > result[1].get("created"))
self.assertTrue(result[1].get("id") > result[2].get("id")) self.assertTrue(result[1].get("id") > result[2].get("id"))
self.assertTrue(result[1].get("created") > result[2].get("created")) self.assertTrue(result[1].get("created") > result[2].get("created"))
def test_feed_load_over_size_pagination(self):
self.client.credentials(HTTP_AUTHORIZATION='Token ' + str(self.token_beate))
response: Response = self.client.get(path="/contents/statements/feed/pagination/?page=1&size=4")
result = response.data["data"]
result_total = response.data["total"]
self.assertTrue(len(result), 3)
self.assertTrue(result_total, 3)
def test_feed_load_under_size_pagination(self):
self.client.credentials(HTTP_AUTHORIZATION='Token ' + str(self.token_beate))
response: Response = self.client.get(path="/contents/statements/feed/pagination/?page=1&size=2")
result = response.data["data"]
result_total = response.data["total"]
self.assertTrue(len(result), 2)
self.assertTrue(result_total, 3)
def test_feed_contains_no_data_pagination(self): def test_feed_contains_no_data_pagination(self):
self.client.credentials(HTTP_AUTHORIZATION='Token ' + str(self.token_beate)) self.client.credentials(HTTP_AUTHORIZATION='Token ' + str(self.token_beate))
......
...@@ -127,7 +127,7 @@ class ShowStatementFeedPagination(APIView): ...@@ -127,7 +127,7 @@ class ShowStatementFeedPagination(APIView):
else: else:
if last >= total: if last >= total:
last = None last = None
feed = feed[first:last] feed = feed[first:last]
serializer: StatementSerializer = StatementSerializer(instance=feed, many=True) serializer: StatementSerializer = StatementSerializer(instance=feed, many=True)
return Response(status=status.HTTP_200_OK, data={"data": serializer.data, "total": total}) return Response(status=status.HTTP_200_OK, data={"data": serializer.data, "total": total})
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment