def setUp(self): self.app = create_app('testing') self.app_context = self.app.app_context() self.app_context.push() db.create_all() Role.insert_roles() self.client = self.app.test_client(use_cookies=True)
def deploy(): """Run deployment tasks.""" upgrade() Role.insert_roles() User.self_follows()
def forge(user, follow, article, tag, comment, collect): """Generate fake data.""" from blog.fakes import fake_admin, fake_user, fake_follow, fake_article, fake_tag, fake_comment, fake_collect #fake_category, db.drop_all() db.create_all() click.echo('Initializing the roles and permissions...') Role.init_role() click.echo('Generating the administrator...') fake_admin() click.echo('Generating %d users...' % user) fake_user(user) click.echo('Generating %d follows...' % follow) fake_follow(follow) # click.echo('Generating %d categories...' % category) # fake_category(category) click.echo('Generating %d tags...' % tag) fake_tag(tag) click.echo('Generating %d articles...' % article) fake_article(article) click.echo('Generating %d collect...' % collect) fake_collect(collect) click.echo('Generating %d comments...' % comment) fake_comment(comment) click.echo('Done.')
def setUp(self): self.app = create_app(TestingConfig) self.app_context = self.app.app_context() self.app_context.push() db.create_all() Role.insert_roles() self.user = self.register_user() self.post = self.add_post()
def init(): """Initialize Blog.""" click.echo('Initializing the database...') db.create_all() click.echo('Initializing the roles and permissions...') Role.init_role() click.echo('Done.')
def deploy(): """Run deployment tasks.""" from flask_migrate import upgrade from blog.models import Role, User print 'INFO [deploy command] migrate database to latest revision' upgrade() print 'INFO [deploy command] create user roles' Role.insert_roles() print 'INFO [deploy command] create admin user' User.insert_admin()
def setUp(self): app = create_app('testing') self.context = app.test_request_context() self.context.push() self.client = app.test_client() self.runner = app.test_cli_runner() db.create_all() Role.init_role() admin_user = User(email='*****@*****.**', name='Admin', username='******') admin_user.set_password('123') admin_user.set_role() normal_user = User(email='*****@*****.**', name='Normal User', username='******') normal_user.set_password('123') unconfirmed_user = User( email='*****@*****.**', name='Unconfirmed', username='******', ) unconfirmed_user.set_password('123') locked_user = User(email='*****@*****.**', name='Locked User', username='******', locked=True) locked_user.set_password('123') locked_user.lock() blocked_user = User(email='*****@*****.**', name='Blocked User', username='******', active=False) blocked_user.set_password('123') category = Category(name='test category') post = Post(title='test post', body='Test post', category=category) comment = Comment(body='test comment body', post=post, author=normal_user) db.session.add_all([ admin_user, normal_user, unconfirmed_user, locked_user, blocked_user ]) db.session.commit()
def forge(user, post, category, comment): """Generate fake data.""" from blog.fakes import fake_admin, fake_user, fake_categories, fake_post, fake_comment db.drop_all() db.create_all() click.echo('Initializing the roles and permissions...') Role.init_role() click.echo('Generating the administrator...') fake_admin() click.echo('Generating %d users...' % user) fake_user(user) click.echo('Generating %d categories...' % category) fake_categories(category) click.echo('Generating %d posts...' % post) fake_post(post) # click.echo('Generating %d collects...' % collect) # fake_collect(collect) click.echo('Generating %d comments...' % comment) fake_comment(comment) click.echo('Done.')
def setUp(self): self.app = create_app(TestingConfig) self.app_context = self.app.app_context() self.app_context.push() db.create_all() Role.insert_roles()