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': '******',
            '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': '******',
            'password': '******',
            'charset': 'utf8',
            'use_unicode': True,
            'get_warnings': True,
            'unix_socket': '/home/jenkins/mysql/mysql.sock',
        }
        self.assertEqual(expected, open_ihm_config.dbinfo())
    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': '******',
            'password': '******',
            'charset': 'utf8',
            'use_unicode': True,
            'get_warnings': True,
        }
        self.assertEqual(expected, open_ihm_config.dbinfo())

        expected = {
            'host': 'localhost',
            'database': 'openheadb',
            'user': '******',
            'password': '',
            'charset': 'utf8',
            'use_unicode': True,
            'get_warnings': True,
        }
        self.assertEqual(expected, open_ihm_config.superuser_dbinfo())
Esempio n. 3
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']
 def test_database_config_dbinfo(self):
     open_ihm_config = OpenHEAConfig()
     expected = {
         'host': 'localhost',
         'database': 'openheadb',
         'user': '******',
         'password': '******',
         'charset': 'utf8',
         'use_unicode': True,
         'get_warnings': True,
     }
     self.assertEqual(expected, open_ihm_config.dbinfo())