def venues():
        conn = db.get_db()
        cursor = conn.cursor()

        venues = db.find_all(models.Venue, cursor)
        venue_dicts = [venue.to_json(cursor) for venue in venues]
        return json.dumps(venue_dicts, default=str)
def db_cursor():
    flask_app = create_app('foursquare_test', testing=True, debug=True)

    with flask_app.app_context():
        conn = get_db()
        cursor = conn.cursor()

    drop_all_tables(conn, cursor)
    build_records(conn, cursor)
    yield cursor
    with flask_app.app_context():
        close_db()
        conn = get_db()
        cursor = conn.cursor()
        drop_all_tables(conn, cursor)
        close_db()
    def search_venues():
        conn = db.get_db()
        cursor = conn.cursor()

        params = dict(request.args)
        venues = models.Venue.search(params, cursor)
        venue_dicts = [venue.to_json(cursor) for venue in venues]
        return json.dumps(venue_dicts, default=str)
def app():
    flask_app = create_app('mobilegaming_test', testing=True, debug=True)

    with flask_app.app_context():
        conn = db.get_db()
        cursor = conn.cursor()
        db.drop_all_tables(conn, cursor)
        db.reset_all_primarykey(conn, cursor)
        build_records(conn, cursor)

        conn.commit()
        db.close_db()
    yield flask_app

    with flask_app.app_context():
        db.close_db()
        conn = db.get_db()
        cursor = conn.cursor()
        db.drop_all_tables(conn, cursor)
        db.reset_all_primarykey(conn, cursor)
        db.close_db()
Esempio n. 5
0
def app():
    flask_app = create_app('foursquare_test', testing=True, debug=True)

    with flask_app.app_context():
        conn = get_db()
        cursor = conn.cursor()
        drop_records(cursor, conn, 'venues')
        drop_records(cursor, conn, 'categories')
        build_records(conn, cursor)

        conn.commit()
        close_db()
    yield flask_app

    with flask_app.app_context():
        close_db()
        conn = get_db()
        cursor = conn.cursor()
        drop_records(cursor, conn, 'venues')
        drop_records(cursor, conn, 'categories')
        close_db()
Esempio n. 6
0
def app():
    flask_app = create_app()
    flask_app.config['DATABASE'] = 'foursquare_test'

    with flask_app.app_context():
        conn = get_db()
        cursor = conn.cursor()
        drop_records(cursor, conn, 'venues')
        drop_records(cursor, conn, 'categories')
        build_records(conn, cursor)

        conn.commit()
        close_db()
    yield flask_app

    with flask_app.app_context():
        close_db()
        conn = get_db()
        cursor = conn.cursor()
        drop_records(cursor, conn, 'venues')
        drop_records(cursor, conn, 'categories')
        close_db()
    def venue(id):
        conn = db.get_db()
        cursor = conn.cursor()
        venue = db.find(models.Venue, id, cursor)

        return json.dumps(venue.__dict__, default=str)