当前位置: 首页>>代码示例>>Python>>正文


Python ProjectFactory.build方法代码示例

本文整理汇总了Python中tests.factories.ProjectFactory.build方法的典型用法代码示例。如果您正苦于以下问题:Python ProjectFactory.build方法的具体用法?Python ProjectFactory.build怎么用?Python ProjectFactory.build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tests.factories.ProjectFactory的用法示例。


在下文中一共展示了ProjectFactory.build方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import build [as 别名]
    def setUp(self):

        super(TestCallbacks, self).setUp()

        self.project = ProjectFactory.build()
        self.consolidated_auth = Auth(self.project.creator)
        self.non_authenticator = UserFactory()
        self.project.save()
        self.project.add_contributor(
            contributor=self.non_authenticator,
            auth=self.consolidated_auth,
        )

        self.project.add_addon('github', auth=self.consolidated_auth)
        self.project.creator.add_addon('github')
        self.external_account = GitHubAccountFactory()
        self.project.creator.external_accounts.append(self.external_account)
        self.project.creator.save()
        self.node_settings = self.project.get_addon('github')
        self.user_settings = self.project.creator.get_addon('github')
        self.node_settings.user_settings = self.user_settings
        self.node_settings.user = 'Queen'
        self.node_settings.repo = 'Sheer-Heart-Attack'
        self.node_settings.external_account = self.external_account
        self.node_settings.save()
        self.node_settings.set_auth
开发者ID:545zhou,项目名称:osf.io,代码行数:28,代码来源:test_models.py

示例2: _set_up_public_project_comment_reports

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import build [as 别名]
 def _set_up_public_project_comment_reports(self):
     self.public_project = ProjectFactory.build(is_public=True, creator=self.user)
     self.public_project.add_contributor(contributor=self.contributor, save=True)
     self.public_comment = CommentFactory.build(node=self.public_project, target=self.public_project, user=self.contributor)
     self.public_comment.reports = {self.user._id: {'category': 'spam', 'text': 'This is spam'}}
     self.public_comment.save()
     self.public_url = '/{}comments/{}/reports/{}/'.format(API_BASE, self.public_comment._id, self.user._id)
开发者ID:mchelen,项目名称:osf.io,代码行数:9,代码来源:test_comment_report_detail.py

示例3: _set_up_public_project_with_file_comment

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import build [as 别名]
 def _set_up_public_project_with_file_comment(self):
     self.public_project = ProjectFactory.build(is_public=True, creator=self.user, comment_level='private')
     self.public_project.add_contributor(self.contributor, save=True)
     self.public_file = test_utils.create_test_file(self.public_project, self.user)
     self.public_comment = CommentFactory(node=self.public_project, target=self.public_file, user=self.user)
     self.public_url = '/{}comments/{}/'.format(API_BASE, self.public_comment._id)
     self.public_comment_payload = self._set_up_payload(self.public_comment._id)
开发者ID:mchelen,项目名称:osf.io,代码行数:9,代码来源:test_comment_detail.py

示例4: test_deleted_projects_excluded

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import build [as 别名]
    def test_deleted_projects_excluded(self):
        project = ProjectFactory.build()
        deleted = ProjectFactory(is_deleted=True)
        project.nodes.append(deleted)
        project.save()

        result = find_nested_projects()
        assert deleted not in result
开发者ID:545zhou,项目名称:osf.io,代码行数:10,代码来源:find_nested_projects.py

示例5: test_find_nested

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import build [as 别名]
    def test_find_nested(self):
        project =ProjectFactory.build()
        nested_project = ProjectFactory()
        project.nodes.append(nested_project)
        project.save()

        result = find_nested_projects()
        assert nested_project in result
        assert project not in result
开发者ID:545zhou,项目名称:osf.io,代码行数:11,代码来源:find_nested_projects.py

