Ejemplo n.º 1
0
    def test_find_all_no_namespace(self):
        aiml = ET.fromstring("""
            <topic>
                    <category>
                        <pattern>HI</pattern>
                        <template>RESPONSE</template>
                    </category>
                    <category>
                        <pattern>HELLO</pattern>
                        <template>RESPONSE</template>
                    </category>
            </topic>
        """)

        store = CategoryReadOnlyStore()
        found = store.find_all(aiml, "category")
        self.assertIsNotNone(found)
        self.assertEqual(2, len(found))
Ejemplo n.º 2
0
    def test_find_all_with_namespace(self):
        aiml = ET.fromstring("""<?xml version="1.0" encoding="ISO-8859-1"?>
            <a:aiml version="1.01"
                  xmlns="http://alicebot.org/2001/AIML"
                  xmlns:a="http://alicebot.org/2001/AIML"
                  xmlns:html="http://www.w3.org/TR/REC-html40">
                  <a:topic>
                    <a:category>
                        <a:pattern>HI</a:pattern>
                        <a:template>RESPONSE</a:template>
                    </a:category>
                    <a:category>
                        <a:pattern>HELLO</a:pattern>
                        <a:template>RESPONSE</a:template>
                    </a:category>
                  </a:topic>
            </a:aiml>
        """)

        store = CategoryReadOnlyStore()
        found = store.find_all(aiml, "topic",
                               {"a": "http://alicebot.org/2001/AIML"})
        self.assertIsNotNone(found)
        self.assertEqual(1, len(found))