Пример #1
0
 def test_verify_api_key_usage_inactive(self):
     arguments = MockArgumentParser()
     client = FlaskRestBotClient(arguments)
     self.assertIsNotNone(client)
     client.configuration.client_configuration._use_api_keys = False
     request = unittest.mock.Mock()
     self.assertEquals((None, None), client.verify_api_key_usage(request))
Пример #2
0
    def test_get_api_key(self):
        arguments = MockArgumentParser()
        client = FlaskRestBotClient(arguments)

        request = unittest.mock.Mock()
        request.args = {}
        request.args['apikey'] = '11111111'

        self.assertEquals('11111111', client.get_api_key(request))
Пример #3
0
    def test_get_question(self):
        arguments = MockArgumentParser()
        client = FlaskRestBotClient(arguments)
        self.assertIsNotNone(client)

        request = unittest.mock.Mock()
        request.args = {}
        request.args['question'] = 'Hello'

        self.assertEquals("Hello", client.get_question(request))
Пример #4
0
    def test_format_success_response(self):
        arguments = MockArgumentParser()
        client = FlaskRestBotClient(arguments)
        self.assertIsNotNone(client)

        response = client.format_success_response("1234567890", "Hello", "Hi")
        self.assertIsNotNone(response)
        self.assertEquals("1234567890", response['sessionid'])
        self.assertEquals("Hello", response['question'])
        self.assertEquals("Hi", response['answer'])
Пример #5
0
    def test_get_sessionid(self):
        arguments = MockArgumentParser()
        client = FlaskRestBotClient(arguments)
        self.assertIsNotNone(client)

        request = unittest.mock.Mock()
        request.args = {}
        request.args['sessionid'] = '1234567890'

        self.assertEquals("1234567890", client.get_sessionid(request))
Пример #6
0
 def test_verify_api_key_usage_active(self):
     arguments = MockArgumentParser()
     client = FlaskRestBotClient(arguments)
     self.assertIsNotNone(client)
     client.configuration.client_configuration._use_api_keys = True
     client.configuration.client_configuration._api_key_file = os.path.dirname(
         __file__) + os.sep + "api_keys.txt"
     client.load_api_keys()
     request = unittest.mock.Mock()
     request.args = {}
     request.args['apikey'] = '11111111'
     self.assertEquals((None, None), client.verify_api_key_usage(request))
Пример #7
0
 def test_rest_client_init(self):
     arguments = MockArgumentParser()
     client = FlaskRestBotClient(arguments)
     self.assertIsNotNone(client)
Пример #8
0
 def __init__(self, argument_parser=None):
     FlaskRestBotClient.__init__(self, argument_parser)
     self.aborted = False
     self.answer = None
     self.ask_question_exception = False