diff --git a/tests/api_tests/__init__.py b/tests/api/__init__.py similarity index 100% rename from tests/api_tests/__init__.py rename to tests/api/__init__.py diff --git a/tests/api_tests/test_gitter.py b/tests/api/test_gitter.py similarity index 100% rename from tests/api_tests/test_gitter.py rename to tests/api/test_gitter.py diff --git a/tests/api_tests/test_microsoft.py b/tests/api/test_microsoft.py similarity index 100% rename from tests/api_tests/test_microsoft.py rename to tests/api/test_microsoft.py diff --git a/tests/filter_integration_tests/__init__.py b/tests/input/__init__.py similarity index 100% rename from tests/filter_integration_tests/__init__.py rename to tests/input/__init__.py diff --git a/tests/input_adapter_tests/test_gitter_input_adapter.py b/tests/input/test_gitter_input_adapter.py similarity index 90% rename from tests/input_adapter_tests/test_gitter_input_adapter.py rename to tests/input/test_gitter_input_adapter.py index 90a78e696..84c20ce77 100644 --- a/tests/input_adapter_tests/test_gitter_input_adapter.py +++ b/tests/input/test_gitter_input_adapter.py @@ -1,6 +1,6 @@ from chatterbot.conversation import Statement from chatterbot.input import Gitter -from tests.api_tests.test_gitter import GitterTestCase +from tests.api.test_gitter import GitterTestCase class GitterAdapterTests(GitterTestCase): diff --git a/tests/input_adapter_tests/test_input_adapter.py b/tests/input/test_input_adapter.py similarity index 100% rename from tests/input_adapter_tests/test_input_adapter.py rename to tests/input/test_input_adapter.py diff --git a/tests/input_adapter_tests/test_mailgun.py b/tests/input/test_mailgun.py similarity index 100% rename from tests/input_adapter_tests/test_mailgun.py rename to tests/input/test_mailgun.py diff --git a/tests/input_adapter_tests/test_microsoft_input_adapter.py b/tests/input/test_microsoft_input_adapter.py similarity index 90% rename from tests/input_adapter_tests/test_microsoft_input_adapter.py rename to tests/input/test_microsoft_input_adapter.py index 80915428c..acb71fca7 100644 --- a/tests/input_adapter_tests/test_microsoft_input_adapter.py +++ b/tests/input/test_microsoft_input_adapter.py @@ -1,6 +1,6 @@ from chatterbot.conversation import Statement from chatterbot.input import Microsoft -from tests.api_tests.test_microsoft import MicrosoftTestCase +from tests.api.test_microsoft import MicrosoftTestCase class MicrosoftInputAdapterTests(MicrosoftTestCase): diff --git a/tests/input_adapter_tests/test_terminal_adapter.py b/tests/input/test_terminal_adapter.py similarity index 100% rename from tests/input_adapter_tests/test_terminal_adapter.py rename to tests/input/test_terminal_adapter.py diff --git a/tests/input_adapter_tests/__init__.py b/tests/logic/__init__.py similarity index 100% rename from tests/input_adapter_tests/__init__.py rename to tests/logic/__init__.py diff --git a/tests/logic_adapter_tests/__init__.py b/tests/logic/best_match_integration_tests/__init__.py similarity index 100% rename from tests/logic_adapter_tests/__init__.py rename to tests/logic/best_match_integration_tests/__init__.py diff --git a/tests/logic_adapter_tests/best_match_integration_tests/test_levenshtein_distance.py b/tests/logic/best_match_integration_tests/test_levenshtein_distance.py similarity index 100% rename from tests/logic_adapter_tests/best_match_integration_tests/test_levenshtein_distance.py rename to tests/logic/best_match_integration_tests/test_levenshtein_distance.py diff --git a/tests/logic_adapter_tests/best_match_integration_tests/test_sentiment_comparison.py b/tests/logic/best_match_integration_tests/test_sentiment_comparison.py similarity index 100% rename from tests/logic_adapter_tests/best_match_integration_tests/test_sentiment_comparison.py rename to tests/logic/best_match_integration_tests/test_sentiment_comparison.py diff --git a/tests/logic_adapter_tests/best_match_integration_tests/test_synset_distance.py b/tests/logic/best_match_integration_tests/test_synset_distance.py similarity index 100% rename from tests/logic_adapter_tests/best_match_integration_tests/test_synset_distance.py rename to tests/logic/best_match_integration_tests/test_synset_distance.py diff --git a/tests/logic_adapter_tests/test_best_match.py b/tests/logic/test_best_match.py similarity index 100% rename from tests/logic_adapter_tests/test_best_match.py rename to tests/logic/test_best_match.py diff --git a/tests/logic_adapter_tests/test_data_cache.py b/tests/logic/test_data_cache.py similarity index 100% rename from tests/logic_adapter_tests/test_data_cache.py rename to tests/logic/test_data_cache.py diff --git a/tests/logic_adapter_tests/test_logic_adapter.py b/tests/logic/test_logic_adapter.py similarity index 100% rename from tests/logic_adapter_tests/test_logic_adapter.py rename to tests/logic/test_logic_adapter.py diff --git a/tests/logic_adapter_tests/test_low_confidence_adapter.py b/tests/logic/test_low_confidence_adapter.py similarity index 100% rename from tests/logic_adapter_tests/test_low_confidence_adapter.py rename to tests/logic/test_low_confidence_adapter.py diff --git a/tests/logic_adapter_tests/test_mathematical_evaluation.py b/tests/logic/test_mathematical_evaluation.py similarity index 100% rename from tests/logic_adapter_tests/test_mathematical_evaluation.py rename to tests/logic/test_mathematical_evaluation.py diff --git a/tests/logic_adapter_tests/test_specific_response.py b/tests/logic/test_specific_response.py similarity index 100% rename from tests/logic_adapter_tests/test_specific_response.py rename to tests/logic/test_specific_response.py diff --git a/tests/logic_adapter_tests/test_time.py b/tests/logic/test_time.py similarity index 100% rename from tests/logic_adapter_tests/test_time.py rename to tests/logic/test_time.py diff --git a/tests/logic_adapter_tests/test_unit_conversion.py b/tests/logic/test_unit_conversion.py similarity index 100% rename from tests/logic_adapter_tests/test_unit_conversion.py rename to tests/logic/test_unit_conversion.py diff --git a/tests/logic_adapter_tests/best_match_integration_tests/__init__.py b/tests/output/__init__.py similarity index 100% rename from tests/logic_adapter_tests/best_match_integration_tests/__init__.py rename to tests/output/__init__.py diff --git a/tests/output_adapter_tests/test_gitter_output_adapter.py b/tests/output/test_gitter_output_adapter.py similarity index 91% rename from tests/output_adapter_tests/test_gitter_output_adapter.py rename to tests/output/test_gitter_output_adapter.py index 7b6c82bbd..9fd8c68a0 100644 --- a/tests/output_adapter_tests/test_gitter_output_adapter.py +++ b/tests/output/test_gitter_output_adapter.py @@ -1,6 +1,6 @@ from chatterbot.conversation import Statement from chatterbot.output import Gitter -from tests.api_tests.test_gitter import GitterTestCase +from tests.api.test_gitter import GitterTestCase class GitterAdapterTestCase(GitterTestCase): diff --git a/tests/output_adapter_tests/test_mailgun.py b/tests/output/test_mailgun.py similarity index 100% rename from tests/output_adapter_tests/test_mailgun.py rename to tests/output/test_mailgun.py diff --git a/tests/output_adapter_tests/test_microsoft_output_adapter.py b/tests/output/test_microsoft_output_adapter.py similarity index 90% rename from tests/output_adapter_tests/test_microsoft_output_adapter.py rename to tests/output/test_microsoft_output_adapter.py index e7ce0e244..d1895b72a 100644 --- a/tests/output_adapter_tests/test_microsoft_output_adapter.py +++ b/tests/output/test_microsoft_output_adapter.py @@ -1,6 +1,6 @@ from chatterbot.conversation import Statement from chatterbot.output import Microsoft -from tests.api_tests.test_microsoft import MicrosoftTestCase +from tests.api.test_microsoft import MicrosoftTestCase class MicrosoftAdapterTests(MicrosoftTestCase): diff --git a/tests/output_adapter_tests/test_output_adapter.py b/tests/output/test_output_adapter.py similarity index 100% rename from tests/output_adapter_tests/test_output_adapter.py rename to tests/output/test_output_adapter.py diff --git a/tests/output_adapter_tests/test_terminal_adapter.py b/tests/output/test_terminal_adapter.py similarity index 100% rename from tests/output_adapter_tests/test_terminal_adapter.py rename to tests/output/test_terminal_adapter.py diff --git a/tests/output_adapter_tests/__init__.py b/tests/storage/__init__.py similarity index 100% rename from tests/output_adapter_tests/__init__.py rename to tests/storage/__init__.py diff --git a/tests/storage_adapter_tests/test_mongo_adapter.py b/tests/storage/test_mongo_adapter.py similarity index 96% rename from tests/storage_adapter_tests/test_mongo_adapter.py rename to tests/storage/test_mongo_adapter.py index cd94d028d..6e7dff156 100644 --- a/tests/storage_adapter_tests/test_mongo_adapter.py +++ b/tests/storage/test_mongo_adapter.py @@ -5,26 +5,37 @@ class MongoAdapterTestCase(TestCase): - def setUp(self): + @classmethod + def setUpClass(cls): """ - Instantiate the adapter. + Instantiate the adapter before any tests in the test case run. """ from pymongo.errors import ServerSelectionTimeoutError from pymongo import MongoClient - # Skip these tests if a mongo client is not running + cls.has_mongo_connection = False + try: client = MongoClient( serverSelectionTimeoutMS=0.1 ) client.server_info() - self.adapter = MongoDatabaseAdapter( - database_uri="mongodb://localhost:27017/chatterbot_test_database" + cls.adapter = MongoDatabaseAdapter( + database_uri='mongodb://localhost:27017/chatterbot_test_database' ) + cls.has_mongo_connection = False + except ServerSelectionTimeoutError: - self.skipTest("Unable to connect to mongo database.") + pass + + def setUp(self): + """ + Skip these tests if a mongo client is not running. + """ + if not self.has_mongo_connection: + self.skipTest('Unable to connect to mongo database.') def tearDown(self): """ diff --git a/tests/storage_adapter_tests/test_sql_adapter.py b/tests/storage/test_sql_adapter.py similarity index 100% rename from tests/storage_adapter_tests/test_sql_adapter.py rename to tests/storage/test_sql_adapter.py diff --git a/tests/storage_adapter_tests/test_storage_adapter.py b/tests/storage/test_storage_adapter.py similarity index 100% rename from tests/storage_adapter_tests/test_storage_adapter.py rename to tests/storage/test_storage_adapter.py diff --git a/tests/storage_adapter_tests/integration_tests/__init__.py b/tests/storage_adapter_tests/integration_tests/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/storage_adapter_tests/integration_tests/mongo_integration_tests.py b/tests/storage_adapter_tests/integration_tests/mongo_integration_tests.py deleted file mode 100644 index 16062ea92..000000000 --- a/tests/storage_adapter_tests/integration_tests/mongo_integration_tests.py +++ /dev/null @@ -1,17 +0,0 @@ -from tests.base_case import ChatBotMongoTestCase - - -class MongoStorageIntegrationTests(ChatBotMongoTestCase): - - def test_database_is_updated(self): - """ - Test that the database is updated when read_only is set to false. - """ - input_text = 'What is the airspeed velocity of an unladen swallow?' - exists_before = self.chatbot.storage.filter(text=input_text) - - self.chatbot.get_response(input_text) - exists_after = self.chatbot.storage.filter(text=input_text) - - self.assertEqual(len(exists_before), 0) - self.assertTrue(len(exists_after), 1) diff --git a/tests/storage_adapter_tests/integration_tests/sqlalchemy_integration_tests.py b/tests/storage_adapter_tests/integration_tests/sqlalchemy_integration_tests.py deleted file mode 100644 index fa6878b3e..000000000 --- a/tests/storage_adapter_tests/integration_tests/sqlalchemy_integration_tests.py +++ /dev/null @@ -1,17 +0,0 @@ -from tests.base_case import ChatBotSQLTestCase - - -class SqlStorageIntegrationTests(ChatBotSQLTestCase): - - def test_database_is_updated(self): - """ - Test that the database is updated when read_only is set to false. - """ - input_text = 'What is the airspeed velocity of an unladen swallow?' - exists_before = self.chatbot.storage.filter(text=input_text) - - self.chatbot.get_response(input_text) - exists_after = self.chatbot.storage.filter(text=input_text) - - self.assertEqual(len(exists_before), 0) - self.assertTrue(len(exists_after), 1) diff --git a/tests/conversation_tests/test_statements.py b/tests/test_conversations.py similarity index 97% rename from tests/conversation_tests/test_statements.py rename to tests/test_conversations.py index 209be2373..85ab3a003 100644 --- a/tests/conversation_tests/test_statements.py +++ b/tests/test_conversations.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- from unittest import TestCase from chatterbot.conversation import Statement diff --git a/tests/filter_integration_tests/test_filters_with_mongo_storage.py b/tests/test_filters.py similarity index 100% rename from tests/filter_integration_tests/test_filters_with_mongo_storage.py rename to tests/test_filters.py diff --git a/tests/storage_adapter_tests/__init__.py b/tests/training/__init__.py similarity index 100% rename from tests/storage_adapter_tests/__init__.py rename to tests/training/__init__.py diff --git a/tests/training_tests/test_chatterbot_corpus_training.py b/tests/training/test_chatterbot_corpus_training.py similarity index 100% rename from tests/training_tests/test_chatterbot_corpus_training.py rename to tests/training/test_chatterbot_corpus_training.py diff --git a/tests/training_tests/test_data/get_search.json b/tests/training/test_data/get_search.json similarity index 100% rename from tests/training_tests/test_data/get_search.json rename to tests/training/test_data/get_search.json diff --git a/tests/training_tests/test_database_export.py b/tests/training/test_database_export.py similarity index 100% rename from tests/training_tests/test_database_export.py rename to tests/training/test_database_export.py diff --git a/tests/training_tests/test_list_training.py b/tests/training/test_list_training.py similarity index 100% rename from tests/training_tests/test_list_training.py rename to tests/training/test_list_training.py diff --git a/tests/training_tests/test_training.py b/tests/training/test_training.py similarity index 100% rename from tests/training_tests/test_training.py rename to tests/training/test_training.py diff --git a/tests/training_tests/test_training_preprocessors.py b/tests/training/test_training_preprocessors.py similarity index 100% rename from tests/training_tests/test_training_preprocessors.py rename to tests/training/test_training_preprocessors.py diff --git a/tests/training_tests/test_twitter_trainer.py b/tests/training/test_twitter_trainer.py similarity index 100% rename from tests/training_tests/test_twitter_trainer.py rename to tests/training/test_twitter_trainer.py diff --git a/tests/training_tests/test_ubuntu_corpus_training.py b/tests/training/test_ubuntu_corpus_training.py similarity index 100% rename from tests/training_tests/test_ubuntu_corpus_training.py rename to tests/training/test_ubuntu_corpus_training.py diff --git a/tests/training_tests/__init__.py b/tests/training_tests/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests_django/integration_tests/__init__.py b/tests_django/integration_tests/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests_django/integration_tests/test_chatterbot_corpus_training.py b/tests_django/test_chatterbot_corpus_training.py similarity index 100% rename from tests_django/integration_tests/test_chatterbot_corpus_training.py rename to tests_django/test_chatterbot_corpus_training.py diff --git a/tests_django/integration_tests/test_input_adapter_integration.py b/tests_django/test_input_adapter_integration.py similarity index 100% rename from tests_django/integration_tests/test_input_adapter_integration.py rename to tests_django/test_input_adapter_integration.py diff --git a/tests_django/integration_tests/test_logic_adapter_integration.py b/tests_django/test_logic_adapter_integration.py similarity index 100% rename from tests_django/integration_tests/test_logic_adapter_integration.py rename to tests_django/test_logic_adapter_integration.py diff --git a/tests_django/integration_tests/test_output_adapter_integration.py b/tests_django/test_output_adapter_integration.py similarity index 100% rename from tests_django/integration_tests/test_output_adapter_integration.py rename to tests_django/test_output_adapter_integration.py diff --git a/tests_django/integration_tests/test_statement_integration.py b/tests_django/test_statement_integration.py similarity index 100% rename from tests_django/integration_tests/test_statement_integration.py rename to tests_django/test_statement_integration.py