Пример #1
0
 def setUp(self):
     """建立测试环境"""
     self.app = create_app('testing')
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.create_all()
     UserType.insert_usertypes()
     Subject.insert_subjects()
Пример #2
0
def db_rebuild():
    """
    Destroy and rebuild database with fake data.
    """
    # destroy and rebuild tables
    db.reflect()
    db.drop_all()
    db.create_all()

    # insert locations as defined in model
    Location.insert_locations()

    # insert roles as defined in model
    Role.insert_roles()

    # insert geos and usertypes as defined in model
    Geo.insert_geos()
    UserType.insert_user_types()

    # insert education data
    Education.create_education()

    # insert fake admin/test users
    from random import seed
    import forgery_py
    seed()
    test_user_1 = User(email='*****@*****.**',
                       username='******',
                       password='******',
                       app_name='password'.encode('base64'),
                       confirmed=True,
                       name='David Kimaru',
                       location='KE',
                       about_me=forgery_py.lorem_ipsum.sentence(),
                       member_since=forgery_py.date.date(True))
    admin_user = User(email='*****@*****.**',
                      username='******',
                      password='******',
                      app_name='webmaster'.encode('base64'),
                      confirmed=True,
                      name='Web Master',
                      location='UG',
                      about_me=forgery_py.lorem_ipsum.sentence(),
                      member_since=forgery_py.date.date(True))
    db.session.add_all([test_user_1, admin_user])
    db.session.commit()

    # insert fake user data
    # User.generate_fake(60)

    # print results
    inspector = db.inspect(db.engine)
    print('The following tables were created.')
    print('-' * 17)
    for table in inspector.get_table_names():
        print(table)
Пример #3
0
def deploy():
    """Run deployment tasks."""
    from flask.ext.migrate import upgrade

    # migrate database to latest revision
    upgrade()

    # create user roles
    Role.insert_roles()

    # insert geos and usertypes as defined in model
    Geo.insert_geos()
    UserType.insert_user_types()

    # insert education data
    Education.create_education()
Пример #4
0
def deploy():
    """Run deployment tasks."""
    from flask.ext.migrate import upgrade

    # migrate database to latest revision
    upgrade()

    # create user roles
    Role.insert_roles()

    # insert geos and usertypes as defined in model
    Geo.insert_geos()
    UserType.insert_user_types()

    # insert firm types/tiers as defined in model
    FirmType.insert_firm_types()
    FirmTier.insert_firm_tiers()
Пример #5
0
def deploy():
    """Run deployment tasks."""
    from flask.ext.migrate import upgrade

    # migrate database to latest revision
    upgrade()

    # create user roles
    Role.insert_roles()

    # insert geos and usertypes as defined in model
    Geo.insert_geos()
    UserType.insert_user_types()

    # insert firm types/tiers as defined in model
    FirmType.insert_firm_types()
    FirmTier.insert_firm_tiers()
Пример #6
0
def user_type_pretty(user_type):
    return str(UserType(user_type))
Пример #7
0
def setup_general():
    """Runs the set-up needed for both local development and production."""
    Role.insert_roles()
    UserType.insert_user_types()
