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 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 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.')