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,7 +807,7 @@ class TestWorkspaceContents(FunctionalTest):
807 807
         res = self.testapp.put_json(
808 808
             '/api/v2/workspaces/2/contents/8/move',
809 809
             params=params,
810
-            status=200
810
+            status=204
811 811
         )
812 812
         new_folder1_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder1, status=200).json_body  # nopep8
813 813
         new_folder2_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder2, status=200).json_body  # nopep8
@@ -846,7 +846,7 @@ class TestWorkspaceContents(FunctionalTest):
846 846
         res = self.testapp.put_json(
847 847
             # INFO - G.M - 2018-06-163 - delete Apple_Pie
848 848
             '/api/v2/workspaces/2/contents/8/delete',
849
-            status=200
849
+            status=204
850 850
         )
851 851
         new_active_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_active, status=200).json_body  # nopep8
852 852
         new_deleted_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_deleted, status=200).json_body  # nopep8
@@ -883,7 +883,7 @@ class TestWorkspaceContents(FunctionalTest):
883 883
         assert not [content for content in archived_contents if content['content_id'] == 8]  # nopep8
884 884
         res = self.testapp.put_json(
885 885
             '/api/v2/workspaces/2/contents/8/archive',
886
-            status=200
886
+            status=204
887 887
         )
888 888
         new_active_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_active, status=200).json_body  # nopep8
889 889
         new_archived_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_archived, status=200).json_body  # nopep8
@@ -920,7 +920,7 @@ class TestWorkspaceContents(FunctionalTest):
920 920
         assert [content for content in deleted_contents if content['content_id'] == 14]  # nopep8
921 921
         res = self.testapp.put_json(
922 922
             '/api/v2/workspaces/2/contents/14/undelete',
923
-            status=200
923
+            status=204
924 924
         )
925 925
         new_active_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_active, status=200).json_body  # nopep8
926 926
         new_deleted_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_deleted, status=200).json_body  # nopep8
@@ -957,7 +957,7 @@ class TestWorkspaceContents(FunctionalTest):
957 957
         assert [content for content in archived_contents if content['content_id'] == 13]  # nopep8
958 958
         res = self.testapp.put_json(
959 959
             '/api/v2/workspaces/2/contents/13/unarchive',
960
-            status=200
960
+            status=204
961 961
         )
962 962
         new_active_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_active, status=200).json_body  # nopep8
963 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,7 +159,7 @@ class WorkspaceController(Controller):
159 159
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
160 160
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
161 161
     @hapic.input_body(ContentMoveSchema())
162
-    @hapic.output_body(NoContentSchema())
162
+    @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
163 163
     def move_content(
164 164
             self,
165 165
             context,
@@ -198,7 +198,7 @@ class WorkspaceController(Controller):
198 198
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
199 199
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
200 200
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
201
-    @hapic.output_body(NoContentSchema())
201
+    @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
202 202
     def delete_content(
203 203
             self,
204 204
             context,
@@ -233,7 +233,7 @@ class WorkspaceController(Controller):
233 233
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
234 234
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
235 235
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
236
-    @hapic.output_body(NoContentSchema())
236
+    @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
237 237
     def undelete_content(
238 238
             self,
239 239
             context,
@@ -269,7 +269,7 @@ class WorkspaceController(Controller):
269 269
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
270 270
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
271 271
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
272
-    @hapic.output_body(NoContentSchema())
272
+    @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
273 273
     def archive_content(
274 274
             self,
275 275
             context,
@@ -301,7 +301,7 @@ class WorkspaceController(Controller):
301 301
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
302 302
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
303 303
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
304
-    @hapic.output_body(NoContentSchema())
304
+    @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
305 305
     def unarchive_content(
306 306
             self,
307 307
             context,