def test_ask_question_no_botid(self):

        config = BrainServiceConfiguration("__PUBLISHEDBOT__")
        config._host = "test_publishdbot"

        self._client_context.bot.brain.configuration._bot_name = "RequestBot"
        self._client_context.bot.brain.configuration._manager_name = "Bot_API_key"

        userInfo = UserInfo(None, None)
        userInfo.set("__USER_LOCALE__", "ja-JP")
        userInfo.set("__USER_TIME__", "2019-01-01T00:00:00+09:00")
        userInfo.set("__USER_METADATA__", "Test Data")
        self._client_context.userInfo = userInfo

        response_data = '{"response": "Hello"}'
        request_api = MockPublishedBotAPI(response=response_data)
        service = PublishedBotService(config=config, api=request_api)
        self.assertIsNotNone(service)

        service.botId = None
        service.botHost = None
        service.locale = None
        service.time = None
        service.userId = "user00"
        service.topic = None
        service.deleteVariable = None
        service.metadata = None
        service.config = None

        question = "Hello"
        response = service.ask_question(self._client_context, question)
        self.assertEqual('', response)
    def test_ask_question_exception(self):

        config = BrainServiceConfiguration("__PUBLISHEDBOT__")
        config._host = "test_publishdbot"

        self._client_context.bot.brain.configuration._bot_name = "RequestBot"
        self._client_context.bot.brain.configuration._manager_name = "Bot_API_key"

        response_data = '{"response": "Hello"}'
        request_api = MockPublishedBotAPI(response=response_data,
                                          throw_exception=True)
        service = PublishedBotService(config=config, api=request_api)
        self.assertIsNotNone(service)

        service.botId = "PublishedBot"
        service.botHost = None
        service.locale = None
        service.time = None
        service.userId = "user00"
        service.topic = None
        service.deleteVariable = None
        service.metadata = None
        service.config = None

        question = "Hello"
        response = service.ask_question(self._client_context, question)
        self.assertEqual('', response)
    def test_ask_question_all_parameter(self):

        config = BrainServiceConfiguration("__PUBLISHEDBOT__")
        config._host = "test_publishdbot"

        self._client_context.bot.brain.configuration._bot_name = "RequestBot"
        self._client_context.bot.brain.configuration._manager_name = "Bot_API_key"

        response_data = '{"response": "Hello"}'
        request_api = MockPublishedBotAPI(response=response_data)
        service = PublishedBotService(config=config, api=request_api)
        self.assertIsNotNone(service)

        service.botId = "PublishedBot"
        service.botHost = "cotobadesign.co.jp"
        service.locale = "ja-JP"
        service.time = "2019-01-01T00:00:00+09:00"
        service.userId = "user00"
        service.topic = "morning"
        service.deleteVariable = True
        service.metadata = "Test Data"
        service.config = '{"logLevel": "debug"}'

        question = "Hello"
        response = service.ask_question(self._client_context, question)
        self.assertEqual('{"response": "Hello"}', response)