diff test/rest_common.py @ 6318:ec853cef2f09

Add test for invaild action in rest.py patch_element.
author John Rouillard <rouilj@ieee.org>
date Fri, 01 Jan 2021 23:58:50 -0500
parents ea0becc9fdb9
children 6a69584d117e
line wrap: on
line diff
--- a/test/rest_common.py	Fri Jan 01 23:37:38 2021 -0500
+++ b/test/rest_common.py	Fri Jan 01 23:58:50 2021 -0500
@@ -3277,6 +3277,29 @@
         # verify the result
         self.assertTrue(not self.db.issue.is_retired(issue_id))
 
+    def testPatchBadAction(self):
+        """
+        Test Patch Action 'Unknown'
+        """
+        # create a new issue with userid 1 and 2 in the nosy list
+        issue_id = self.db.issue.create(title='foo')
+
+        # execute action retire
+        form = cgi.FieldStorage()
+        etag = calculate_etag(self.db.issue.getnode(issue_id),
+                              self.db.config['WEB_SECRET_KEY'])
+        form.list = [
+            cgi.MiniFieldStorage('@op', 'action'),
+            cgi.MiniFieldStorage('@action_name', 'unknown'),
+            cgi.MiniFieldStorage('@etag', etag)
+        ]
+        results = self.server.patch_element('issue', issue_id, form)
+        self.assertEqual(self.dummy_client.response_code, 400)
+        # verify the result, note order of allowed elements changes
+        # for python2/3 so just check prefix.
+        self.assertIn('action "unknown" is not supported, allowed: ',
+                       results['error']['msg'].args[0])
+
     def testPatchRemove(self):
         """
         Test Patch Action 'Remove' only some element from a list

Roundup Issue Tracker: http://roundup-tracker.org/