Exemple #1
0
 def test_mysql(self, pymysql_mock, get_config_mock):
     connection = mock.MagicMock()
     curs = mock.MagicMock()
     side_effect = [(k, 0) for k in mysql.COLLECT_COUNTERS]
     side_effect.append(None)  # Instead of StopIteration pymsql uses None
     curs.fetchone.side_effect = side_effect
     connection.cursor.return_value = curs
     pymysql_mock.return_value = connection
     result = mysql.collect()
     self.assertEqual(sorted(mysql.COLLECT_COUNTERS),
                      sorted(result.keys()))
     self.assertTrue(all([val == 0 for val in result.values()]))
def get_mysql():
    global mysql_data
    mysql_data = mysql.collect()
def get_mysql():
    global mysql_data
    mysql_data = mysql.collect()