def test_init_global_as_default_no_name(self): var = TemplateConditionListItemNode(name="var1") self.assertIsNotNone(var) self.assertEqual(var.name, "var1") self.assertEqual(var.var_type, TemplateConditionListItemNode.GLOBAL) self.assertFalse(var.loop) self.assertTrue(var.is_default()) self.assertEqual("[CONDITIONLIST(var1)]", var.to_string()) self.assertEqual('<li name="var1"></li>', var.to_xml(self._client_context))
def test_init_defaults(self): var = TemplateConditionListItemNode() self.assertIsNotNone(var) self.assertIsNone(var.name) self.assertIsNone(var.value) self.assertEquals(var.var_type, TemplateConditionListItemNode.GLOBAL) self.assertFalse(var.loop) self.assertTrue(var.is_default()) self.assertEquals("[CONDITIONLIST]", var.to_string()) self.assertEquals("<li></li>", var.to_xml(self._bot, self._clientid))
def test_init_global_as_default(self): var = TemplateConditionListItemNode(name="var1", value=TemplateWordNode("value1")) self.assertIsNotNone(var) self.assertEqual(var.name, "var1") self.assertEqual(var.value.word, "value1") self.assertEqual(var.var_type, TemplateConditionListItemNode.GLOBAL) self.assertFalse(var.loop) self.assertFalse(var.is_default()) self.assertEqual("[CONDITIONLIST(var1=[WORD]value1)]", var.to_string()) self.assertEqual('<li name="var1"><value>value1</value></li>', var.to_xml(self._client_context))
def test_init_bot_with_loop(self): var = TemplateConditionListItemNode(name="var1", value=TemplateWordNode("value1"), var_type=TemplateConditionListItemNode.BOT, loop=True) self.assertIsNotNone(var) self.assertEqual(var.name, "var1") self.assertEqual(var.value.word, "value1") self.assertEqual(var.var_type, TemplateConditionListItemNode.BOT) self.assertTrue(var.loop) self.assertFalse(var.is_default()) self.assertEqual("[CONDITIONLIST(var1=[WORD]value1)]", var.to_string()) self.assertEqual('<li bot="var1"><value>value1</value><loop /></li>', var.to_xml(self._client_context))
def test_init_local(self): var = TemplateConditionListItemNode( name="var1", value=TemplateWordNode("value1"), var_type=TemplateConditionListItemNode.LOCAL) self.assertIsNotNone(var) self.assertEquals(var.name, "var1") self.assertEquals(var.value.word, "value1") self.assertEquals(var.var_type, TemplateConditionListItemNode.LOCAL) self.assertFalse(var.loop) self.assertFalse(var.is_default()) self.assertEquals("[CONDITIONLIST(var1=[WORD]value1)]", var.to_string()) self.assertEquals('<li var="var1"><value>value1</value></li>', var.to_xml(self._bot, self._clientid))
def test_init_global_with_loop(self): var = TemplateConditionListItemNode( name="var1", value=TemplateWordNode("value1"), var_type=TemplateConditionListItemNode.GLOBAL, loop=True) self.assertIsNotNone(var) self.assertEquals(var.name, "var1") self.assertEquals(var.value.word, "value1") self.assertEquals(var.var_type, TemplateConditionListItemNode.GLOBAL) self.assertTrue(var.loop) self.assertFalse(var.is_default()) self.assertEquals("[CONDITIONLIST(var1=[WORD]value1)]", var.to_string()) self.assertEquals('<li name="var1"><value>value1</value><loop /></li>', var.to_xml(self.bot, self.clientid))
def test_to_xml_unknown_without_loop(self): var = TemplateConditionListItemNode(name="var1", value=TemplateWordNode("value1"), var_type="Unknown", loop=False) self.assertEquals('<li unknown="var1"><value>value1</value></li>', var.to_xml(self._client_context))
def test_to_xml_default_with_loop(self): var = TemplateConditionListItemNode(name="var1", value=TemplateWordNode("value1"), var_type=TemplateConditionListItemNode.DEFAULT, loop=True) self.assertEquals('<li default="var1"><value>value1</value><loop /></li>', var.to_xml(self._client_context))