Commit 39e0eb5c authored by Romain Courteaud's avatar Romain Courteaud

slapos_json_rpc_api: tests

parent 9f40b63a
......@@ -811,28 +811,67 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSJsonRpcMixin):
def test_InstanceAccess_15_softwareInstanceError(self):
self._makeComplexComputeNode(self.project)
instance = self.start_requested_software_instance
self.login(instance.getUserId())
error_log = 'The error'
self.callInstancePutToApiAndCheck({
"reference": instance.getReference(),
"portal_type": "Software Instance",
"reported_state": "error",
"status_message": error_log,
})
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": "error",
"status_message": error_log,
},
instance.getUserId()
)
self.assertEqual('application/json', response.headers.get('content-type'))
self.assertEqual(
byteify(json.loads(response.getBody())),
{
'reference': instance.getReference(),
'date': '2020-05-19T00:00:00+00:00',
'portal_type': 'Software Instance',
'success': 'Done'
})
self.assertEqual(response.getStatus(), 200)
# Check Data is correct
partition = instance.getAggregateValue(portal_type="Compute Partition")
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 while instanciating: %s" % error_log
)
},
instance.getUserId())
self.assertEqual('application/json', response.headers.get('content-type'))
self.assertEqual({
#"$schema": instance.getJSONSchemaUrl(),
"title": instance.getTitle(),
"reference": instance.getReference(),
"software_release_uri": instance.getUrlString(),
"software_type": instance.getSourceReference(),
"state": self.getAPIStateFromSlapState(instance.getSlapState()),
"connection_parameters": instance.getConnectionXmlAsDict(),
"parameters": instance.getInstanceXmlAsDict(),
"shared": False,
"root_instance_title": instance.getSpecialiseValue().getTitle(),
"ip_list":
[
[
x.getNetworkInterface(''),
x.getIpAddress()
] for x in partition.contentValues(portal_type='Internet Protocol Address')
],
"full_ip_list": [],
"sla_parameters": instance.getSlaXmlAsDict(),
"compute_node_id": partition.getParentValue().getReference(),
"compute_partition_id": partition.getReference(),
"processing_timestamp": instance.getSlapTimestamp(),
"access_status_message": '#error while instanciating: The error',
#"api_revision": instance.getJIOAPIRevision(self.web_site.api.getRelativeUrl()),
"portal_type": instance.getPortalType(),
}, byteify(json.loads(response.getBody())))
self.assertEqual(response.getStatus(), 200)
def test_InstanceAccess_16_softwareInstanceError_twice(self):
self._makeComplexComputeNode(self.project)
......
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