def test_check_aiml_tag_no_namespace(self): aiml = ET.fromstring("""<?xml version="1.0" encoding="ISO-8859-1"?> <aiml version="1.01"> <category> <pattern>*</pattern> <template>RESPONSE</template> </category> </aiml> """) tag_name, namespace = AIMLParser.check_aiml_tag(aiml) self.assertEquals("aiml", tag_name) self.assertEquals(None, namespace)
def test_check_aiml_tag_not_aiml(self): aiml = ET.fromstring("""<?xml version="1.0" encoding="ISO-8859-1"?> <aipl version="1.01" xmlns="http://alicebot.org/2001/AIML" xmlns:aiml="http://alicebot.org/2001/AIML" xmlns:html="http://www.w3.org/TR/REC-html40"> <category> <pattern>*</pattern> <template>RESPONSE</template> </category> </aipl> """) with self.assertRaises(ParserException): _, _ = AIMLParser.check_aiml_tag(aiml)
def test_check_aiml_tag(self): aiml = ET.fromstring("""<?xml version="1.0" encoding="ISO-8859-1"?> <aiml version="1.01" xmlns="http://alicebot.org/2001/AIML" xmlns:aiml="http://alicebot.org/2001/AIML" xmlns:html="http://www.w3.org/TR/REC-html40"> <category> <pattern>*</pattern> <template>RESPONSE</template> </category> </aiml> """) tag_name, namespace = AIMLParser.check_aiml_tag(aiml) self.assertEquals("aiml", tag_name) self.assertEquals("{http://alicebot.org/2001/AIML}", namespace)
def test_check_aiml_tag_no_aiml(self): aiml = None with self.assertRaises(ParserException): tag_name, namespace = AIMLParser.check_aiml_tag(aiml)