Commit b9904d9f authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Accept _ to display the parameters a bit nicer

See merge request nexedi/slapos.core!389
parents 7e61728e 9d093a5c
from Products.ERP5Type.Document import newTempBase
import json
return_list = []
try:
......@@ -9,6 +10,11 @@ except Exception:
if connection_dict is None:
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()
if relative_url == None:
relative_url = context.getRelativeUrl()
......
......@@ -306,7 +306,6 @@ class TestSoftwareInstance_getNewsDict(TestSlapOSHalJsonStyleMixin):
self.assertEqual(news_dict, expected_news_dict)
# Ensure it don't raise error when converting to JSON
json.dumps(news_dict)
class TestSoftwareInstallation_getNewsDict(TestSlapOSHalJsonStyleMixin):
def test(self):
......@@ -1199,4 +1198,53 @@ class TestInstanceTree_edit(TestSlapOSHalJsonStyleMixin):
self.instance_tree.getTextContent())
self.assertEqual(new_parameter,
self.instance_tree.getTextContent())
\ No newline at end of file
self.instance_tree.getTextContent())
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 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testSlapOSHalJsonStyleSkins</string> </value>
......@@ -55,28 +49,13 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<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>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
......@@ -89,7 +68,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -98,7 +77,7 @@
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</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