Commit 9d093a5c authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Accept _ to display the parameters a bit nicer

parent 7e61728e
from Products.ERP5Type.Document import newTempBase from Products.ERP5Type.Document import newTempBase
import json
return_list = [] return_list = []
try: try:
...@@ -9,6 +10,11 @@ except Exception: ...@@ -9,6 +10,11 @@ except Exception:
if connection_dict is None: if connection_dict is None:
return return_list return return_list
if connection_dict.keys() == ["_"]:
json_connection_dict = json.loads(connection_dict["_"])
if isinstance(json_connection_dict, dict):
connection_dict = json_connection_dict
portal = context.getPortalObject() portal = context.getPortalObject()
if relative_url == None: if relative_url == None:
relative_url = context.getRelativeUrl() relative_url = context.getRelativeUrl()
......
...@@ -306,7 +306,6 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin): ...@@ -306,7 +306,6 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin):
self.assertEqual(news_dict, expected_news_dict) self.assertEqual(news_dict, expected_news_dict)
# Ensure it don't raise error when converting to JSON # Ensure it don't raise error when converting to JSON
json.dumps(news_dict) json.dumps(news_dict)
class TestSoftwareInstallation_getNewsDict(TestSlapOSHalJsonStyleMixin): class TestSoftwareInstallation_getNewsDict(TestSlapOSHalJsonStyleMixin):
def test(self): def test(self):
...@@ -1199,4 +1198,53 @@ class TestInstanceTree_edit(TestSlapOSHalJsonStyleMixin): ...@@ -1199,4 +1198,53 @@ class TestInstanceTree_edit(TestSlapOSHalJsonStyleMixin):
self.instance_tree.getTextContent()) self.instance_tree.getTextContent())
self.assertEqual(new_parameter, self.assertEqual(new_parameter,
self.instance_tree.getTextContent()) self.instance_tree.getTextContent())
\ No newline at end of file
class TestSoftwareInstance_getConnectionParameterList(TestSlapOSHalJsonStyleMixin):
def testSoftwareInstance_getConnectionParameterList(self):
instance = self._makeInstance()
xml_sample = """<?xml version="1.0" encoding="utf-8"?>
<instance>
<parameter id="p0">ABC</parameter>
<parameter id="p1">DEF</parameter>
</instance>"""
instance.edit(connection_xml=xml_sample)
# Place instances on the project
self.logout()
self.login()
self.changeSkin("Hal")
self.assertEqual(
len(instance.SoftwareInstance_getConnectionParameterList()),
2)
self.assertEqual(
instance.SoftwareInstance_getConnectionParameterList(raw=True),
[{"connection_key": "p0", "connection_value": "ABC"},
{"connection_key": "p1", "connection_value": "DEF"}]
)
xml_sample = """<?xml version="1.0" encoding="utf-8"?>
<instance>
<parameter id="_">{"p0": "ABC", "p1": "DEF"}</parameter>
</instance>"""
instance.edit(connection_xml=xml_sample)
# Place instances on the project
self.logout()
self.login()
self.changeSkin("Hal")
self.assertEqual(
len(instance.SoftwareInstance_getConnectionParameterList()),
2)
self.assertEqual(
instance.SoftwareInstance_getConnectionParameterList(raw=True),
[{"connection_key": "p0", "connection_value": "ABC"},
{"connection_key": "p1", "connection_value": "DEF"}]
)
\ No newline at end of file
...@@ -6,12 +6,6 @@ ...@@ -6,12 +6,6 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>testSlapOSHalJsonStyleSkins</string> </value> <value> <string>testSlapOSHalJsonStyleSkins</string> </value>
...@@ -55,28 +49,13 @@ ...@@ -55,28 +49,13 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -89,7 +68,7 @@ ...@@ -89,7 +68,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -98,7 +77,7 @@ ...@@ -98,7 +77,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
......
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