def setUp(self):
        app.config["DBHOST"] = 'localhost'
        app.config["DBPORT"] = 3306
        app.config["DBUSER"] = '******'
        app.config["DBPASS"] = '******'
        app.config['DBNAME'] = 'test_metrics'
        app.config['TESTING'] = True
        self.app = app.test_client()

        db.connect()
        with db.cursor() as cur:
            create_db = "create database if not exists %s " % (app.config["DBNAME"])
            cur.execute(create_db)
            select_db = "use %s " % (app.config['DBNAME'])
            cur.execute(select_db)

            with open(relfile('../schema.sql'), 'r') as schemaFile:
                schema = schemaFile.read().split(';')
                for command in schema:
                    if command:
                        cur.execute(command)
Beispiel #2
0
def before_request():
    db.connect()