Пример #1
0
 def initdb(drop):
     if drop:
         click.confirm(
             'This operation will delete the database, do you want to continue?',
             abort=True)
         db.drop_all()
     db.create_all()
     click.echo('Initialized database.')
Пример #2
0
    def make_faker(num_category, num_article, num_comment):
        from blog.fake_data import fake_admin, fake_articles, fake_categories, fake_comments

        db.drop_all()
        db.create_all()
        
        fake_admin()
        fake_categories(num_category)
        fake_articles(num_article)
        fake_comments(num_comment)
Пример #3
0
def client():
    # 设置测试数据库路径和测试环境
    app = create_app('test')

    # 初始化测试数据库
    with app.test_client() as client:
        with app.app_context():
            db.drop_all()
            db.create_all()
            db.session.add(User(username='******', password='******'))
            db.session.commit()
            db.session.close()
        yield client
Пример #4
0
 def forge(category, post, comment):
     """Generate the fake categories, posts and commands."""
     db.drop_all()
     db.create_all()
     click.echo('Generating the admin...')
     fake_admin()
     click.echo('Generating the categories...')
     fake_categories(category)
     click.echo('Generating the posts...')
     fake_posts(post)
     click.echo('Generating the comment...')
     fake_comments(comment)
     click.echo('Done')
Пример #5
0
    def forge(category, post):
        """Generate fake data."""
        from blog.fakes import fake_categories, fake_posts

        db.drop_all()
        db.create_all()

        click.echo('Generating %d categories...' % category)
        fake_categories(category)

        click.echo('Generating %d posts...' % post)
        fake_posts(post)

        click.echo('Done.')
Пример #6
0
    def forge(category, post, comment):
        from blog.fakes import fake_admin, fake_categories, fake_posts, fake_comments

        db.drop_all()
        db.create_all()

        click.echo('Generating the administrator...')
        fake_admin()

        click.echo('Generating %d categories...' % category)
        fake_categories(category)

        click.echo('Generating %d posts...' % post)
        fake_posts(post)

        click.echo('Generating %d comments...' % comment)
        fake_comments(comment)

        click.echo('Done.')
Пример #7
0
    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.')
Пример #8
0
 def setUp(self):
     super(CLITestCase, self).setUp()
     db.drop_all()
Пример #9
0
 def initdb(drop):
     """Initialize the database."""
     if drop:
         db.drop_all()
     db.create_all()
     click.echo('Initialized database.')
Пример #10
0
 def tearDown(self):
     db.drop_all()
     self.context.pop()
Пример #11
0
 def init_database(drop):
     if drop:
         db.drop_all()
     db.crete_all()