コード例 #1
0
    def test_ask_question_no_host(self):

        response_data = 'Hello'
        request_api = MockPublishedRestAPI(response=response_data)
        service = PublishedRestService(config=self._config, api=request_api)
        self.assertIsNotNone(service)

        service.method = "GET"
        service.query = '"userid": "test01", "question": "Hello"'
        service.header = '"Content-type": "application/json,charset=UTF-8"'
        service.body = None

        question = None
        response = service.ask_question(self._client_context, question)
        self.assertEqual('', response)
コード例 #2
0
    def test_ask_question_no_charset(self):

        response_data = 'Hello'
        request_api = MockPublishedRestAPI(response=response_data)
        service = PublishedRestService(config=self._config, api=request_api)
        self.assertIsNotNone(service)

        service.host = "http://test.publishdrest.url"
        service.method = "GET"
        service.query = {"userid": "test01", "question": "Hello"}
        service.header = {"Content-type": "application/json"}
        service.body = '{"json": {"data": "test"}}'

        question = None
        response = service.ask_question(self._client_context, question)
        self.assertEqual('Hello', response)
コード例 #3
0
    def test_ask_question_invlid_method(self):

        response_data = 'Hello'
        request_api = MockPublishedRestAPI(response=response_data)
        service = PublishedRestService(config=self._config, api=request_api)
        self.assertIsNotNone(service)

        service.host = "http://test.publishdrest.url"
        service.method = "INSERT"
        service.query = None
        service.header = None
        service.body = "Hello"

        question = None
        response = service.ask_question(self._client_context, question)
        self.assertEqual("", response)