<s> import sys <EOL> import os <EOL> sys . path . pop ( <NUM_LIT:0> ) <EOL> sys . path . insert ( <NUM_LIT:0> , os . getcwd ( ) ) <EOL> from flask . ext . security import Security , UserMixin , RoleMixin , SQLAlchemyUserDatastore <EOL> from flask . ext . social import Social , SQLAlchemyConnectionDatastore <EOL> from flask . ext . sqlalchemy import SQLAlchemy <EOL> from tests . test_app import create_app as create_base_app , populate_data <EOL> def create_app ( config = None , debug = True ) : <EOL> app = create_base_app ( config , debug ) <EOL> app . config [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> db = SQLAlchemy ( app ) <EOL> roles_users = db . Table ( '<STR_LIT>' , <EOL> db . Column ( '<STR_LIT>' , db . Integer ( ) , db . ForeignKey ( '<STR_LIT>' ) ) , <EOL> db . Column ( '<STR_LIT>' , db . Integer ( ) , db . ForeignKey ( '<STR_LIT>' ) ) ) <EOL> class Role ( db . Model , RoleMixin ) : <EOL> id = db . Column ( db . Integer ( ) , primary_key = True ) <EOL> name = db . Column ( db . String ( <NUM_LIT> ) , unique = True ) <EOL> description = db . Column ( db . String ( <NUM_LIT:255> ) ) <EOL> class User ( db . Model , UserMixin ) : <EOL> id = db . Column ( db . Integer , primary_key = True ) <EOL> email = db . Column ( db . String ( <NUM_LIT:255> ) , unique = True ) <EOL> password = db . Column ( db . String ( <NUM_LIT> ) ) <EOL> active = db . Column ( db . Boolean ( ) ) <EOL> roles = db . relationship ( '<STR_LIT>' , secondary = roles_users , <EOL> backref = db . backref ( '<STR_LIT>' , lazy = '<STR_LIT>' ) ) <EOL> connections = db . relationship ( '<STR_LIT>' , <EOL> backref = db . backref ( '<STR_LIT:user>' , lazy = '<STR_LIT>' ) ) <EOL> class Connection ( db . Model ) : <EOL> id = db . Column ( db . Integer , primary_key = True ) <EOL> user_id = db . Column ( db . Integer , db . ForeignKey ( '<STR_LIT>' ) ) <EOL> provider_id = db . Column ( db . String ( <NUM_LIT:255> ) ) <EOL> provider_user_id = db . Column ( db . String ( <NUM_LIT:255> ) ) <EOL> access_token = db . Column ( db . String ( <NUM_LIT:255> ) ) <EOL> secret = db . Column ( db . String ( <NUM_LIT:255> ) ) <EOL> display_name = db . Column ( db . String ( <NUM_LIT:255> ) ) <EOL> full_name = db . Column ( db . String ( <NUM_LIT:255> ) ) <EOL> profile_url = db . Column ( db . String ( <NUM_LIT> ) ) <EOL> image_url = db . Column ( db . String ( <NUM_LIT> ) ) <EOL> rank = db . Column ( db . Integer ) <EOL> app . security = Security ( app , SQLAlchemyUserDatastore ( db , User , Role ) ) <EOL> app . social = Social ( app , SQLAlchemyConnectionDatastore ( db , Connection ) ) <EOL> @ app . before_first_request <EOL> def before_first_request ( ) : <EOL> db . drop_all ( ) <EOL> db . create_all ( ) <EOL> populate_data ( ) <EOL> app . get_user = lambda : User . query . first ( ) <EOL> return app <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> create_app ( ) . run ( ) </s>
