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_remove_response(self):
        self.object.add_response(ResponseObject('Hello'))
        model_response_statement = StatementModel.objects.create(text='Hello')
        self.model.save()
        self.model.in_response.create(statement=self.model, response=model_response_statement)

        object_removed = self.object.remove_response('Hello')
        model_removed = self.model.remove_response('Hello')

        self.assertTrue(object_removed)
        self.assertTrue(model_removed)
Пример #4
0
    def get_statement(self):
        from chatterbot.conversation import Statement as StatementObject
        from chatterbot.conversation import Response as ResponseObject

        statement = StatementObject(self.text,
                                    tags=[tag.name for tag in self.tags],
                                    extra_data=self.extra_data)
        for response in self.in_response_to:
            statement.add_response(
                ResponseObject(text=response.text,
                               occurrence=response.occurrence))
        return statement
    def test_get_response_count(self):
        self.object.add_response(ResponseObject('Hello', occurrence=2))
        model_response_statement = StatementModel.objects.create(text='Hello')
        self.model.save()
        self.model.in_response.create(
            statement=self.model, response=model_response_statement, occurrence=2
        )

        object_count = self.object.get_response_count(StatementObject(text='Hello'))
        model_count = self.model.get_response_count(StatementModel(text='Hello'))

        self.assertEqual(object_count, 2)
        self.assertEqual(model_count, 2)
Пример #6
0
 def get_response(self):
     from chatterbot.conversation import Response as ResponseObject
     occ = {'occurrence': self.occurrence}
     return ResponseObject(text=self.text, **occ)