Mercurial > p > roundup > code
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 6317:ea0becc9fdb9 | 6318:ec853cef2f09 |
|---|---|
| 3275 self.assertEqual(self.dummy_client.response_code, 200) | 3275 self.assertEqual(self.dummy_client.response_code, 200) |
| 3276 | 3276 |
| 3277 # verify the result | 3277 # verify the result |
| 3278 self.assertTrue(not self.db.issue.is_retired(issue_id)) | 3278 self.assertTrue(not self.db.issue.is_retired(issue_id)) |
| 3279 | 3279 |
| 3280 def testPatchBadAction(self): | |
| 3281 """ | |
| 3282 Test Patch Action 'Unknown' | |
| 3283 """ | |
| 3284 # create a new issue with userid 1 and 2 in the nosy list | |
| 3285 issue_id = self.db.issue.create(title='foo') | |
| 3286 | |
| 3287 # execute action retire | |
| 3288 form = cgi.FieldStorage() | |
| 3289 etag = calculate_etag(self.db.issue.getnode(issue_id), | |
| 3290 self.db.config['WEB_SECRET_KEY']) | |
| 3291 form.list = [ | |
| 3292 cgi.MiniFieldStorage('@op', 'action'), | |
| 3293 cgi.MiniFieldStorage('@action_name', 'unknown'), | |
| 3294 cgi.MiniFieldStorage('@etag', etag) | |
| 3295 ] | |
| 3296 results = self.server.patch_element('issue', issue_id, form) | |
| 3297 self.assertEqual(self.dummy_client.response_code, 400) | |
| 3298 # verify the result, note order of allowed elements changes | |
| 3299 # for python2/3 so just check prefix. | |
| 3300 self.assertIn('action "unknown" is not supported, allowed: ', | |
| 3301 results['error']['msg'].args[0]) | |
| 3302 | |
| 3280 def testPatchRemove(self): | 3303 def testPatchRemove(self): |
| 3281 """ | 3304 """ |
| 3282 Test Patch Action 'Remove' only some element from a list | 3305 Test Patch Action 'Remove' only some element from a list |
| 3283 """ | 3306 """ |
| 3284 # create a new issue with userid 1, 2, 3 in the nosy list | 3307 # create a new issue with userid 1, 2, 3 in the nosy list |
