<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_peewee . db import Database <EOL> from flask . ext . security import Security , UserMixin , RoleMixin , PeeweeUserDatastore <EOL> from flask . ext . social import Social , PeeweeConnectionDatastore <EOL> from peewee import * <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>' ] = { <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> db = Database ( app ) <EOL> class Role ( db . Model , RoleMixin ) : <EOL> name = TextField ( unique = True ) <EOL> description = TextField ( null = True ) <EOL> class User ( db . Model , UserMixin ) : <EOL> email = TextField ( ) <EOL> password = TextField ( ) <EOL> last_login_at = DateTimeField ( null = True ) <EOL> current_login_at = DateTimeField ( null = True ) <EOL> last_login_ip = TextField ( null = True ) <EOL> current_login_ip = TextField ( null = True ) <EOL> login_count = IntegerField ( null = True ) <EOL> active = BooleanField ( default = True ) <EOL> confirmed_at = DateTimeField ( null = True ) <EOL> class UserRoles ( db . Model ) : <EOL> """<STR_LIT>""" <EOL> user = ForeignKeyField ( User , related_name = '<STR_LIT>' ) <EOL> role = ForeignKeyField ( Role , related_name = '<STR_LIT>' ) <EOL> name = property ( lambda self : self . role . name ) <EOL> description = property ( lambda self : self . role . description ) <EOL> class Connection ( db . Model ) : <EOL> user = ForeignKeyField ( User , related_name = '<STR_LIT>' ) <EOL> provider_id = TextField ( ) <EOL> provider_user_id = TextField ( ) <EOL> access_token = TextField ( ) <EOL> secret = TextField ( null = True ) <EOL> display_name = TextField ( ) <EOL> full_name = TextField ( ) <EOL> profile_url = TextField ( ) <EOL> image_url = TextField ( ) <EOL> rank = IntegerField ( null = True ) <EOL> app . security = Security ( app , PeeweeUserDatastore ( db , User , Role , UserRoles ) ) <EOL> app . social = Social ( app , PeeweeConnectionDatastore ( db , Connection ) ) <EOL> @ app . before_first_request <EOL> def before_first_request ( ) : <EOL> for Model in ( Role , User , UserRoles , Connection ) : <EOL> Model . drop_table ( fail_silently = True ) <EOL> Model . create_table ( fail_silently = True ) <EOL> populate_data ( ) <EOL> app . get_user = lambda : User . select ( ) . get ( ) <EOL> return app <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> create_app ( ) . run ( ) </s>
