Commit f01094f3 authored by Romain Courteaud's avatar Romain Courteaud

Slaptool now uses updateConnection transition.

Each call will now be reported by the consumption API.
parent 07720848
......@@ -1006,6 +1006,14 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
self.assertEqual(expected_xml, got_xml,
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def assertInstanceUpdateConnectionSimulator(self, args, kwargs):
stored = eval(open(self.instance_update_connection_simulator).read())
# do the same translation magic as in workflow
kwargs['connection_xml'] = kwargs.pop('connection_xml')
self.assertEqual(stored,
[{'recargs': args, 'reckwargs': kwargs,
'recmethod': 'updateConnection'}])
def test_setConnectionXml_withSlave(self):
self._makeComplexComputer(with_slave=True)
partition_id = self.start_requested_software_instance.getAggregateValue(
......@@ -1019,13 +1027,26 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<string>v2</string>
</dictionary>
</marshal>"""
stored_xml = """<?xml version='1.0' encoding='utf-8'?>
<instance>
<parameter id="p2">v2</parameter>
<parameter id="p1">v1</parameter>
</instance>
"""
self.login(self.start_requested_software_instance.getReference())
response = self.portal_slap.setComputerPartitionConnectionXml(self.computer_id,
partition_id, connection_xml, slave_reference)
self.instance_update_connection_simulator = tempfile.mkstemp()[1]
try:
self.start_requested_slave_instance.updateConnection = Simulator(
self.instance_update_connection_simulator, 'updateConnection')
response = self.portal_slap.setComputerPartitionConnectionXml(
self.computer_id, partition_id, connection_xml, slave_reference)
self.assertEqual('None', response)
self.assertEqual({'p2': 'v2', 'p1': 'v1'},
self.start_requested_slave_instance.getConnectionXmlAsDict()
)
self.assertInstanceUpdateConnectionSimulator((),
{'connection_xml': stored_xml})
finally:
if os.path.exists(self.instance_update_connection_simulator):
os.unlink(self.instance_update_connection_simulator)
def test_setConnectionXml(self):
self._makeComplexComputer()
......@@ -1039,13 +1060,26 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<string>v2</string>
</dictionary>
</marshal>"""
stored_xml = """<?xml version='1.0' encoding='utf-8'?>
<instance>
<parameter id="p2">v2</parameter>
<parameter id="p1">v1</parameter>
</instance>
"""
self.login(self.start_requested_software_instance.getReference())
response = self.portal_slap.setComputerPartitionConnectionXml(self.computer_id,
partition_id, connection_xml)
self.instance_update_connection_simulator = tempfile.mkstemp()[1]
try:
self.start_requested_software_instance.updateConnection = Simulator(
self.instance_update_connection_simulator, 'updateConnection')
response = self.portal_slap.setComputerPartitionConnectionXml(
self.computer_id, partition_id, connection_xml)
self.assertEqual('None', response)
self.assertEqual({'p2': 'v2', 'p1': 'v1'},
self.start_requested_software_instance.getConnectionXmlAsDict()
)
self.assertInstanceUpdateConnectionSimulator((),
{'connection_xml': stored_xml})
finally:
if os.path.exists(self.instance_update_connection_simulator):
os.unlink(self.instance_update_connection_simulator)
def test_softwareInstanceError(self):
self._makeComplexComputer()
......
18
\ No newline at end of file
19
\ No newline at end of file
......@@ -1023,7 +1023,7 @@ class SlapTool(BaseTool):
xml_declaration=True, encoding='utf-8')
reference = software_instance.getReference()
if self._getLastData(reference) != connection_xml:
software_instance.edit(
software_instance.updateConnection(
connection_xml=connection_xml,
)
self._storeLastData(reference, connection_xml)
......
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