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
         # folder subcontent modification does not change folder order
330
         # folder subcontent modification does not change folder order
331
         assert res[6]['content_id'] == main_folder.content_id
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
     def test_api__get_read_status__ok__200__nominal_case(self):
333
     def test_api__get_read_status__ok__200__nominal_case(self):
335
 
334
 
336
         # init DB
335
         # init DB
402
             firstly_created.content_id,
401
             firstly_created.content_id,
403
             main_folder.content_id,
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
         res = self.testapp.get(
411
         res = self.testapp.get(
416
-            '/api/v2/users/1/workspaces/{}/contents/read_status'.format(workspace.workspace_id),  # nopep8
412
+            url=url,
417
             status=200,
413
             status=200,
418
-            params=params
419
         )
414
         )
420
         res = res.json_body
415
         res = res.json_body
421
         assert len(res) == 4
416
         assert len(res) == 4
424
             assert isinstance(elem['read_by_user'], bool)
419
             assert isinstance(elem['read_by_user'], bool)
425
         # comment is newest than page2
420
         # comment is newest than page2
426
         assert res[0]['content_id'] == firstly_created_but_recently_commented.content_id
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
         # last updated content is newer than other one despite creation
422
         # last updated content is newer than other one despite creation
429
         # of the other is more recent
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
         # creation order is inverted here as last created is last active
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
         # folder subcontent modification does not change folder order
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
 class TestUserSetContentAsRead(FunctionalTest):
431
 class TestUserSetContentAsRead(FunctionalTest):

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

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