Commit 0f5173d3 authored by Andreas Burbach's avatar Andreas Burbach
Browse files

add test

parent 416caa89
Pipeline #76036 passed with stages
in 3 minutes and 58 seconds
......@@ -615,6 +615,29 @@ class TestGetStatementFeed(APITestCase):
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("created") > result[2].get("created"))
def test_feed_contains_correct_data_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=5")
result = response.data["data"]
result_total = response.data["total"]
self.assertTrue(len(result), 3)
self.assertTrue(result_total, 3)
self.assertEqual(result[0].get("id"), self.statement_3.id)
self.assertEqual(result[1].get("id"), self.statement_2.id)
self.assertEqual(result[2].get("id"), self.statement_1.id)
self.assertTrue(result[0].get("id") > result[1].get("id"))
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("created") > result[2].get("created"))
def test_feed_contains_no_data_pagination(self):
self.client.credentials(HTTP_AUTHORIZATION='Token ' + str(self.token_beate))
response: Response = self.client.get(path="/contents/statements/feed/pagination/?page=2&size=2")
result = response.data["data"]
result_total = response.data["total"]
self.assertTrue(len(result), 0)
self.assertTrue(result_total, 3)
class TestTrendingHashtag(APITestCase):
......
......@@ -6,6 +6,6 @@ urlpatterns = [
path('statements/get/<int:id>/', ShowStatement.as_view(), name="show_statement"),
path('statements/with/hashtag/', ShowStatementsWithHashtag.as_view(), name="show_statement_with_hashtag"),
path('statements/feed/', ShowStatementFeed.as_view(), name="show_statement_feed"),
path('statements/feed/pagination', ShowStatementFeedPagination.as_view(), name="show_statement_feed_pagination"),
path('statements/feed/pagination/', ShowStatementFeedPagination.as_view(), name="show_statement_feed_pagination"),
path('trending/hashtag/', ShowTrendingHashtag.as_view(), name="show_trending_hashtags"),
]
\ No newline at end of file
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