def setUp(self):
        """
        Instantiate the adapter.
        """
        from pymongo.errors import ServerSelectionTimeoutError
        from pymongo import MongoClient

        database_name = "test_db"

        # Skip these tests if a mongo client is not running
        try:
            client = MongoClient(serverSelectionTimeoutMS=0.1)
            client.server_info()

            self.adapter = MongoDatabaseAdapter(database=database_name)

        except ServerSelectionTimeoutError:
            raise SkipTest("Unable to connect to mongo database.")
    def setUp(self):
        """
        Instantiate the adapter.
        """
        from pymongo.errors import ServerSelectionTimeoutError
        from pymongo import MongoClient

        # Skip these tests if a mongo client is not running
        try:
            client = MongoClient(serverSelectionTimeoutMS=0.1)
            client.server_info()

            self.adapter = MongoDatabaseAdapter(
                database_uri=
                "mongodb://localhost:27017/chatterbot_test_database")

        except ServerSelectionTimeoutError:
            raise SkipTest("Unable to connect to mongo database.")
Exemple #3
0
    def setUpClass(cls):
        """
        Instantiate the adapter before any tests in the test case run.
        """
        from pymongo.errors import ServerSelectionTimeoutError
        from pymongo import MongoClient

        cls.has_mongo_connection = False

        try:
            client = MongoClient(serverSelectionTimeoutMS=0.1)
            client.server_info()

            cls.adapter = MongoDatabaseAdapter(
                database_uri=
                'mongodb://localhost:27017/chatterbot_test_database')

            cls.has_mongo_connection = True

        except ServerSelectionTimeoutError:
            pass
 def __init__(self, connection_uri, database_name):
     self.database_uri = connection_uri + database_name
     self.stat_collection = MongoDatabaseAdapter(
         database_uri=self.database_uri)
     mongo_client = MongoClient(connection_uri)
     self.collections_db = mongo_client[database_name]