本文整理汇总了Python中tests.factories.NodeFactory.build方法的典型用法代码示例。如果您正苦于以下问题:Python NodeFactory.build方法的具体用法?Python NodeFactory.build怎么用?Python NodeFactory.build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.factories.NodeFactory
的用法示例。
在下文中一共展示了NodeFactory.build方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_fake_projects
# 需要导入模块: from tests.factories import NodeFactory [as 别名]
# 或者: from tests.factories.NodeFactory import build [as 别名]
def create_fake_projects(creator, depth, num_logs, level=1, parent=None):
#auth = Auth(user=creator)
if depth < 0:
return None
descriptor = choice(descriptors) if (level % 2 == 0) else 'project'
project_title = parent.title + (': ' + CATEGORY_MAP[descriptor]) if (level % 2 == 0) else fake.word()
project = NodeFactory.build(title=project_title, description=fake.sentences(), creator=creator, parent=parent, is_public=True, privacy='public', category=descriptor)
project.save()
for i in range(int(num_logs)):
project.add_log('wiki_updated', {
'node': project._id,
},
Auth(creator),
)
project.save()
nextlevel = level + 1
nextdepth = int(depth) - 1
for i in range(nextlevel):
create_fake_projects(creator, nextdepth, num_logs, nextlevel, project)
return project