Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test strings #279

Merged
merged 2 commits into from
Sep 4, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions chatterbot/chatterbot.py
Original file line number Diff line number Diff line change
@@ -143,12 +143,12 @@ def get_response(self, input_item):
existing_statement = self.storage.find(input_statement.text)

if existing_statement:
self.logger.info(u'{} is a known statement'.format(input_statement.text))
self.logger.info(u'"{}" is a known statement'.format(input_statement.text))
if input_statement.extra_data:
existing_statement.extra_data.update(input_statement.extra_data)
input_statement = existing_statement
else:
self.logger.info(u'{} is not a known statement'.format(input_statement.text))
self.logger.info(u'"{}" is not a known statement'.format(input_statement.text))

# Select a response to the input statement
confidence, response = self.logic.process(input_statement)
2 changes: 0 additions & 2 deletions tests/base_case.py
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@ def get_kwargs(self):
return {
'input_adapter': 'chatterbot.adapters.input.VariableInputTypeAdapter',
'output_adapter': 'chatterbot.adapters.output.OutputFormatAdapter',
'output_format': 'text',
'database': self.create_test_data_directory()
}

@@ -72,6 +71,5 @@ def get_kwargs(self):
kwargs = super(ChatBotMongoTestCase, self).get_kwargs()
kwargs['database'] = self.random_string()
kwargs['storage_adapter'] = 'chatterbot.adapters.storage.MongoDatabaseAdapter'
kwargs['output_format'] = 'object'
return kwargs

4 changes: 2 additions & 2 deletions tests/test_chatbot.py
Original file line number Diff line number Diff line change
@@ -110,7 +110,7 @@ def test_response_format(self):
self.chatbot.storage.update(self.test_statement)

response = self.chatbot.get_response("Hi")
statement_object = self.chatbot.storage.find(response)
statement_object = self.chatbot.storage.find(response.text)

self.assertEqual(response, self.test_statement.text)
self.assertEqual(len(statement_object.in_response_to), 1)
@@ -122,7 +122,7 @@ def test_second_response_format(self):
response = self.chatbot.get_response("Hi")
# response = "Hello"
second_response = self.chatbot.get_response("How are you?")
statement = self.chatbot.storage.find(second_response)
statement = self.chatbot.storage.find(second_response.text)

# Make sure that the second response was saved to the database
self.assertIsNotNone(self.chatbot.storage.find("How are you?"))
12 changes: 6 additions & 6 deletions tests/training_tests/test_list_training.py
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ def test_training_adds_statements(self):

response = self.chatbot.get_response("Thank you.")

self.assertEqual(response, "You are welcome.")
self.assertEqual(response.text, "You are welcome.")

def test_training_increments_occurrence_count(self):

@@ -178,14 +178,14 @@ def test_answer_to_known_input(self):
input_text = "What... is your favourite colour?"
response = self.chatbot.get_response(input_text)

self.assertIn("Blue", response)
self.assertIn("Blue", response.text)

def test_answer_close_to_known_input(self):

input_text = "What is your favourite colour?"
response = self.chatbot.get_response(input_text)

self.assertIn("Blue", response)
self.assertIn("Blue", response.text)

def test_match_has_no_response(self):
"""
@@ -196,13 +196,13 @@ def test_match_has_no_response(self):
input_text = "Siri is my cat"
response = self.chatbot.get_response(input_text)

self.assertGreater(len(response), 0)
self.assertGreater(len(response.text), 0)

def test_empty_input(self):
"""
If empty input is provided, anything may be returned.
"""
output = self.chatbot.get_response("")
response = self.chatbot.get_response("")

self.assertTrue(len(output) >= 0)
self.assertTrue(len(response.text) >= 0)