def test_multiple_list_servers(self): """Function: test_multiple_list_servers Description: Test with multiple servers in a list. Arguments: """ mongo = mongo_libs.create_instance(self.config_name, self.config_dir, mongo_class.Server) mongo2 = mongo_libs.create_instance(self.config_name, self.config_dir, mongo_class.Server) mongo.connect() mongo2.connect() mongo_libs.disconnect([mongo, mongo2]) self.assertFalse(mongo.conn or mongo2.conn)
def test_combo_servers(self): """Function: test_combo_servers Description: Test with in a combination of servers and list. Arguments: """ mongo = mongo_libs.create_instance(self.config_name, self.config_dir, mongo_class.Server) mongo2 = mongo_libs.create_instance(self.config_name, self.config_dir, mongo_class.Server) mongo3 = mongo_libs.create_instance(self.config_name, self.config_dir, mongo_class.Server) mongo.connect() mongo2.connect() mongo3.connect() mongo_libs.disconnect([mongo, mongo2], mongo3) self.assertFalse(mongo.conn or mongo2.conn or mongo3.conn)
def test_no_mech_auth(self, mock_load): """Function: test_no_mech_auth Description: Test with no authentication mechanism passed. Arguments: """ mock_load.return_value = self.cfg mongo = mongo_libs.create_instance("cfg_file", "dir_path", mongo_class.Server) self.assertEqual(mongo.auth_mech, self.auth_meth)
def test_mech_auth2(self, mock_load): """Function: test_mech_auth2 Description: Test with authentication mechanism passed. Arguments: """ mock_load.return_value = self.cfg2 mongo = mongo_libs.create_instance("cfg_file", "dir_path", mongo_class.MasterRep) self.assertEqual(mongo.auth_mech, self.cfg2.auth_mech)
def test_no_ssl(self, mock_load): """Function: test_no_ssl Description: Test with no SSL passed. Arguments: """ mock_load.return_value = self.cfg mongo = mongo_libs.create_instance("cfg_file", "dir_path", mongo_class.Server) self.assertFalse(mongo.ssl_client_ca)
def test_none_ssl2(self, mock_load): """Function: test_none_ssl2 Description: Test with SSL set to None. Arguments: """ mock_load.return_value = self.cfg2 mongo = mongo_libs.create_instance("cfg_file", "dir_path", mongo_class.MasterRep) self.assertFalse(mongo.ssl_client_ca)
def test_set_ssl(self, mock_load): """Function: test_set_ssl Description: Test with SSL set. Arguments: """ mock_load.return_value = self.cfg3 mongo = mongo_libs.create_instance("cfg_file", "dir_path", mongo_class.Server) self.assertEqual(mongo.ssl_client_ca, self.ssl_client_ca)
def test_single_server(self): """Function: test_single_server Description: Test with one server. Arguments: """ mongo = mongo_libs.create_instance(self.config_name, self.config_dir, mongo_class.Server) mongo.connect() mongo_libs.disconnect(mongo) self.assertFalse(mongo.conn)
def test_new_attributes(self, mock_load): """Function: test_new_attributes Description: Test with new use_uri, use_arg, and auth_db attributes. Arguments: """ mock_load.return_value = self.cfg mongo = mongo_libs.create_instance("cfg_file", "dir_path", mongo_class.Server) self.assertEqual((mongo.use_uri, mongo.use_arg, mongo.auth_db), (self.use_uri, self.use_arg, self.auth_db))
def test_server_instance(self, mock_load): """Function: test_server_instance Description: Test creation of Mongo Server instance. Arguments: """ mock_load.return_value = self.cfg mongo = mongo_libs.create_instance("cfg_file", "dir_path", mongo_class.Server) self.assertEqual((mongo.name, mongo.user, mongo.japd, mongo.host, mongo.port, mongo.auth, mongo.conf_file), (self.name, self.user, self.japd, self.host, self.port, self.auth, self.conf_file))