コード例 #1
0
    def test_old_connection_unix_port(self):
        open_ihm_config = OpenHEAConfig()
        config_file = """
[database]
superuser = master
superuser_password = password
port = 3307
unix_socket = /home/jenkins/mysql/mysql.sock
        """
        open_ihm_config.readfp(io.BytesIO(config_file))
        sexpected = {
            'host': 'localhost',
            'database': 'openheadb',
            'user': 'master',
            'password': 'password',
            'charset': 'utf8',
            'use_unicode': True,
            'get_warnings': True,
            'unix_socket': '/home/jenkins/mysql/mysql.sock',
        }
        self.assertEqual(sexpected, open_ihm_config.superuser_dbinfo())
        expected = {
            'host': 'localhost',
            'database': 'openheadb',
            'user': 'openhea',
            'password': 'hea2012',
            'charset': 'utf8',
            'use_unicode': True,
            'get_warnings': True,
            'unix_socket': '/home/jenkins/mysql/mysql.sock',
        }
        self.assertEqual(expected, open_ihm_config.dbinfo())
コード例 #2
0
 def test_schema_script_path(self):
     open_ihm_config = OpenHEAConfig()
     # FIXME: might need to use a regex to make this pass
     # on windows?
     expected = 'model/scripts'
     script_path = open_ihm_config.schema_script_path()
     self.assertEqual(expected, script_path[0 - len(expected):])
コード例 #3
0
    def test_database_config_issue_38(self):
        # this issue was caused by not protecting the 
        # default values dictionary so it got broken
        # after using it for one purpose.
        open_ihm_config = OpenHEAConfig()
        expected = {
            'host': 'localhost',
            'database': 'openheadb',
            'user': 'openhea',
            'password': 'hea2012',
            'charset': 'utf8',
            'use_unicode': True,
            'get_warnings': True,
        }
        self.assertEqual(expected, open_ihm_config.dbinfo())

        expected = {
            'host': 'localhost',
            'database': 'openheadb',
            'user': 'root',
            'password': '',
            'charset': 'utf8',
            'use_unicode': True,
            'get_warnings': True,
        }
        self.assertEqual(expected, open_ihm_config.superuser_dbinfo())
コード例 #4
0
 def __init__(self):
     config = OpenHEAConfig()
     self.config = config
     self.test_dir = os.path.dirname(__file__)
     config_file = os.path.join(self.test_dir, '..', 'test_openhea.cfg')
     read = config.read(config_file)
     if len(read) != 1:
         m = 'Need test_openhea.cfg setup with database parameters'
         e = unittest.SkipTest(m)
         raise e
     info = config.dbinfo()
     self.database = info['database']
コード例 #5
0
 def test_database_config_superuser_dbinfo(self):
     open_ihm_config = OpenHEAConfig()
     expected = {
         'host': 'localhost',
         'database': 'openheadb',
         'user': 'root',
         'password': '',
         'charset': 'utf8',
         'use_unicode': True,
         'get_warnings': True,
     }
     self.assertEqual(expected, open_ihm_config.superuser_dbinfo())
コード例 #6
0
    def test_sqlalchemy_config_file(self):
        open_ihm_config = OpenHEAConfig()
        config_file = """
[database]
superuser = master
superuser_password = password
driver = mysql+mysqlconnector
        """
        open_ihm_config.readfp(io.BytesIO(config_file))
        expected = 'mysql+mysqlconnector://master:[email protected]/openheadb'
        self.assertEqual(expected,
                    open_ihm_config.sqlalchemy_superuser_connection_string())
コード例 #7
0
    def test_database_config(self):
        open_ihm_config = OpenHEAConfig()

        expected = {
            'host': 'localhost',
            'database': 'openheadb',
            'user': 'openhea',
            'password': 'hea2012',
            'port': 3306,
            'superuser': 'root',
            'superuser_password': '',
        }
        self.assertEqual(expected, open_ihm_config.database_config())
コード例 #8
0
    def test_read_config_file_port_default(self):
        open_ihm_config = OpenHEAConfig()
        config_file = """
[database]
superuser = master
superuser_password = password
        """
        open_ihm_config.readfp(io.BytesIO(config_file))
        expected = {
            'host': 'localhost',
            'database': 'openheadb',
            'user': 'openhea',
            'password': 'hea2012',
            'port': 3306,
            'superuser': 'master',
            'superuser_password': 'password',
        }
        self.assertEqual(expected, open_ihm_config.database_config())
コード例 #9
0
 def test_sqlalchemy_config(self):
     open_ihm_config = OpenHEAConfig()
     expected = 'mysql+mysqldb://openhea:[email protected]/openheadb'
     self.assertEqual(expected,
                     open_ihm_config.sqlalchemy_connection_string())