Browse Source

rename exception for empty comment content

Guénaël Muller 6 years ago
parent
commit
e1cf2dfbca

+ 1 - 1
tracim/exceptions.py View File

160
     pass
160
     pass
161
 
161
 
162
 
162
 
163
-class EmptyRawContentNotAllowed(EmptyValueNotAllowed):
163
+class EmptyCommentContentNotAllowed(EmptyValueNotAllowed):
164
     pass
164
     pass

+ 3 - 3
tracim/lib/core/content.py View File

24
 
24
 
25
 from tracim.lib.utils.utils import cmp_to_key
25
 from tracim.lib.utils.utils import cmp_to_key
26
 from tracim.lib.core.notifications import NotifierFactory
26
 from tracim.lib.core.notifications import NotifierFactory
27
-from tracim.exceptions import SameValueError, EmptyRawContentNotAllowed
27
+from tracim.exceptions import SameValueError
28
+from tracim.exceptions import EmptyCommentContentNotAllowed
28
 from tracim.exceptions import EmptyLabelNotAllowed
29
 from tracim.exceptions import EmptyLabelNotAllowed
29
 from tracim.exceptions import ContentNotFound
30
 from tracim.exceptions import ContentNotFound
30
 from tracim.exceptions import WorkspacesDoNotMatch
31
 from tracim.exceptions import WorkspacesDoNotMatch
437
     def create_comment(self, workspace: Workspace=None, parent: Content=None, content:str ='', do_save=False) -> Content:
438
     def create_comment(self, workspace: Workspace=None, parent: Content=None, content:str ='', do_save=False) -> Content:
438
         assert parent and parent.type != ContentType.Folder
439
         assert parent and parent.type != ContentType.Folder
439
         if not content:
440
         if not content:
440
-            raise EmptyRawContentNotAllowed()
441
+            raise EmptyCommentContentNotAllowed()
441
         item = Content()
442
         item = Content()
442
         item.owner = self._user
443
         item.owner = self._user
443
         item.parent = parent
444
         item.parent = parent
453
             self.save(item, ActionDescription.COMMENT)
454
             self.save(item, ActionDescription.COMMENT)
454
         return item
455
         return item
455
 
456
 
456
-
457
     def get_one_from_revision(self, content_id: int, content_type: str, workspace: Workspace=None, revision_id=None) -> Content:
457
     def get_one_from_revision(self, content_id: int, content_type: str, workspace: Workspace=None, revision_id=None) -> Content:
458
         """
458
         """
459
         This method is a hack to convert a node revision item into a node
459
         This method is a hack to convert a node revision item into a node

+ 1 - 0
tracim/tests/functional/test_comments.py View File

113
             params=params,
113
             params=params,
114
             status=400
114
             status=400
115
         )
115
         )
116
+
116
     def test_api__delete_content_comment__ok_200__user_is_owner_and_workspace_manager(self) -> None:  # nopep8
117
     def test_api__delete_content_comment__ok_200__user_is_owner_and_workspace_manager(self) -> None:  # nopep8
117
         """
118
         """
118
         delete comment (user is workspace_manager and owner)
119
         delete comment (user is workspace_manager and owner)

+ 2 - 5
tracim/views/contents_api/comment_controller.py View File

19
 from tracim.views.core_api.schemas import SetCommentSchema
19
 from tracim.views.core_api.schemas import SetCommentSchema
20
 from tracim.views.core_api.schemas import WorkspaceAndContentIdPathSchema
20
 from tracim.views.core_api.schemas import WorkspaceAndContentIdPathSchema
21
 from tracim.views.core_api.schemas import NoContentSchema
21
 from tracim.views.core_api.schemas import NoContentSchema
22
-from tracim.exceptions import WorkspaceNotFound, EmptyRawContentNotAllowed
23
-from tracim.exceptions import InsufficientUserRoleInWorkspace
24
-from tracim.exceptions import NotAuthenticated
25
-from tracim.exceptions import AuthenticationFailed
22
+from tracim.exceptions import EmptyCommentContentNotAllowed
26
 from tracim.models.contents import ContentTypeLegacy as ContentType
23
 from tracim.models.contents import ContentTypeLegacy as ContentType
27
 from tracim.models.revision_protection import new_revision
24
 from tracim.models.revision_protection import new_revision
28
 from tracim.models.data import UserRoleInWorkspace
25
 from tracim.models.data import UserRoleInWorkspace
59
         ]
56
         ]
60
 
57
 
61
     @hapic.with_api_doc(tags=[COMMENT_ENDPOINTS_TAG])
58
     @hapic.with_api_doc(tags=[COMMENT_ENDPOINTS_TAG])
62
-    @hapic.handle_exception(EmptyRawContentNotAllowed, HTTPStatus.BAD_REQUEST)
59
+    @hapic.handle_exception(EmptyCommentContentNotAllowed, HTTPStatus.BAD_REQUEST)  # nopep8
63
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
60
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
64
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
61
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
65
     @hapic.input_body(SetCommentSchema())
62
     @hapic.input_body(SetCommentSchema())