Пример #8
0
def db_rebuild():
    """
    Destroy and rebuild database with fake data.
    """
    # destroy and rebuild tables
    db.reflect()
    db.drop_all()
    db.create_all()

    # insert roles as defined in model
    Role.insert_roles()

    # insert geos and usertypes as defined in model
    Geo.insert_geos()
    UserType.insert_user_types()

    # insert firm types/tiers as defined in model
    FirmType.insert_firm_types()
    FirmTier.insert_firm_tiers()

    # insert fake admin/test users
    from random import seed
    import forgery_py
    seed()
    test_user_1 = User(email='*****@*****.**',
                       username='******',
                       password='******',
                       confirmed=True,
                       name='Salim Hamed',
                       location='Seattle, WA',
                       about_me=forgery_py.lorem_ipsum.sentence(),
                       member_since=forgery_py.date.date(True))
    test_user_2 = User(email='*****@*****.**',
                       username='******',
                       password='******',
                       confirmed=True,
                       name='Bryan Davis',
                       location='Seattle, WA',
                       about_me=forgery_py.lorem_ipsum.sentence(),
                       member_since=forgery_py.date.date(True))
    test_user_3 = User(email='*****@*****.**',
                       username='******',
                       password='******',
                       confirmed=True,
                       name='Joe Smith',
                       location='San Francisco, CA',
                       about_me=forgery_py.lorem_ipsum.sentence(),
                       member_since=forgery_py.date.date(True))
    test_user_4 = User(email='*****@*****.**',
                       username='******',
                       password='******',
                       confirmed=True,
                       name='Bill Gates',
                       location='Bellevue, WA',
                       about_me=forgery_py.lorem_ipsum.sentence(),
                       member_since=forgery_py.date.date(True))
    admin_user = User(email='*****@*****.**',
                      username='******',
                      password='******',
                      confirmed=True,
                      name='Bill Gates',
                      location='Seattle, WA',
                      about_me=forgery_py.lorem_ipsum.sentence(),
                      member_since=forgery_py.date.date(True))
    db.session.add_all(
        [test_user_1, test_user_2, test_user_3, test_user_4, admin_user])
    db.session.commit()

    # insert fake user data
    User.generate_fake(60)

    # insert fake post data
    Post.generate_fake(400)

    # insert fake followers
    Follow.generate_fake(2000)

    # insert fake firms
    Firm.generate_fake(5000)

    # insert fake companies
    Company.generate_fake(10000)

    # insert fake relationships
    Relationship.generate_fake(60000)

    # print results
    inspector = db.inspect(db.engine)
    print('The following tables were created.')
    print('-' * 17)
    for table in inspector.get_table_names():
        print(table)
Пример #9
0
def db_rebuild():
    """
    Destroy and rebuild database with fake data.
    """
    # destroy and rebuild tables
    db.reflect()
    db.drop_all()
    db.create_all()

    # insert roles as defined in model
    Role.insert_roles()

    # insert geos and usertypes as defined in model
    Geo.insert_geos()
    UserType.insert_user_types()

    # insert firm types/tiers as defined in model
    FirmType.insert_firm_types()
    FirmTier.insert_firm_tiers()

    # insert fake admin/test users
    from random import seed
    import forgery_py
    seed()
    test_user_1 = User(
        email='*****@*****.**',
        username='******',
        password='******',
        confirmed=True,
        name='Salim Hamed',
        location='Seattle, WA',
        about_me=forgery_py.lorem_ipsum.sentence(),
        member_since=forgery_py.date.date(True)
    )
    test_user_2 = User(
        email='*****@*****.**',
        username='******',
        password='******',
        confirmed=True,
        name='Bryan Davis',
        location='Seattle, WA',
        about_me=forgery_py.lorem_ipsum.sentence(),
        member_since=forgery_py.date.date(True)
    )
    test_user_3 = User(
        email='*****@*****.**',
        username='******',
        password='******',
        confirmed=True,
        name='Joe Smith',
        location='San Francisco, CA',
        about_me=forgery_py.lorem_ipsum.sentence(),
        member_since=forgery_py.date.date(True)
    )
    test_user_4 = User(
        email='*****@*****.**',
        username='******',
        password='******',
        confirmed=True,
        name='Bill Gates',
        location='Bellevue, WA',
        about_me=forgery_py.lorem_ipsum.sentence(),
        member_since=forgery_py.date.date(True)
    )
    admin_user = User(
        email='*****@*****.**',
        username='******',
        password='******',
        confirmed=True,
        name='Bill Gates',
        location='Seattle, WA',
        about_me=forgery_py.lorem_ipsum.sentence(),
        member_since=forgery_py.date.date(True)
    )
    db.session.add_all([test_user_1, test_user_2, test_user_3, test_user_4,
                        admin_user])
    db.session.commit()

    # insert fake user data
    User.generate_fake(60)

    # insert fake post data
    Post.generate_fake(400)

    # insert fake followers
    Follow.generate_fake(2000)

    # insert fake firms
    Firm.generate_fake(5000)

    # insert fake companies
    Company.generate_fake(10000)

    # insert fake relationships
    Relationship.generate_fake(60000)

    # print results
    inspector = db.inspect(db.engine)
    print 'The following tables were created.'
    print '-'*17
    for table in inspector.get_table_names():
        print table