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

New transition to update the connection_xml.

parent a490a99a
...@@ -4,6 +4,7 @@ from Products.SlapOS.tests.testSlapOSMixin import \ ...@@ -4,6 +4,7 @@ from Products.SlapOS.tests.testSlapOSMixin import \
import transaction import transaction
from Products.ERP5Type.tests.backportUnittest import expectedFailure from Products.ERP5Type.tests.backportUnittest import expectedFailure
from Products.ERP5Type.Errors import UnsupportedWorkflowMethod from Products.ERP5Type.Errors import UnsupportedWorkflowMethod
from Products.DCWorkflow.DCWorkflow import ValidationFailed
from AccessControl.SecurityManagement import getSecurityManager, \ from AccessControl.SecurityManagement import getSecurityManager, \
setSecurityManager setSecurityManager
...@@ -1065,6 +1066,37 @@ class TestSlapOSCoreInstanceSlapInterfaceWorkflow(testSlapOSMixin): ...@@ -1065,6 +1066,37 @@ class TestSlapOSCoreInstanceSlapInterfaceWorkflow(testSlapOSMixin):
) )
transaction.abort() transaction.abort()
def test_updateConnection(self):
self.login(self.instance.getReference())
request_kw = self.request_kw.copy()
self.instance.requestStop(**request_kw)
connection_xml = self.generateSafeXml()
self.instance.updateConnection(connection_xml=connection_xml)
self.assertEquals(self.instance.getConnectionXml(), connection_xml)
transaction.abort()
def test_updateConnectionRequired(self):
self.login(self.instance.getReference())
request_kw = self.request_kw.copy()
self.instance.requestStop(**request_kw)
# No connection_xml
self.assertRaises(TypeError, self.instance.updateConnection)
transaction.abort()
def test_updateConnectionBrokenXml(self):
self.login(self.instance.getReference())
request_kw = self.request_kw.copy()
self.instance.requestStop(**request_kw)
# No connection_xml
self.assertRaises(ValidationFailed, self.instance.updateConnection,
connection_xml="<foo bar /<>")
transaction.abort()
class TestSlapOSCoreSoftwareInstanceRequest(testSlapOSMixin): class TestSlapOSCoreSoftwareInstanceRequest(testSlapOSMixin):
"""Tests instance.requestInstance""" """Tests instance.requestInstance"""
def afterSetUp(self): def afterSetUp(self):
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>instance = state_change[\'object\']\n
portal = instance.getPortalObject()\n
# Get required arguments\n
kwargs = state_change.kwargs\n
\n
# Required args\n
# Raise TypeError if all parameters are not provided\n
try:\n
connection_xml = state_change.kwargs[\'connection_xml\']\n
except KeyError:\n
raise TypeError, "RequestedInstance_updateConnectionInformation takes exactly 1 arguments"\n
\n
edit_kw = {\n
\'connection_xml\': connection_xml,\n
}\n
\n
instance.edit(**edit_kw)\n
# Prevent storing broken XML in text content (which prevent to update parameters after)\n
context.Instance_checkConsistency(state_change)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>RequestedInstance_updateConnectionInformation</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
<string>report_computer_partition_error</string> <string>report_computer_partition_error</string>
<string>request_instance</string> <string>request_instance</string>
<string>unallocate_partition</string> <string>unallocate_partition</string>
<string>update_connection</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
<string>request_instance</string> <string>request_instance</string>
<string>request_start</string> <string>request_start</string>
<string>request_stop</string> <string>request_stop</string>
<string>update_connection</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
<string>request_instance</string> <string>request_instance</string>
<string>request_start</string> <string>request_start</string>
<string>request_stop</string> <string>request_stop</string>
<string>update_connection</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="TransitionDefinition" module="Products.DCWorkflow.Transitions"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
</item>
<item>
<key> <string>actbox_icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value> <string>RequestedInstance_updateConnectionInformation</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>update_connection</string> </value>
</item>
<item>
<key> <string>new_state_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
262 263
\ No newline at end of file \ No newline at end of file
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