本文整理汇总了Python中tests.factories.PreprintFactory.set_privacy方法的典型用法代码示例。如果您正苦于以下问题:Python PreprintFactory.set_privacy方法的具体用法?Python PreprintFactory.set_privacy怎么用?Python PreprintFactory.set_privacy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.factories.PreprintFactory
的用法示例。
在下文中一共展示了PreprintFactory.set_privacy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_fake_project
# 需要导入模块: from tests.factories import PreprintFactory [as 别名]
# 或者: from tests.factories.PreprintFactory import set_privacy [as 别名]
def create_fake_project(creator, n_users, privacy, n_components, name, n_tags, presentation_name, is_registration, is_preprint, preprint_providers):
auth = Auth(user=creator)
project_title = name if name else fake.science_sentence()
if is_preprint:
providers_to_add = []
if preprint_providers:
providers = preprint_providers.split(',')
for provider in providers:
try:
preprint_provider = models.PreprintProvider.find_one(Q('_id', 'eq', provider))
except NoResultsFound:
preprint_provider = PreprintProviderFactory(name=provider)
providers_to_add.append(preprint_provider)
privacy = 'public'
project = PreprintFactory(title=project_title, description=fake.science_paragraph(), creator=creator, providers=providers_to_add)
elif is_registration:
project = RegistrationFactory(title=project_title, description=fake.science_paragraph(), creator=creator)
else:
project = ProjectFactory(title=project_title, description=fake.science_paragraph(), creator=creator)
project.set_privacy(privacy)
for _ in range(n_users):
contrib = create_fake_user()
project.add_contributor(contrib, auth=auth)
if isinstance(n_components, int):
for _ in range(n_components):
NodeFactory(project=project, title=fake.science_sentence(), description=fake.science_paragraph(),
creator=creator)
elif isinstance(n_components, list):
render_generations_from_node_structure_list(project, creator, n_components)
for _ in range(n_tags):
project.add_tag(fake.science_word(), auth=auth)
if presentation_name is not None:
project.add_tag(presentation_name, auth=auth)
project.add_tag('poster', auth=auth)
project.save()
logger.info('Created project: {0}'.format(project.title))
return project