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_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:password@localhost/openheadb'
        self.assertEqual(expected,
                    open_ihm_config.sqlalchemy_superuser_connection_string())
    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': '******',
            'password': '******',
            'port': 3306,
            'superuser': '******',
            'superuser_password': '******',
        }
        self.assertEqual(expected, open_ihm_config.database_config())