Ejemplo n.º 1
0
class InputAdapterTestCase(ChatBotTestCase):
    """
    This test case is for the InputAdapter base class.
    Although this class is not intended for direct use,
    this test case ensures that exceptions requiring
    basic functionality are triggered when needed.
    """

    def setUp(self):
        super(InputAdapterTestCase, self).setUp()
        self.adapter = InputAdapter()

    def test_process_response(self):
        with self.assertRaises(InputAdapter.AdapterMethodNotImplementedError):
            self.adapter.process_input()

    def test_process_response_statement(self):
        with self.assertRaises(InputAdapter.AdapterMethodNotImplementedError):
            self.adapter.process_input_statement()

    def test_process_response_statement_initialized(self):
        self.adapter.chatbot = self.chatbot
        self.adapter.process_input = lambda *args, **kwargs: Statement('Hi')
        response = self.adapter.process_input_statement()
        self.assertEqual(response, 'Hi')
class InputAdapterTestCase(ChatBotTestCase):
    """
    Test case for the InputAdapter class.
    """

    def setUp(self):
        super().setUp()
        self.adapter = InputAdapter(self.chatbot)

    def test_process_input_statement(self):
        statement = self.adapter.process_input(Statement(text='Test'))

        self.assertEqual(statement.text, 'Test')

    def test_process_input_dict(self):
        data = {
            'text': 'Robot ipsum datus scan amet.'
        }
        statement = self.adapter.process_input(data)

        self.assertEqual(statement.text, data['text'])

    def test_process_input_text(self):
        text = 'The test statement to process is here.'
        statement = self.adapter.process_input(text)

        self.assertEqual(statement.text, text)

    def test_process_invalid_input_type(self):
        data = ['A list', 'of text', 'is an', 'invalid input type.']

        with self.assertRaises(InputAdapter.UnrecognizedInputFormatException):
            self.adapter.process_input(data)
Ejemplo n.º 3
0
 def setUp(self):
     super(InputAdapterTestCase, self).setUp()
     self.adapter = InputAdapter()
Ejemplo n.º 4
0
 def setUp(self):
     super().setUp()
     self.adapter = InputAdapter(self.chatbot)