Browse Source

204 no content http status for content action

Guénaël Muller 6 years ago
parent
commit
7864e47945

+ 5 - 5
tracim/tests/functional/test_workspaces.py View File

807
         res = self.testapp.put_json(
807
         res = self.testapp.put_json(
808
             '/api/v2/workspaces/2/contents/8/move',
808
             '/api/v2/workspaces/2/contents/8/move',
809
             params=params,
809
             params=params,
810
-            status=200
810
+            status=204
811
         )
811
         )
812
         new_folder1_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder1, status=200).json_body  # nopep8
812
         new_folder1_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder1, status=200).json_body  # nopep8
813
         new_folder2_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder2, status=200).json_body  # nopep8
813
         new_folder2_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder2, status=200).json_body  # nopep8
846
         res = self.testapp.put_json(
846
         res = self.testapp.put_json(
847
             # INFO - G.M - 2018-06-163 - delete Apple_Pie
847
             # INFO - G.M - 2018-06-163 - delete Apple_Pie
848
             '/api/v2/workspaces/2/contents/8/delete',
848
             '/api/v2/workspaces/2/contents/8/delete',
849
-            status=200
849
+            status=204
850
         )
850
         )
851
         new_active_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_active, status=200).json_body  # nopep8
851
         new_active_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_active, status=200).json_body  # nopep8
852
         new_deleted_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_deleted, status=200).json_body  # nopep8
852
         new_deleted_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_deleted, status=200).json_body  # nopep8
883
         assert not [content for content in archived_contents if content['content_id'] == 8]  # nopep8
883
         assert not [content for content in archived_contents if content['content_id'] == 8]  # nopep8
884
         res = self.testapp.put_json(
884
         res = self.testapp.put_json(
885
             '/api/v2/workspaces/2/contents/8/archive',
885
             '/api/v2/workspaces/2/contents/8/archive',
886
-            status=200
886
+            status=204
887
         )
887
         )
888
         new_active_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_active, status=200).json_body  # nopep8
888
         new_active_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_active, status=200).json_body  # nopep8
889
         new_archived_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_archived, status=200).json_body  # nopep8
889
         new_archived_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_archived, status=200).json_body  # nopep8
920
         assert [content for content in deleted_contents if content['content_id'] == 14]  # nopep8
920
         assert [content for content in deleted_contents if content['content_id'] == 14]  # nopep8
921
         res = self.testapp.put_json(
921
         res = self.testapp.put_json(
922
             '/api/v2/workspaces/2/contents/14/undelete',
922
             '/api/v2/workspaces/2/contents/14/undelete',
923
-            status=200
923
+            status=204
924
         )
924
         )
925
         new_active_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_active, status=200).json_body  # nopep8
925
         new_active_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_active, status=200).json_body  # nopep8
926
         new_deleted_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_deleted, status=200).json_body  # nopep8
926
         new_deleted_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_deleted, status=200).json_body  # nopep8
957
         assert [content for content in archived_contents if content['content_id'] == 13]  # nopep8
957
         assert [content for content in archived_contents if content['content_id'] == 13]  # nopep8
958
         res = self.testapp.put_json(
958
         res = self.testapp.put_json(
959
             '/api/v2/workspaces/2/contents/13/unarchive',
959
             '/api/v2/workspaces/2/contents/13/unarchive',
960
-            status=200
960
+            status=204
961
         )
961
         )
962
         new_active_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_active, status=200).json_body  # nopep8
962
         new_active_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_active, status=200).json_body  # nopep8
963
         new_archived_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_archived, status=200).json_body  # nopep8
963
         new_archived_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_archived, status=200).json_body  # nopep8

+ 5 - 5
tracim/views/core_api/workspace_controller.py View File

159
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
159
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
160
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
160
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
161
     @hapic.input_body(ContentMoveSchema())
161
     @hapic.input_body(ContentMoveSchema())
162
-    @hapic.output_body(NoContentSchema())
162
+    @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
163
     def move_content(
163
     def move_content(
164
             self,
164
             self,
165
             context,
165
             context,
198
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
198
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
199
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
199
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
200
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
200
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
201
-    @hapic.output_body(NoContentSchema())
201
+    @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
202
     def delete_content(
202
     def delete_content(
203
             self,
203
             self,
204
             context,
204
             context,
233
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
233
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
234
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
234
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
235
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
235
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
236
-    @hapic.output_body(NoContentSchema())
236
+    @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
237
     def undelete_content(
237
     def undelete_content(
238
             self,
238
             self,
239
             context,
239
             context,
269
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
269
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
270
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
270
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
271
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
271
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
272
-    @hapic.output_body(NoContentSchema())
272
+    @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
273
     def archive_content(
273
     def archive_content(
274
             self,
274
             self,
275
             context,
275
             context,
301
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
301
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
302
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
302
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
303
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
303
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
304
-    @hapic.output_body(NoContentSchema())
304
+    @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
305
     def unarchive_content(
305
     def unarchive_content(
306
             self,
306
             self,
307
             context,
307
             context,