class ResponseIntegrationTestCase(TestCase):

    """
    Test case to make sure that the Django Response model
    and ChatterBot Response object have a common interface.
    """

    def setUp(self):
        super(ResponseIntegrationTestCase, self).setUp()
        statement_object = StatementObject(text='_')
        statement_model = StatementModel.objects.create(text='_')
        self.object = ResponseObject(statement_object.text)
        self.model = ResponseModel(statement=statement_model, response=statement_model)
        self.model.save()

    def test_serialize(self):
        object_data = self.object.serialize()
        model_data = self.model.serialize()

        self.assertEqual(len(object_data), len(model_data))
        self.assertIn('text', object_data)
        self.assertIn('text', model_data)
        self.assertEqual(object_data['text'], model_data['text'])
        self.assertIn('occurrence', object_data)
        self.assertIn('occurrence', model_data)
        self.assertEqual(object_data['occurrence'], model_data['occurrence'])
 def setUp(self):
     super(ResponseIntegrationTestCase, self).setUp()
     statement_object = StatementObject(text='_')
     statement_model = StatementModel.objects.create(text='_')
     self.object = ResponseObject(statement_object.text)
     self.model = ResponseModel(statement=statement_model, response=statement_model)
     self.model.save()
 def setUp(self):
     super(ResponseIntegrationTestCase, self).setUp()
     date_created = timezone.now()
     statement_object = StatementObject(text='_', created_at=date_created)
     statement_model = StatementModel.objects.create(text='_', created_at=date_created)
     self.object = ResponseObject(statement_object.text)
     self.model = ResponseModel(statement=statement_model, response=statement_model)
    def test_best_match(self):
        from chatterbot.logic import BestMatch

        adapter = BestMatch()
        adapter.set_chatbot(self.chatbot)

        statement1 = Statement(text='Do you like programming?')
        statement1.save()

        statement2 = Statement(text='Yes')
        statement2.save()

        response = Response(statement=statement1, response=statement2)
        response.save()

        response = adapter.process(statement1)

        self.assertEqual(response.text, 'Yes')
        self.assertEqual(response.confidence, 1)
    def test_best_match(self):
        from chatterbot.logic import BestMatch

        adapter = BestMatch()
        adapter.set_chatbot(self.chatbot)

        statement1 = Statement(text='Do you like programming?')
        statement1.save()

        statement2 = Statement(text='Yes')
        statement2.save()

        response = Response(statement=statement1, response=statement2)
        response.save()

        response = adapter.process(statement1)

        self.assertEqual(response.text, 'Yes')
        self.assertEqual(response.confidence, 1)
Example #6
0
class ResponseIntegrationTestCase(TestCase):
    """
    Test case to make sure that the Django Response model
    and ChatterBot Response object have a common interface.
    """
    def setUp(self):
        super(ResponseIntegrationTestCase, self).setUp()
        date_created = timezone.now()
        statement_object = StatementObject(text='_', created_at=date_created)
        statement_model = StatementModel.objects.create(
            text='_', created_at=date_created)
        self.object = ResponseObject(statement_object.text)
        self.model = ResponseModel(statement=statement_model,
                                   response=statement_model)

    def test_serialize(self):
        object_data = self.object.serialize()
        model_data = self.model.serialize()

        self.assertEqual(object_data, model_data)