Ejemplo n.º 1
0
 def test_collection_with_authentication(self, create_mongo_database_one):  # noqa: F811
     mongo_name = MongoDatabase(dbname=mongo_database_one)
     db = mongo_name.get_database()
     db.add_user("never", password="******")
     user = "******"
     pwd = "do_this_in_production"
     self.add_user(db, user, pwd)
     os.environ["MONGO_USER"] = user
     os.environ["MONGO_PASSWORD"] = pwd
     mongo_name_two = MongoDatabase(dbname=mongo_database_one)
     assert mongo_name.get_mongo_string() != mongo_name_two.get_mongo_string()
     os.environ["MONGO_USER"] = ''
     os.environ["MONGO_PASSWORD"] = ''
Ejemplo n.º 2
0
def create_mongo_database_no_name():
    db = MongoDatabase()
    yield db.get_database()
    db.drop_database()
Ejemplo n.º 3
0
def create_mongo_database_two():
    db = MongoDatabase(dbname=mongo_database_two)
    yield db.get_database()
    db.drop_database()
Ejemplo n.º 4
0
 def test_get_documents_from_all_collections(self, create_mongo_database_one):  # noqa: F811
     mongo_name = MongoDatabase(dbname=mongo_database_one)
     collection_dict = mongo_name.get_documents_from_all_collections()
     assert default_collection in collection_dict.keys()
     assert collection_dict[default_collection][0][simplest_document_key] == simplest_document_value
Ejemplo n.º 5
0
 def test_get_mongodb_collection_names(self, create_mongo_database_one):  # noqa: F811
     mongo_name = MongoDatabase(dbname=mongo_database_one)
     assert default_collection in mongo_name.get_mongodb_collection_names()
Ejemplo n.º 6
0
 def test_get_mongodb_database_collection(self, create_mongo_database_one):  # noqa: F811
     mongo_name = MongoDatabase(dbname=mongo_database_one)
     assert mongo_name.get_database()[default_collection] == \
         mongo_name.get_mongodb_database_collection(default_collection)
Ejemplo n.º 7
0
 def test_mongo_insert_with_db_name(self, create_mongo_database_one):  # noqa: F811
     mongo_name = MongoDatabase(dbname=mongo_database_one)
     self.run_insert_one_mongo_script(mongo_name)
     assert mongo_name.get_database()[default_collection].find_one(simplest_document) == simplest_document