Browse Source

fix query param as list + test related

Guénaël Muller 6 years ago
parent
commit
e39605245e
2 changed files with 11 additions and 20 deletions
  1. 10 18
      tracim/tests/functional/test_user.py
  2. 1 2
      tracim/views/core_api/user_controller.py

+ 10 - 18
tracim/tests/functional/test_user.py View File

@@ -330,7 +330,6 @@ class TestUserReadStatusEndpoint(FunctionalTest):
330 330
         # folder subcontent modification does not change folder order
331 331
         assert res[6]['content_id'] == main_folder.content_id
332 332
 
333
-    @pytest.mark.xfail(reason='List of item in path bug need to be fixed')
334 333
     def test_api__get_read_status__ok__200__nominal_case(self):
335 334
 
336 335
         # init DB
@@ -402,20 +401,16 @@ class TestUserReadStatusEndpoint(FunctionalTest):
402 401
             firstly_created.content_id,
403 402
             main_folder.content_id,
404 403
         ]
405
-
406
-        content_id_str = '[{0},{1},{2},{3}]'.format(
407
-            selected_contents_id[0],
408
-            selected_contents_id[1],
409
-            selected_contents_id[2],
410
-            selected_contents_id[3],
404
+        url = '/api/v2/users/1/workspaces/{workspace_id}/contents/read_status?contents_ids={cid1}&contents_ids={cid2}&contents_ids={cid3}&contents_ids={cid4}'.format(  # nopep8
405
+              workspace_id=workspace.workspace_id,
406
+              cid1=selected_contents_id[0],
407
+              cid2=selected_contents_id[1],
408
+              cid3=selected_contents_id[2],
409
+              cid4=selected_contents_id[3],
411 410
         )
412
-        params = {
413
-            'contents_ids': content_id_str
414
-        }
415 411
         res = self.testapp.get(
416
-            '/api/v2/users/1/workspaces/{}/contents/read_status'.format(workspace.workspace_id),  # nopep8
412
+            url=url,
417 413
             status=200,
418
-            params=params
419 414
         )
420 415
         res = res.json_body
421 416
         assert len(res) == 4
@@ -424,16 +419,13 @@ class TestUserReadStatusEndpoint(FunctionalTest):
424 419
             assert isinstance(elem['read_by_user'], bool)
425 420
         # comment is newest than page2
426 421
         assert res[0]['content_id'] == firstly_created_but_recently_commented.content_id
427
-        assert res[1]['content_id'] == secondly_created_but_not_commented.content_id
428 422
         # last updated content is newer than other one despite creation
429 423
         # of the other is more recent
430
-        assert res[2]['content_id'] == firstly_created_but_recently_updated.content_id
431
-        assert res[3]['content_id'] == secondly_created_but_not_updated.content_id
424
+        assert res[1]['content_id'] == firstly_created_but_recently_updated.content_id
432 425
         # creation order is inverted here as last created is last active
433
-        assert res[4]['content_id'] == secondly_created.content_id
434
-        assert res[5]['content_id'] == firstly_created.content_id
426
+        assert res[2]['content_id'] == firstly_created.content_id
435 427
         # folder subcontent modification does not change folder order
436
-        assert res[6]['content_id'] == main_folder.content_id
428
+        assert res[3]['content_id'] == main_folder.content_id
437 429
 
438 430
 
439 431
 class TestUserSetContentAsRead(FunctionalTest):

+ 1 - 2
tracim/views/core_api/user_controller.py View File

@@ -86,7 +86,7 @@ class UserController(Controller):
86 86
     @hapic.with_api_doc(tags=[USER_ENDPOINTS_TAG])
87 87
     @require_same_user_or_profile(Group.TIM_ADMIN)
88 88
     @hapic.input_path(UserWorkspaceIdPathSchema())
89
-    @hapic.input_query(ContentIdsQuerySchema())
89
+    @hapic.input_query(ContentIdsQuerySchema(), as_list=['contents_ids'])
90 90
     @hapic.output_body(ReadStatusSchema(many=True))  # nopep8
91 91
     def contents_read_status(self, context, request: TracimRequest, hapic_data=None):  # nopep8
92 92
         """
@@ -118,7 +118,6 @@ class UserController(Controller):
118 118
             for content in last_actives
119 119
         ]
120 120
 
121
-
122 121
     @hapic.with_api_doc(tags=[USER_ENDPOINTS_TAG])
123 122
     @require_same_user_or_profile(Group.TIM_ADMIN)
124 123
     @hapic.input_path(UserWorkspaceAndContentIdPathSchema())