예제 #1
0
    def setUp(self):
        os.environ['APP_CONFIG'] = 'project.config.TestConfig'
        self.app = create_app()
        app_config = os.getenv('APP_CONFIG', 'project.config.DevConfig')
        self.app.config.from_object(app_config)
        self.app.config['TESTING'] = True
        self.app.config['DEBUG'] = False
        self.client = self.app.test_client()

        with self.app.app_context():
            init_db()
예제 #2
0
def clear_entries(mode):
    with app.app_context():
        db = get_db()

        database_request = "drop table if exists " + mode + ";"
        db.cursor().execute(database_request)
        db.commit()
        init_db()

        flash('All ' + mode + ' entries were successfully cleared')
        return "OK"
예제 #3
0
def clear_entries(mode):
    with app.app_context():
        db = get_db()

        database_request = "drop table if exists " + mode + ";"
        db.cursor().execute(database_request)
        db.commit()
        init_db()

        flash('All ' + mode + ' entries were successfully cleared')
        return "OK"
예제 #4
0
def client():
    db_fd, project.app.config['DATABASE'] = tempfile.mkstemp()
    project.app.config['TESTING'] = True
    client = project.app.test_client()

    with project.app.app_context():
        project.init_db()

    yield client

    os.close(db_fd)
    os.unlink(project.app.config['DATABASE'])
예제 #5
0
def client():
    db_fd, project.app.config['DATABASE'] = tempfile.mkstemp()
    project.app.config['TESTING'] = True
    client = project.app.test_client()

    with project.app.app_context():
        project.init_db()

    yield client

    os.close(db_fd)
    os.unlink(project.app.config['DATABASE'])
예제 #6
0
    def setUp(self):
        os.environ['APP_CONFIG'] = 'project.config.TestConfig'
        self.app = create_app()
        app_config = os.getenv('APP_CONFIG', 'project.config.DevConfig')
        self.app.config.from_object(app_config)
        self.client = self.app.test_client()

        with self.app.app_context():
            init_db()

        self.token = self.login()
        self.path_test_file = self.app.config['UPLOAD_FOLDER']
        self.headers = {'Authorization': f'Bearer {self.token}'}
from project import app, init_db
init_db()
app.run(debug=True)