示例#1
0
    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))
示例#2
0
    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)
示例#3
0
    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())
示例#4
0
    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())
示例#5
0
    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))
示例#6
0
 def __init__(self):
     TemplateSRAIXNode.__init__(self)