def test_mysql_to_dict(self): test_mysql_output = ['+----+------+-----------+------+---------+------+-------+------------------+', '| Id | User | Host | db | Command | Time | State | Info |', '+----+------+-----------+------+---------+------+-------+------------------+', '| 7 | root | localhost | NULL | Query | 0 | init | show processlist |', '+----+------+-----------+------+---------+------+-------+------------------+'] ret = utils.mysql_to_dict(test_mysql_output, 'Info') expected_dict = { 'show processlist': {'Info': 'show processlist', 'db': 'NULL', 'State': 'init', 'Host': 'localhost', 'Command': 'Query', 'User': '******', 'Time': 0, 'Id': 7}} self.assertDictEqual(ret, expected_dict)
def test_mysql_to_dict(self): test_mysql_output = [ "+----+------+-----------+------+---------+------+-------+------------------+", "| Id | User | Host | db | Command | Time | State | Info |", "+----+------+-----------+------+---------+------+-------+------------------+", "| 7 | root | localhost | NULL | Query | 0 | init | show processlist |", "+----+------+-----------+------+---------+------+-------+------------------+", ] ret = utils.mysql_to_dict(test_mysql_output, "Info") expected_dict = { "show processlist": { "Info": "show processlist", "db": "NULL", "State": "init", "Host": "localhost", "Command": "Query", "User": "******", "Time": 0, "Id": 7, } } self.assertDictEqual(ret, expected_dict)