def test_sqlalchemy_config_file(self): open_ihm_config = OpenIHMConfig() config_file = """ [database] superuser = master superuser_password = password driver = mysql+mysqlconnector """ open_ihm_config.readfp(io.BytesIO(config_file)) expected = 'mysql+mysqlconnector://master:password@localhost/openihmdb' self.assertEqual(expected, open_ihm_config.sqlalchemy_superuser_connection_string())
def test_database_config_dbinfo(self): open_ihm_config = OpenIHMConfig() expected = { 'host': 'localhost', 'database': 'openihmdb', 'user': '******', 'password': '******', 'charset': 'utf8', 'use_unicode': True, 'get_warnings': True, } self.assertEqual(expected, open_ihm_config.dbinfo())
def test_database_config(self): open_ihm_config = OpenIHMConfig() expected = { 'host': 'localhost', 'database': 'openihmdb', 'user': '******', 'password': '******', 'port': 3306, 'superuser': '******', 'superuser_password': '', } self.assertEqual(expected, open_ihm_config.database_config())
def __init__(self): config = OpenIHMConfig() self.real_config = config self.test_dir = os.path.dirname(__file__) config_file = os.path.join(self.test_dir, '..', 'test_openihm.cfg') read = config.read(config_file) if len(read) != 1: m = 'Need test_openihm.cfg setup with database parameters' e = unittest.SkipTest(m) raise e Config.set_config(config) self.dbconfig = config.database_config() self.config = DbConfig(**self.dbconfig)
def test_read_config_file_port_default(self): open_ihm_config = OpenIHMConfig() config_file = """ [database] superuser = master superuser_password = password """ open_ihm_config.readfp(io.BytesIO(config_file)) expected = { 'host': 'localhost', 'database': 'openihmdb', 'user': '******', 'password': '******', 'port': 3306, 'superuser': '******', 'superuser_password': '******', } self.assertEqual(expected, open_ihm_config.database_config())
def test_sqlalchemy_config(self): open_ihm_config = OpenIHMConfig() expected = 'mysql+mysqldb://openihm:ihm2010@localhost/openihmdb' self.assertEqual(expected, open_ihm_config.sqlalchemy_connection_string())