import unittest
import logging; logger = logging.getLogger()

from checks.db.mysql import MySql

class TestMySql(unittest.TestCase):
    def setUp(self):
        # This should run on pre-2.7 python so no skiptest
        try:
            import MySQLdb
            self.mysql = MySql(logger)
        except ImportError:
            self.skip = True

    def testChecks(self):
        if not self.skip:
            results = self.mysql.check({"mysql_server": "localhost", "mysql_user": "dog", "mysql_pass": "dog"})
            assert results

if __name__ == '__main__':
    unittest.main()

@@ -88,16 +88,64 @@
 rt MySql
+%0Afrom tests.common import load_check%0Aimport time
 %0A%0Aclass 
@@ -174,24 +174,25 @@
 tCase):%0A
+%0A
     def 
 setUp(se
@@ -187,13 +187,18 @@
 def 
-setUp
+testChecks
 (sel
@@ -213,175 +213,390 @@
     
-# This should run on pre-2.7 python so no skiptest%0A        try:%0A            import MySQLdb%0A            self.mysql = MySql(logger)%0A        except ImportError:%0A 
+agentConfig = %7B 'mysql_server': 'localhost',%0A            'mysql_user': %22datadog%22,%0A            'mysql_pass': %22phQOrbaXem0kP8JHri1qSMRS%22,%0A            'version': '0.1',%0A            'api_key': 'toto' %7D%0A%0A        # Initialize the check from checks.d%0A        c = load_check('mysql', %7B'init_config': %7B%7D, 'instances':%7B%7D%7D,agentConfig)%0A        conf = c.parse_agent_config(agentConfig)%0A
         
    s
@@ -595,220 +595,332 @@
     
-   
 self.
-skip = True%0A%0A    def testChecks(self):%0A        if not self.skip:%0A            results = self.mysql.check(%7B%22mysql_server%22: %22localhost%22, %22mysql_user%22: %22dog%22, %22mysql_pass%22: %22dog%22%7D)%0A            assert results%0A
+check = load_check('mysql', conf, agentConfig)%0A%0A        self.check.run()%0A        metrics = self.check.get_metrics()%0A        self.assertTrue(len(metrics) %3E= 8, metrics)%0A        time.sleep(1)%0A        self.check.run()%0A        metrics = self.check.get_metrics()%0A        self.assertTrue(len(metrics) %3E= 16, metrics)%0A        
 %0Aif 

Fix mysql check to use checks.d version