Skip to content

Commit f071de4

Browse files
committed
Add another test case: change protected attribute using patch_attribute.
1 parent 0180c32 commit f071de4

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/rest_common.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,6 +1472,28 @@ def testPatchReplace(self):
14721472
str(expected['error']['msg']))
14731473
self.assertEqual(self.dummy_client.response_code, 400)
14741474

1475+
# try to set a protected prop using patch_attribute. It should
1476+
# fail with a 405 bad/unsupported method.
1477+
etag = calculate_etag(self.db.issue.getnode(issue_id))
1478+
form = cgi.FieldStorage()
1479+
form.list = [
1480+
cgi.MiniFieldStorage('@op', 'replace'),
1481+
cgi.MiniFieldStorage('data', '2'),
1482+
cgi.MiniFieldStorage('@etag', etag)
1483+
]
1484+
results = self.server.patch_attribute('issue', issue_id, 'creator',
1485+
form)
1486+
expected= {'error': {'status': 405,
1487+
'msg': AttributeError("Attribute 'creator' can not be updated for class issue.",)}}
1488+
print(results)
1489+
self.assertEqual(results['error']['status'],
1490+
expected['error']['status'])
1491+
self.assertEqual(type(results['error']['msg']),
1492+
type(expected['error']['msg']))
1493+
self.assertEqual(str(results['error']['msg']),
1494+
str(expected['error']['msg']))
1495+
self.assertEqual(self.dummy_client.response_code, 405)
1496+
14751497
def testPatchRemoveAll(self):
14761498
"""
14771499
Test Patch Action 'Remove'

0 commit comments

Comments
 (0)