示例6: _set_up_private_project_file_comment_reports

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import build [as 别名]
 def _set_up_private_project_file_comment_reports(self):
     self.private_project = ProjectFactory.build(is_public=False, creator=self.user)
     self.private_project.add_contributor(contributor=self.contributor, save=True)
     self.file = test_utils.create_test_file(self.private_project, self.user)
     self.comment = CommentFactory.build(node=self.private_project, target=self.file, user=self.contributor)
     self.comment.reports = self.comment.reports or {}
     self.comment.reports[self.user._id] = {'category': 'spam', 'text': 'This is spam'}
     self.comment.save()
     self.private_url = '/{}comments/{}/reports/'.format(API_BASE, self.comment._id)
开发者ID:mchelen,项目名称:osf.io,代码行数:11,代码来源:test_comment_report_list.py

示例7: _set_up_private_project_comment_reports

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import build [as 别名]
 def _set_up_private_project_comment_reports(self):
     self.private_project = ProjectFactory.build(is_public=False, creator=self.user)
     self.private_project.add_contributor(contributor=self.contributor, save=True)
     self.comment = CommentFactory.build(node=self.private_project, target=self.private_project, user=self.contributor)
     self.comment.reports = {self.user._id: {
         'category': 'spam',
         'text': 'This is spam',
         'date': datetime.utcnow(),
         'retracted': False,
     }}
     self.comment.save()
     self.private_url = '/{}comments/{}/reports/{}/'.format(API_BASE, self.comment._id, self.user._id)
开发者ID:AllisonLBowers,项目名称:osf.io,代码行数:14,代码来源:test_comment_report_detail.py

示例8: _set_up_public_project_comment_reports

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import build [as 别名]
 def _set_up_public_project_comment_reports(self, comment_level='public'):
     self.public_project = ProjectFactory.build(is_public=True, creator=self.user, comment_level=comment_level)
     self.public_project.add_contributor(contributor=self.contributor, save=True)
     self.public_comment = CommentFactory.build(node=self.public_project, user=self.contributor)
     self.public_comment.reports = self.public_comment.reports or {}
     self.public_comment.reports[self.user._id] = {
         'category': 'spam',
         'text': 'This is spam',
         'date': datetime.utcnow(),
         'retracted': False,
     }
     self.public_comment.save()
     self.public_url = '/{}comments/{}/reports/'.format(API_BASE, self.public_comment._id)
开发者ID:digideskio,项目名称:osf.io,代码行数:15,代码来源:test_comment_report_list.py

示例9: _set_up_private_project_file_comment_reports

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import build [as 别名]
 def _set_up_private_project_file_comment_reports(self):
     self.private_project = ProjectFactory.build(is_public=False, creator=self.user)
     self.private_project.add_contributor(contributor=self.contributor, save=True)
     self.file = test_utils.create_test_file(self.private_project, self.user)
     self.comment = CommentFactory.build(node=self.private_project, target=self.file, user=self.contributor)
     self.comment.reports = self.comment.reports or {}
     self.comment.reports[self.user._id] = {
         "category": "spam",
         "text": "This is spam",
         "date": datetime.utcnow(),
         "retracted": False,
     }
     self.comment.save()
     self.private_url = "/{}comments/{}/reports/".format(API_BASE, self.comment._id)
开发者ID:KAsante95,项目名称:osf.io,代码行数:16,代码来源:test_comment_report_list.py

示例10: test_serialize_private_node

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import build [as 别名]
    def test_serialize_private_node(self):
        user = UserFactory()
        auth = Auth(user=user)
        public = ProjectFactory.build(is_public=True)
        public.add_contributor(user)
        public.save()
        private = ProjectFactory(project=public, is_public=False)
        NodeFactory(project=private)
        collector = rubeus.NodeFileCollector(node=public, auth=auth)

        private_dummy = collector._serialize_node(private)
        assert_false(private_dummy['permissions']['edit'])
        assert_false(private_dummy['permissions']['view'])
        assert_equal(private_dummy['name'], 'Private Component')
        assert_equal(len(private_dummy['children']), 0)
开发者ID:AndrewSallans,项目名称:osf.io,代码行数:17,代码来源:test_rubeus.py

