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

slapos_json_rpc_api: test

parent 50f4796c
...@@ -1403,34 +1403,38 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSJsonRpcMixin): ...@@ -1403,34 +1403,38 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSJsonRpcMixin):
def test_PersonAccess_33_softwareInstanceRename(self): def test_PersonAccess_33_softwareInstanceRename(self):
self._makeComplexComputeNode(self.project, person=self.person) 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 instance = self.start_requested_software_instance
try:
rename = instance.__class__.rename previous_name = instance.getTitle()
instance.__class__.rename = calledRename new_name = 'new me'
self.login(self.person_user_id) with PinnedDateTime(self, DateTime('2020/05/19')):
self.callInstancePutToApiAndCheck({ response = self.callJsonRpcWebService(
"reference": instance.getReference(), "slapos.put.slapos_jio_api_put_software_instance",
"portal_type": "Software Instance",
"title": new_name,
})
self.assertEqual(self.called_instance_rename,
{ {
'comment': 'Rename %s into %s' % ( "reference": instance.getReference(),
instance.getTitle(), "portal_type": "Software Instance",
new_name "title": new_name,
), },
'new_name': new_name self.person_user_id
}
) )
self.assertEqual('application/json', response.headers.get('content-type'))
finally: self.assertEqual({
instance.__class__.rename = rename '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): def test_PersonAccess_34_request_withSlave(self):
self.called_instance_request = "" 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