@@ -786,6 +786,24 @@ def test_api_request_endpoint_edit_serialized_data(self):
786786 expected = {"serialized_data" : ['"Organization" is required.' ]}
787787 self .assertEqual (expected , response .data )
788788
789+ def test_api_request_endpoint_add_comment_action (self ):
790+ self .client .login (username = "super_user" , password = "secret" )
791+ add_comment_url = reverse ("api_v2:request-add-comment" , args = [self .request1 .uuid ])
792+
793+ data = {}
794+ response = self .client .post (add_comment_url , data = data )
795+ self .assertEqual (status .HTTP_400_BAD_REQUEST , response .status_code )
796+ expected = {
797+ "text" : ["This field is required." ],
798+ }
799+ self .assertEqual (expected , response .json ())
800+
801+ data = {"text" : "Comment content." }
802+ response = self .client .post (add_comment_url , data = data )
803+ self .assertEqual (status .HTTP_201_CREATED , response .status_code )
804+ expected = {"status" : "Comment added." }
805+ self .assertEqual (expected , response .data )
806+
789807 def test_api_request_and_request_template_endpoints_tab_permission (self ):
790808 self .assertEqual ((TabPermission ,), RequestViewSet .extra_permissions )
791809 self .assertEqual ((TabPermission ,), RequestTemplateViewSet .extra_permissions )
0 commit comments