def test_call_no_service_defined(self): root = TemplateNode() node = TemplateSRAIXNode() root.append(node) node.append(TemplateWordNode("Hello")) self.assertEqual("", node.resolve(self._client_context))
def test_to_xml_no_service(self): root = TemplateNode() node = TemplateSRAIXNode() root.append(node) node.append(TemplateWordNode("Hello")) xml = root.xml_tree(self._client_context) self.assertIsNotNone(xml) xml_str = ET.tostring(xml, "utf-8").decode("utf-8") self.assertEqual('<template><sraix>Hello</sraix></template>', xml_str)
def test_node_no_service(self): root = TemplateNode() self.assertIsNotNone(root) self.assertIsNotNone(root.children) self.assertEqual(len(root.children), 0) node = TemplateSRAIXNode() self.assertIsNotNone(node) root.append(node) self.assertEqual(len(root.children), 1) self.assertEqual("SRAIX ()", node.to_string())
def test_node_unsupported_attributes(self): root = TemplateNode() self.assertIsNotNone(root) self.assertIsNotNone(root.children) self.assertEqual(len(root.children), 0) node = TemplateSRAIXNode() self.assertIsNotNone(node) node.host = "http://somebot.org" node.botid = "1234567890" node.hint = "The usual" node.apikey = "ABCDEF" node.service = "api" root.append(node) self.assertEqual(len(root.children), 1) self.assertEqual("SRAIX (service=api)", node.to_string())
def test_call_service(self): service_config = BrainServiceConfiguration("mock") service_config._classname = 'programrtest.services.test_service.MockService' brain_config = BrainConfiguration() brain_config.services._services['mock'] = service_config ServiceFactory.preload_services(brain_config.services) root = TemplateNode() node = TemplateSRAIXNode() node.service = "mock" root.append(node) node.append(TemplateWordNode("Hello")) self.assertEqual("asked", node.resolve(self._client_context))
def __init__(self): TemplateSRAIXNode.__init__(self)