def test_init(self): graph = TemplateGraph(self._client_context.brain.aiml_parser) self.assertIsNotNone(graph) self.assertEquals(self._client_context.brain.aiml_parser, graph.aiml_parser) self.assertEquals(self._client_context.brain.template_factory, graph.template_factory)
def setUp(self): self.parser = TemplateGraph(AIMLParser()) self.assertIsNotNone(self.parser) self.test_brain = None self.test_sentence = Sentence("test sentence") test_node = PatternOneOrMoreWildCardNode("*") self.test_sentence._matched_context = MatchContext(max_search_depth=100, max_search_timeout=-1) self.test_sentence._matched_context._matched_nodes = [Match(Match.WORD, test_node, 'one'), Match(Match.WORD, test_node, 'two'), Match(Match.WORD, test_node, 'three'), Match(Match.WORD, test_node, 'four'), Match(Match.WORD, test_node, 'five'), Match(Match.WORD, test_node, 'six'), Match(Match.TOPIC, test_node, '*'), Match(Match.THAT, test_node, '*')] test_config = ProgramyConfiguration(self.get_client_config(), brain_config=self.get_brain_config(), bot_config=self.get_bot_config()) self.test_bot = Bot(Brain(self.get_brain_config()), config=test_config.bot_configuration) self.test_clientid = "testid" conversation = self.test_bot.get_conversation(self.test_clientid) question = Question.create_from_sentence(self.test_sentence) conversation._questions.append(question)
def __init__(self, brain=None): self._brain = brain self.pattern_parser = PatternGraph(aiml_parser=self) self.template_parser = TemplateGraph(aiml_parser=self) self._aiml_loader = AIMLLoader(self) self._num_categories = 0 self._duplicates = None self._errors = None
def __init__(self, supress_warnings=False, stop_on_invalid=False): self._supress_warnings = supress_warnings self.stop_on_invalid = stop_on_invalid self.pattern_parser = PatternGraph() self.template_parser = TemplateGraph(self) self._filename = "Unknown" self._version = "Unknown" self._aiml_loader = AIMLLoader(self) self._num_categories = 0
def setUp(self): self.parser = TemplateGraph() self.assertIsNotNone(self.parser) self.test_brain = None test_config = ClientConfiguration() self.test_bot = Bot(Brain(BrainConfiguration()), config=test_config.bot_configuration) self.test_clientid = "testid"
def __init__(self, supress_warnings=False, stop_on_invalid=False): self._supress_warnings = supress_warnings self.stop_on_invalid = stop_on_invalid self.pattern_parser = PatternGraph() self.template_parser = TemplateGraph(self) self._aiml_loader = AIMLLoader(self) self._num_categories = 0 self._duplicates = None self._errors = None
def setUp(self): self.parser = TemplateGraph() self.assertIsNotNone(self.parser) self.test_brain = None self.test_sentence = Sentence("test sentence") self.test_sentence._stars = ['one', 'two', 'three', 'four', 'five', 'six'] self.test_sentence._thatstars = ["*"] self.test_sentence._topicstars = ["*"] test_config = ClientConfiguration() self.test_bot = Bot(Brain(BrainConfiguration()), config=test_config.bot_configuration) self.test_clientid = "testid" conversation = self.test_bot.get_conversation(self.test_clientid) question = Question.create_from_sentence(self.test_sentence) conversation._questions.append(question)
def create_template_graph(self): return TemplateGraph(aiml_parser=self)
def test_get_node_class_by_name_missing(self): graph = TemplateGraph(self._client_context.brain.aiml_parser) with self.assertRaises(ParserException): _ = graph.get_node_class_by_name("other")
def test_get_node_class_by_name(self): graph = TemplateGraph(self._client_context.brain.aiml_parser) node = graph.get_node_class_by_name("base") self.assertIsNotNone(node)