Commit ca3a78e0 authored by Romain Courteaud's avatar Romain Courteaud 🐙

slapos_json_rpc_api: update test

parent 88a80d68
......@@ -1337,43 +1337,69 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSJsonRpcMixin):
def test_PersonAccess_32_softwareInstanceBang(self):
self._makeComplexComputeNode(self.project, person=self.person)
self.called_instance_bang = ""
def calledBanged(*args, **kw):
self.called_instance_bang = kw
instance = self.start_requested_software_instance
error_log = 'Please bang me'
try:
bang = instance.__class__.bang
instance.__class__.bang = calledBanged
self.login(self.person_user_id)
error_log = 'Please bang me'
self.callInstancePutToApiAndCheck({
error_log = 'Please force slapos instance rerun'
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",
"reported_state": "bang",
"status_message": error_log,
})
self.assertEqual(
self.called_instance_bang,
{'bang_tree': True, 'comment': 'Please bang me'}
"status_message": error_log
},
self.person_user_id
)
finally:
instance.__class__.bang = bang
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, error_log)
action_id = portal_workflow.getInfoFor(ob=instance,
name='action',
wf_id='instance_slap_interface_workflow')
self.assertEqual(action_id, 'bang')
response = self.callJsonRpcWebService("slapos.get.slapos_jio_api_get_software_instance", {
# Check get return the expected results after
response = self.callJsonRpcWebService(
"slapos.get.slapos_jio_api_get_software_instance",
{
"portal_type": "Software Instance",
"reference": instance.getReference(),
})
instance_dict = json.loads(response.getBody())
if 200 != response.getStatus():
raise ValueError("Unexpected Result %s" % instance_dict)
self.assertEqual('application/json',
response.headers.get('content-type'))
self.assertEqual(
instance_dict["access_status_message"],
"#error bang called"
},
self.person_user_id
)
self.assertEqual('application/json', response.headers.get('content-type'))
partition = instance.getAggregateValue(portal_type="Compute Partition")
self.assertEqual({
'access_status_message': '#error bang called',
"compute_node_id": partition.getParentValue().getReference(),
"compute_partition_id": partition.getReference(),
'full_ip_list': [],
'ip_list': [['', 'ip_address_1']],
'portal_type': 'Software Instance',
'processing_timestamp': 1589846400000000,
'reference': instance.getReference(),
'root_instance_title': instance.getSpecialiseTitle(),
'shared': False,
"sla_parameters": instance.getSlaXmlAsDict(),
"parameters": instance.getInstanceXmlAsDict(),
"connection_parameters": instance.getConnectionXmlAsDict(),
'software_release_uri': instance.getUrlString(),
'software_type': instance.getSourceReference(),
'state': 'started',
'title': instance.getTitle()
}, byteify(json.loads(response.getBody())))
self.assertEqual(response.getStatus(), 200)
def test_PersonAccess_33_softwareInstanceRename(self):
self._makeComplexComputeNode(self.project, person=self.person)
......
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