Commit 2a8c31c4 authored by Romain Courteaud's avatar Romain Courteaud

slapos_json_rpc_api: test

parent 50f4796c
......@@ -1403,34 +1403,38 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSJsonRpcMixin):
def test_PersonAccess_33_softwareInstanceRename(self):
self._makeComplexComputeNode(self.project, person=self.person)
new_name = 'new me'
self.called_instance_rename = ""
def calledRename(*args, **kw):
self.called_instance_rename = kw
instance = self.start_requested_software_instance
try:
rename = instance.__class__.rename
instance.__class__.rename = calledRename
self.login(self.person_user_id)
self.callInstancePutToApiAndCheck({
previous_name = instance.getTitle()
new_name = 'new me'
with PinnedDateTime(self, DateTime('2020/05/19')):
response = self.callJsonRpcWebService(
"slapos.put.slapos_jio_api_put_software_instance",
{
"reference": instance.getReference(),
"portal_type": "Software Instance",
"title": new_name,
})
self.assertEqual(self.called_instance_rename,
{
'comment': 'Rename %s into %s' % (
instance.getTitle(),
new_name
),
'new_name': new_name
}
},
self.person_user_id
)
finally:
instance.__class__.rename = rename
self.assertEqual('application/json', response.headers.get('content-type'))
self.assertEqual({
'reference': instance.getReference(),
'date': '2020-05-19T00:00:00+00:00',
'portal_type': 'Software Instance',
'success': 'Done'
}, byteify(json.loads(response.getBody())))
self.assertEqual(response.getStatus(), 200)
portal_workflow = self.portal.portal_workflow
comment = portal_workflow.getInfoFor(ob=instance,
name='comment',
wf_id='instance_slap_interface_workflow')
self.assertEqual(comment, 'Rename %s into %s' % (previous_name, new_name))
action_id = portal_workflow.getInfoFor(ob=instance,
name='action',
wf_id='instance_slap_interface_workflow')
self.assertEqual(action_id, 'rename')
self.assertEqual(instance.getTitle(), new_name)
def test_PersonAccess_34_request_withSlave(self):
self.called_instance_request = ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment