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

slapos_json_rpc_api: tests

parent 9f40b63a
...@@ -811,28 +811,67 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSJsonRpcMixin): ...@@ -811,28 +811,67 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSJsonRpcMixin):
def test_InstanceAccess_15_softwareInstanceError(self): def test_InstanceAccess_15_softwareInstanceError(self):
self._makeComplexComputeNode(self.project) self._makeComplexComputeNode(self.project)
instance = self.start_requested_software_instance instance = self.start_requested_software_instance
self.login(instance.getUserId())
error_log = 'The error' error_log = 'The error'
self.callInstancePutToApiAndCheck({ with PinnedDateTime(self, DateTime('2020/05/19')):
"reference": instance.getReference(), response = self.callJsonRpcWebService(
"portal_type": "Software Instance", "slapos.put.slapos_jio_api_put_software_instance",
"reported_state": "error", {
"status_message": error_log, "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", { response = self.callJsonRpcWebService("slapos.get.slapos_jio_api_get_software_instance", {
"portal_type": "Software Instance", "portal_type": "Software Instance",
"reference": instance.getReference(), "reference": instance.getReference(),
}) },
instance_dict = json.loads(response.getBody()) instance.getUserId())
if 200 != response.getStatus(): self.assertEqual('application/json', response.headers.get('content-type'))
raise ValueError("Unexpected Result %s" % instance_dict) self.assertEqual({
self.assertEqual('application/json', #"$schema": instance.getJSONSchemaUrl(),
response.headers.get('content-type')) "title": instance.getTitle(),
self.assertEqual( "reference": instance.getReference(),
instance_dict["access_status_message"], "software_release_uri": instance.getUrlString(),
"#error while instanciating: %s" % error_log "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): def test_InstanceAccess_16_softwareInstanceError_twice(self):
self._makeComplexComputeNode(self.project) 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