Commit 40c4c4f0 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Improve and test getFastInputDict

parent 2546c2ec
""" # Recommendation, keep as simple as possible.
Sample of the return:
# Use string in url because there are multiple products for ORS,
# and it would be a costly query and require Manager Proxy role.
if context.getRootSlave():
return {}
for sr_string in ['software/re6stnet/', 'software/caddy-frontend/']:
if sr_string in context.getUrlString(''):
return { return {
'enabled': True, 'enabled': True,
'sla_xml': '<parameter id="instance_guid">%s</parameter>' % context.getSuccessorReference() 'sla_xml': '<parameter id="instance_guid">%s</parameter>' % context.getSuccessorReference()
} }
"""
return {} return {}
...@@ -1659,3 +1659,84 @@ class TestBase_getAttentionPointList(TestSlapOSHalJsonStyleMixin): ...@@ -1659,3 +1659,84 @@ class TestBase_getAttentionPointList(TestSlapOSHalJsonStyleMixin):
attention_point_list = json.loads( attention_point_list = json.loads(
support_request_module.Base_getAttentionPointList()) support_request_module.Base_getAttentionPointList())
self.assertEqual(attention_point_list, []) self.assertEqual(attention_point_list, [])
class TestInstanceTree_getFastInputDict(TestSlapOSHalJsonStyleMixin):
def afterSetUp(self):
self.instance_tree = self.portal.instance_tree_module.newContent(
portal_type="Instance Tree"
)
self.software_instance = self.portal.software_instance_module.newContent(
portal_type="Software Instance"
)
TestSlapOSHalJsonStyleMixin.afterSetUp(self)
def testInstanceTree_getFastInputDict_noUrlString(self):
self.assertEqual({},
self.instance_tree.InstanceTree_getFastInputDict())
def testInstanceTree_getFastInputDict_re6st_no_instance(self):
self.instance_tree.setUrlString(
self.portal.software_release_module.re6st.getUrlString())
self.assertEqual({},
self.instance_tree.InstanceTree_getFastInputDict())
def testInstanceTree_getFastInputDict_frontend_no_instance(self):
self.instance_tree.setUrlString(
self.portal.software_release_module.frontend.getUrlString())
self.assertEqual({},
self.instance_tree.InstanceTree_getFastInputDict())
def testInstanceTree_getFastInputDict_slave_re6st(self):
self.instance_tree.setRootSlave(True)
self.instance_tree.setUrlString(
self.portal.software_release_module.re6st.getUrlString())
slave_instance = self.portal.software_instance_module.newContent(
portal_type="Slave Instance",
specialise_value=self.instance_tree
)
self.instance_tree.setSuccessorValue(slave_instance)
self.assertEqual({},
self.instance_tree.InstanceTree_getFastInputDict())
def testInstanceTree_getFastInputDict_slave_frontend(self):
self.instance_tree.setRootSlave(True)
slave_instance = self.portal.software_instance_module.newContent(
portal_type="Slave Instance",
specialise_value=self.instance_tree
)
self.instance_tree.setSuccessorValue(slave_instance)
self.instance_tree.setUrlString(
self.portal.software_release_module.frontend.getUrlString())
self.assertEqual({},
self.instance_tree.InstanceTree_getFastInputDict())
def testInstanceTree_getFastInputDict_re6st(self):
self.instance_tree.setUrlString(
self.portal.software_release_module.re6st.getUrlString())
software_instance = self.portal.software_instance_module.newContent(
portal_type="Software Instance",
specialise_value=self.instance_tree,
reference="TESTSOFTINST-%s" % self.generateNewId()
)
self.instance_tree.setSuccessorValue(software_instance)
self.instance_tree.setUrlString(
self.portal.software_release_module.re6st.getUrlString())
self.assertEqual({
'enabled': True,
'sla_xml': '<parameter id="instance_guid">%s</parameter>' % software_instance.getReference()
}, self.instance_tree.InstanceTree_getFastInputDict())
def testInstanceTree_getFastInputDict_frontend(self):
software_instance = self.portal.software_instance_module.newContent(
portal_type="Software Instance",
specialise_value=self.instance_tree,
reference="TESTSOFTINST-%s" % self.generateNewId()
)
self.instance_tree.setSuccessorValue(software_instance)
self.instance_tree.setUrlString(
self.portal.software_release_module.frontend.getUrlString())
self.assertEqual({
'enabled': True,
'sla_xml': '<parameter id="instance_guid">%s</parameter>' % software_instance.getReference()
}, self.instance_tree.InstanceTree_getFastInputDict())
\ 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