def test_prod_config(self): """ Tests if the production config loads correctly """ app = create_app('movieapp.settings.ProdConfig') assert app.config[ 'SQLALCHEMY_DATABASE_URI'] == 'sqlite:///../database2.db' assert app.config['CACHE_TYPE'] == 'simple'
def test_test_config(self): """ Tests if the test config loads correctly """ app = create_app('movieapp.settings.TestConfig') assert app.config['DEBUG'] is True assert app.config['SQLALCHEMY_ECHO'] is True assert app.config['CACHE_TYPE'] == 'null'
def testapp(request): app = create_app('movieapp.settings.TestConfig') client = app.test_client() db.app = app db.create_all() if getattr(request.module, "create_user", True): admin = User('admin', 'supersafepassword', 12, "14242", "student") db.session.add(admin) db.session.commit() def teardown(): db.session.remove() db.drop_all() request.addfinalizer(teardown) return client
def test_dev_config(self): app = create_app('movieapp.settings.DevConfig') assert app.config['DEBUG'] is True assert app.config[ 'SQLALCHEMY_DATABASE_URI'] == 'sqlite:///../database2.db' assert app.config['CACHE_TYPE'] == 'null'
__author__ = 'Guo' from flask_script import Manager, Server from movieapp import create_app from movieapp.models import models app = create_app('movieapp.config.DevConfig') manager = Manager(app) manager.add_command("runserver", Server()) @manager.shell def make_shell_context(): return dict(app=app, db=models.db_user, User=models.User) if __name__ == '__main__': manager.run()
import os from flask_script import Manager, Server from flask_script.commands import ShowUrls, Clean from movieapp import create_app from movieapp.models import db, User, Movie, Rating from movieapp.util import * import pickle from movieapp.recommendation import prepare_data from random import randint import pandas as pd #Default to dev-config env = os.environ.get('MOVIEAPP_ENV', 'dev') app = create_app('movieapp.settings.%sConfig' % env.capitalize()) manager = Manager(app) manager.add_command("server", Server()) manager.add_command("show-urls", ShowUrls()) manager.add_command("clean", Clean()) @manager.shell def make_shell_context(): ''' Creates a ptyhon REPL with several default imports in the context of the app :return: ''' return dict(app=app, db=db, User=User, Movie=Movie, Rating=Rating)