def test_call_CustomService_response_default(self): service_config = BrainServiceConfiguration("mock") service_config._classname = 'programytest.services.test_service.MockService' brain_config = BrainConfiguration() brain_config.services._services['mock'] = service_config ServiceFactory.preload_services(brain_config.services) root = TemplateNode() node = TemplateSRAIXNode() node._service = "mock" node._default = "unknown" node.append(TemplateWordNode("Hello")) root.append(node) service = ServiceFactory.get_service("mock") service.set_response("") self.assertEqual("unknown", node.resolve(self._client_context)) conversation = self._client_context.bot.get_conversation( self._client_context) self.assertIsNotNone(conversation) question = Question.create_from_text( self._client_context, "Hello", self._client_context.bot.sentence_splitter) conversation.record_dialog(question) self.assertIsNotNone(conversation.current_question()) self.assertEqual("unknown", node.resolve(self._client_context)) self.assertEqual("unknown", question.property('__SUBAGENT__.mock'))
def test_call_CustomService_response_none(self): service_config = BrainServiceConfiguration("mock") service_config._classname = 'programytest.services.test_service.MockService' brain_config = BrainConfiguration() brain_config.services._services['mock'] = service_config ServiceFactory.preload_services(brain_config.services) root = TemplateNode() node = TemplateSRAIXNode() node._service = "mock" node.append(TemplateWordNode("Hello")) root.append(node) service = ServiceFactory.get_service("mock") service.set_response(None) self.assertEqual(None, node.resolve(self._client_context))