Beispiel #1
0
 def setUp(self):
     """Before each test, set up a blank database"""
     self.project = create_app()
     init_app(self.project, 'test')
     self.app = self.project.test_client()
     with self.project.test_request_context():
         create_db(self.project)
         clear_db(self.project)
Beispiel #2
0
def main():
    # initialize database if it doesn't exist
    current_path = os.path.dirname(os.path.realpath(__file__))
    if not os.path.exists(os.path.join(current_path, "entries.db")):
        create_db()
        print("Database initialized")

    # auto-open the application
    webbrowser.open("http://0.0.0.0:8080/")
    serve(app, port=8080)
Beispiel #3
0
def main():
    """
    initialize mongodb
    create jwt secret if does not exist
    run the webserver
    """

    create_db()
    create_secret()
    (create_app().run(host="0.0.0.0", port=5001, debug=True))
Beispiel #4
0
    def setUp(self):
	''' Sets up the testing environment 
            adds a single category and a single question to it '''
        self.test_client = app.app.test_client()
        app.create_db()
        quest = app.Question("Test Question")
        category = app.Category("Test Category")
        
        app.db.session.add(quest)
        app.db.session.add(category)
        app.db.session.commit()
        qcatassoc = app.QCATAssociation()
        qcatassoc.category_id = quest.id
        qcatassoc.question_id = category.id
        app.db.session.add(qcatassoc)
        app.db.session.commit()
Beispiel #5
0
 def setUp(self):
     app = create_app("settings.TestingConfig")
     self.db = create_db(app)
     create_resources(app)
     self.app = app.test_client()
     with app.app_context():
         create_tables()
Beispiel #6
0
def initdb(config=None):
    """Create DB from scratch"""
    init_app(flask_app, config)
    create_db(flask_app)
from app import create_db

db = create_db()
cur = db.cursor()

cur.execute('''CREATE TABLE users (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    username VARCHAR(32) NOT NULL UNIQUE,
    password VARCHAR(128) NOT NULL
)''')

print("Done")
Beispiel #8
0
        user = register(uid, password)

        for _ in range(10):
            session = login(uid, password)
            logout(session.refresh_token)

        self.assertEqual(Session.find_with_user(user), [])
        for _ in range(10):
            login(uid, password)

        self.assertTrue(terminate_sessions(uid))
        self.assertEqual(Session.find_with_user(user), [])


class TestLogout(TestCase):
    def test_logout(self):

        uid, password = uuid4().hex, uuid4().hex
        user = register(uid, password)

        session = login(uid, password)
        logout(session.refresh_token)

        self.assertEqual(Session.find_with_user(user), [])


if __name__ == '__main__':
    create_db()
    create_secret()
    main()
Beispiel #9
0
def initdb():
    # Note: calling this will drop everything in db
    create_db(app)
Beispiel #10
0
from app import create_app, create_db
from flask_migrate import Migrate

app = create_app()
db = create_db(app)

migrate = Migrate(app, db, compare_type=True)

if __name__ == "__main__":
    app.run(debug=True)
Beispiel #11
0
 def setUp(self):
     """ clear database before each test """
     self.db_fd, app.app.config['DATABASE'] = tempfile.mkstemp()
     app.app.config['TESTING'] = True
     self.app = app.app.test_client()
     app.create_db()
Beispiel #12
0
 def setUpClass(cls):
     app.create_db()
Beispiel #13
0
def deploy():
    """
    部署项目
    """
    create_db()
Beispiel #14
0
def initdb(env='Development'):
    # Note: calling this will drop everything in db
    # on production: heroku run python manage.py initdb -e Production
    app = create_app(env)
    create_db(app)
Beispiel #15
0
def initdb(env='Development'):
    # Note: calling this will drop everything in db
    app = create_app(env, manager=True)
    create_db(app)
Beispiel #16
0
def test_db():
    """
    Testing the DB engine existence
    """
    assert create_db() != None