def base(): from app import db db.drop_all() db.create_all() Role.insert_roles() from app.models import User user = User(email='[email protected], username='******', password='******', confirmed=True) db.session.add(user) db.session.commit() Category.generate_fake() Tag.generate_fake() Post.generate_fake(100) BlogInfo.insert_system_indo() # 统计分类和标签的文章数量 Category.category_count() Tag.tags_count() User.articles_count()
def categoryfake(): Category.generate_fake()
def fake(): User.generate_fake() Category.generate_fake() Post.generate_fake() Comment.generate_fake()
def test_02_generate_category(self): """测试批量创建分类""" Category.generate_fake(20) self.assertTrue(Category.query.count() == 20)
def test_10_generate_post(self): """测试批量增加文章""" Tag.generate_fake(40) Category.generate_fake(30) Post.generate_fake() self.assertTrue(Post.query.count() == 30)