Esempio n. 1
0
 def setUp(self):
     db = SQLAlchemy()
     app.config["SQLALCHEMY_DATABASE_URI"] = "mysql://{}:{}@{}/{}".format(
         USER, PASSWORD, HOST, DATABASE)
     app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
     app.app_context().push()
     db.init_app(app)
     with app.app_context():
         db.create_all()
Esempio n. 2
0
def db(app, client, request):
    """ Erase then Create DB """
    database.drop_all()
    database.create_all()
    database.session.commit()

    def fin():
        database.session.remove()

    request.addfinalizer(fin)
    return database
    def setUp(self):
        """
        This is for setting up the test cases with Flask app configuration and cloud database access. This will also init the database from flask_api.py with the app context
        """

        db = SQLAlchemy()
        app.config["SQLALCHEMY_DATABASE_URI"] = "mysql://{}:{}@{}/{}".format(USER, PASSWORD, HOST, DATABASE)
        app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True
        app.app_context().push()
        db.init_app(app)
        with app.app_context():
            db.create_all()
Esempio n. 4
0
    def setUp(self):
        # print(os.path.abspath(os.path.dirname(__file__)))
        app.config['TESTING'] = True
        app.config['WTF_CSRF_ENABLED'] = False
        app.config['DEBUG'] = False
        app.config["SQLALCHEMY_DATABASE_URI"] = 'sqlite:///' + os.path.join(os.path.abspath(os.path.dirname(__file__)), TEST_DB)
        
        app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = True

        self.app = app.test_client()   

        # db.drop_all()
        # db.create_all()
        # self.assertEqual(app.debug, False)

        with self.app.application.app_context():
            db.drop_all()
            db.create_all()
        
        self.populate_users_data()
        self.populate_cars_data()
        self.populate_booking_data()
Esempio n. 5
0
from flask_api import app, db
from flask_api.models import users, apikeys

db.create_all() # makes sure all tables exist

if __name__ == '__main__':
    # use port=80 to remove port requirement in url
	app.run(port=5000, debug=False) # 5000 is default for flask