diff --git a/chatterbot/storage/mongodb.py b/chatterbot/storage/mongodb.py index 75c3bb000..f4c9b65fa 100644 --- a/chatterbot/storage/mongodb.py +++ b/chatterbot/storage/mongodb.py @@ -78,10 +78,6 @@ def filter(self, **kwargs): tags = kwargs.pop('tags', []) exclude_text = kwargs.pop('exclude_text', None) - # Convert a single sting into a list if only one tag is provided - if type(tags) == str: - tags = [tags] - if tags: kwargs['tags'] = { '$in': tags @@ -277,7 +273,7 @@ def get_response_statements(self, page_size=1000): statement_query = self.statements.find(_statement_query) - for statement in list(statement_query): + for statement in statement_query: yield self.mongo_to_object(statement) def drop(self): diff --git a/tests/test_filters.py b/tests/test_filters.py index 4c65a8299..d25fc7f6f 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -29,7 +29,7 @@ def test_filter_selection(self): 'Hi', 'Hello', 'How are you?', - 'I am good.', + 'I am good', 'Glad to hear', 'How are you?' ]) diff --git a/tests_django/test_logic_adapter_integration.py b/tests_django/test_logic_adapter_integration.py index e3f5e0991..8537d5734 100644 --- a/tests_django/test_logic_adapter_integration.py +++ b/tests_django/test_logic_adapter_integration.py @@ -1,5 +1,5 @@ from tests_django.base_case import ChatterBotTestCase -from chatterbot.ext.django_chatterbot.models import Statement +from chatterbot.conversation import Statement class LogicIntegrationTestCase(ChatterBotTestCase): @@ -11,19 +11,19 @@ class LogicIntegrationTestCase(ChatterBotTestCase): def setUp(self): super().setUp() - Statement.objects.create(text='Default statement') + self.chatbot.storage.create(text='Default statement') def test_best_match(self): from chatterbot.logic import BestMatch adapter = BestMatch(self.chatbot) - statement1 = Statement.objects.create( + statement1 = self.chatbot.storage.create( text='Do you like programming?', conversation='test' ) - Statement.objects.create( + self.chatbot.storage.create( text='Yes', in_response_to=statement1.text, conversation='test'