示例11: _set_up_public_project_with_comment

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import build [as 别名]
 def _set_up_public_project_with_comment(self):
     self.public_project = ProjectFactory.build(is_public=True, creator=self.user)
     self.public_project.add_contributor(self.contributor, save=True)
     self.public_comment = CommentFactory(node=self.public_project, target=self.public_project, user=self.user)
     self.public_url = '/{}comments/{}/'.format(API_BASE, self.public_comment._id)
     self.public_comment_payload = {
         'data': {
             'id': self.public_comment._id,
             'type': 'comments',
             'attributes': {
                 'content': 'Updating this comment',
                 'deleted': False
             }
         }
     }
开发者ID:mchelen,项目名称:osf.io,代码行数:17,代码来源:test_comment_detail.py

示例12: setUp

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import build [as 别名]
    def setUp(self):

        super(TestRegistrationsWithGithub, self).setUp()
        self.project = ProjectFactory.build()
        self.project.save()
        self.consolidated_auth = Auth(user=self.project.creator)

        self.project.add_addon('github', auth=self.consolidated_auth)
        self.project.creator.add_addon('github')
        self.node_settings = self.project.get_addon('github')
        self.user_settings = self.project.creator.get_addon('github')
        self.node_settings.user_settings = self.user_settings
        self.node_settings.user = 'Queen'
        self.node_settings.repo = 'Sheer-Heart-Attack'
        self.node_settings.save()
开发者ID:lbanner,项目名称:osf.io,代码行数:17,代码来源:test_views.py

示例13: _set_up_public_project_comment_reports

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import build [as 别名]
 def _set_up_public_project_comment_reports(self, comment_level="public"):
     self.public_project = ProjectFactory.build(is_public=True, creator=self.user, comment_level=comment_level)
     self.public_project.add_contributor(contributor=self.contributor, save=True)
     self.public_comment = CommentFactory.build(
         node=self.public_project, target=self.public_project, user=self.contributor
     )
     self.public_comment.reports = self.public_comment.reports or {}
     self.public_comment.reports[self.user._id] = {
         "category": "spam",
         "text": "This is spam",
         "date": datetime.utcnow(),
         "retracted": False,
     }
     self.public_comment.save()
     self.public_url = "/{}comments/{}/reports/".format(API_BASE, self.public_comment._id)
开发者ID:KAsante95,项目名称:osf.io,代码行数:17,代码来源:test_comment_report_list.py

示例14: test_serialize_private_node

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import build [as 别名]
    def test_serialize_private_node(self):
        user = UserFactory()
        auth = Auth(user=user)
        public = ProjectFactory.build(is_public=True)
        # Add contributor with write permissions to avoid admin permission cascade
        public.add_contributor(user, permissions=["read", "write"])
        public.save()
        private = ProjectFactory(parent=public, is_public=False)
        NodeFactory(parent=private)
        collector = rubeus.NodeFileCollector(node=public, auth=auth)

        private_dummy = collector._serialize_node(private)
        assert_false(private_dummy["permissions"]["edit"])
        assert_false(private_dummy["permissions"]["view"])
        assert_equal(private_dummy["name"], "Private Component")
        assert_equal(len(private_dummy["children"]), 0)
开发者ID:Alpani,项目名称:osf.io,代码行数:18,代码来源:test_rubeus.py

示例15: create_fake_project

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import build [as 别名]
def create_fake_project(creator, n_users, privacy, n_components, name, n_tags):
    auth = Auth(user=creator)
    project_title = name if name else fake.science_sentence()
    project = ProjectFactory.build(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)
    for _ in range(n_components):
        NodeFactory(project=project, title=fake.science_sentence(), description=fake.science_paragraph(), creator=creator)
    for _ in range(n_tags):
        project.add_tag(fake.science_word(), auth=auth)

    project.save()
    logger.info('Created project: {0}'.format(project.title))
    return project
开发者ID:AndrewSallans,项目名称:osf.io,代码行数:18,代码来源:create_fakes.py


注:本文中的tests.factories.ProjectFactory.build方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。