예제 #1
0
def deploy():
    db.drop_all()
    db.create_all()
    horror = Genre(
        name="Horror",
        description=
        "Horror Films are unsettling films designed to frighten and panic, cause dread and alarm, and to invoke our hidden worst fears, often in a terrifying, shocking finale, while captivating and entertaining us at the same time in a cathartic experience."
    )
    action = Genre(
        name="Action",
        description=
        "Action film is a genre in which the protagonist or protagonists end up in a series of challenges that typically include violence, extended fighting, physical feats, and frantic chases."
    )
    romantic = Genre(
        name="Romantic",
        description=
        "Romance films or romance movies are romantic love stories recorded in visual media for broadcast in theaters and on TV that focus on passion, emotion, and the affectionate romantic involvement of the main characters and the journey that their genuinely strong, true and pure romantic love takes them through dating, courtship or marriage."
    )
    split = Movie(
        name="Split",
        director="M. Night Shyamalan",
        actors=
        "James McAvoy, Anya Taylor-Joy, Betty Buckley, Haley Lu Richardson",
        description=
        "Split is a 2016 American psychological horror-thriller film written and directed by M. Night Shyamalan and starring James McAvoy, Anya Taylor-Joy, and Betty Buckley. The film follows a man with 23 different personalities who kidnaps and imprisons three teenage girls in an isolated underground facility.",
        genre=horror)
    darkKnight = Movie(
        name="The Dark Knight",
        director=" Christopher Nolan",
        actors=" Christian Bale, Heath Ledger, Aaron Eckhart",
        description=
        "When the menace known as the Joker emerges from his mysterious past, he wreaks havoc and chaos on the people of Gotham, the Dark Knight must accept one of the greatest psychological and physical tests of his ability to fight injustice.",
        genre=action)
    titanic = Movie(
        name="Titanic",
        director="James Cameron",
        actors=" Leonardo DiCaprio, Kate Winslet, Billy Zane",
        description=
        "A seventeen-year-old aristocrat falls in love with a kind but poor artist aboard the luxurious, ill-fated R.M.S. Titanic.",
        genre=romantic)
    db.session.add(horror)
    db.session.add(action)
    db.session.add(romantic)
    db.session.add(split)
    db.session.add(darkKnight)
    db.session.add(titanic)
    db.session.commit()
예제 #2
0
def initdb(env):
    """Initialize the ID database"""
    # Mock environment
    app.config.from_object(getattr(configs, env))

    # Remove socket connection
    if env in ['staging', 'production']:
        remote_url = get_item('credential', f"sql-{env}").get('remote_url')
        secho(remote_url, fg='green')
        app.config['SQLALCHEMY_DATABASE_URI'] = remote_url

    secho(f"Init the db -- {env}", fg='green')
    secho(app.config['SQLALCHEMY_DATABASE_URI'])
    db.drop_all()
    db.create_all()
    first_user = User(username='******',
                      email='*****@*****.**',
                      email_verified=True,
                      password=generate_password_hash('Chicago'),
                      university='Northwestern University')

    db.session.add(first_user)
    db.session.commit()

    # Install base set of subreddits
    for group, subreddits in BASE_SUBREDDITS.items():
        for subreddit in subreddits: 
            if type(subreddit) is tuple:
                sub = Subreddit(name=subreddit[0],
                                description=subreddit[1], 
                                group=group,
                                admin_id=first_user.id)
            else:
                sub = Subreddit(name=subreddit, 
                          group=group,
                          admin_id=first_user.id)
            db.session.add(sub)
    db.session.commit()
예제 #3
0
def test_clean_db(client):
    db.drop_all()
    db.create_all()
예제 #4
0
 def tearDown(self):
     db.session.remove()
     db.drop_all()
예제 #5
0
def db_drop():
    db.drop_all()
    logging.info('Drop DB')