def test_underline(self): node = PatternOneOrMoreWildCardNode("_") self.assertIsNotNone(node) self.assertFalse(node.is_root()) self.assertFalse(node.is_priority()) self.assertFalse(node.is_zero_or_more()) self.assertTrue(node.is_one_or_more()) self.assertFalse(node.is_set()) self.assertFalse(node.is_bot()) self.assertFalse(node.is_template()) self.assertFalse(node.is_that()) self.assertFalse(node.is_topic()) self.assertTrue(node.is_wildcard()) self.assertIsNotNone(node.children) self.assertFalse(node.has_children()) self.assertEqual(node.wildcard, "_") sentence = Sentence(self._client_context.brain.nlp.tokenizer, "*") self.assertTrue(node.equivalent(PatternOneOrMoreWildCardNode("_"))) result = node.equals(self._client_context, sentence, 0) self.assertFalse(result.matched) self.assertEqual( node.to_string(), "ONEORMORE [*] [P(0)^(0)#(0)C(0)_(0)*(0)To(0)Th(0)Te(0)] wildcard=[_]" ) self.assertEqual('<oneormore wildcard="_">\n</oneormore>\n', node.to_xml(self._client_context)) self.assertFalse(node.equivalent(PatternWordNode("test")))
def test_equivalent_userid(self): node1 = PatternOneOrMoreWildCardNode("*") node2 = PatternOneOrMoreWildCardNode("*") node3 = PatternOneOrMoreWildCardNode("*", userid="testuser") self.assertTrue(node1.equivalent(node2)) self.assertFalse(node1.equivalent(node3))