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


Python NodeFactory.add_contributor方法代码示例

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


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

示例1: test__initiate_embargo_adds_admins_on_child_nodes

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_contributor [as 别名]
    def test__initiate_embargo_adds_admins_on_child_nodes(self):
        project_admin = UserFactory()
        project_non_admin = UserFactory()
        child_admin = UserFactory()
        child_non_admin = UserFactory()
        grandchild_admin = UserFactory()

        project = ProjectFactory(creator=project_admin)
        project.add_contributor(project_non_admin, auth=Auth(project.creator), save=True)

        child = NodeFactory(creator=child_admin, parent=project)
        child.add_contributor(child_non_admin, auth=Auth(child.creator), save=True)

        grandchild = NodeFactory(creator=grandchild_admin, parent=child)  # noqa

        registration = RegistrationFactory(project=project)

        embargo = registration._initiate_embargo(
            project.creator,
            self.valid_embargo_end_date,
            for_existing_registration=True
        )
        assert_in(project_admin._id, embargo.approval_state)
        assert_in(child_admin._id, embargo.approval_state)
        assert_in(grandchild_admin._id, embargo.approval_state)

        assert_not_in(project_non_admin._id, embargo.approval_state)
        assert_not_in(child_non_admin._id, embargo.approval_state)
开发者ID:leb2dg,项目名称:osf.io,代码行数:30,代码来源:test_embargoes.py

示例2: test_serialize_node_search_returns_only_visible_contributors

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_contributor [as 别名]
    def test_serialize_node_search_returns_only_visible_contributors(self):
        node = NodeFactory()
        non_visible_contributor = UserFactory()
        node.add_contributor(non_visible_contributor, visible=False)
        serialized_node = _serialize_node_search(node)

        assert_equal(serialized_node['firstAuthor'], node.visible_contributors[0].family_name)
        assert_equal(len(node.visible_contributors), 1)
        assert_false(serialized_node['etal'])
开发者ID:leb2dg,项目名称:osf.io,代码行数:11,代码来源:test_serializers.py

示例3: node

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_contributor [as 别名]
 def node(self, user, write_contrib, read_contrib):
     node = NodeFactory(creator=user)
     node.add_contributor(
         write_contrib,
         permissions=[
             permissions.READ,
             permissions.WRITE])
     node.add_contributor(read_contrib, permissions=[permissions.READ])
     node.save()
     return node
开发者ID:CenterForOpenScience,项目名称:osf.io,代码行数:12,代码来源:test_node_relationship_institutions.py

示例4: node_private

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_contributor [as 别名]
 def node_private(
         self, user_admin_contrib, user_write_contrib,
         user_read_contrib, registration):
     node_private = NodeFactory(creator=user_admin_contrib)
     node_private.add_contributor(
         user_write_contrib,
         auth=Auth(user_admin_contrib))
     node_private.add_contributor(
         user_read_contrib,
         permissions=['read'],
         auth=Auth(user_admin_contrib))
     node_private.add_pointer(registration, auth=Auth(user_admin_contrib))
     return node_private
开发者ID:aaxelb,项目名称:osf.io,代码行数:15,代码来源:test_node_linked_registrations.py

示例5: setUp

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_contributor [as 别名]
    def setUp(self):
        super(LinkedRegistrationsTestCase, self).setUp()
        self.mock_archive = mock.patch('website.archiver.tasks.archive')

        self.non_contributor = AuthUserFactory()
        self.read_contributor = AuthUserFactory()
        self.rw_contributor = AuthUserFactory()
        self.admin_contributor = AuthUserFactory()

        self.public_linked_registration = RegistrationFactory(is_public=True, creator=self.rw_contributor)
        self.private_linked_registration = RegistrationFactory(is_public=False, creator=self.rw_contributor)

        self.mock_archive.start()

        public_node = NodeFactory(creator=self.admin_contributor, is_public=True)
        public_node.add_contributor(self.rw_contributor, auth=Auth(self.admin_contributor))
        public_node.add_contributor(self.read_contributor, permissions=['read'], auth=Auth(self.admin_contributor))
        public_node.add_pointer(self.public_linked_registration, auth=Auth(self.admin_contributor))
        public_node.add_pointer(self.private_linked_registration, auth=Auth(self.rw_contributor))
        public_node.save()
        self.public_registration = public_node.register_node(get_default_metaschema(), Auth(self.admin_contributor), '', None)
        self.public_registration.is_public = True
        self.public_registration.save()

        private_node = NodeFactory(creator=self.admin_contributor)
        private_node.add_contributor(self.rw_contributor, auth=Auth(self.admin_contributor))
        private_node.add_contributor(self.read_contributor, permissions=['read'], auth=Auth(self.admin_contributor))
        private_node.add_pointer(self.public_linked_registration, auth=Auth(self.admin_contributor))
        private_node.add_pointer(self.private_linked_registration, auth=Auth(self.rw_contributor))
        private_node.save()
        self.private_registration = private_node.register_node(get_default_metaschema(), Auth(self.admin_contributor), '', None)
开发者ID:adlius,项目名称:osf.io,代码行数:33,代码来源:test_registration_linked_registrations.py

示例6: test_user_is_read_write

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_contributor [as 别名]
    def test_user_is_read_write(self):
        user = AuthUserFactory()
        user.affiliated_institutions.add(self.institution)
        node = NodeFactory()
        node.add_contributor(user)
        node.save()
        res = self.app.post_json_api(
            self.institution_nodes_url,
            self.create_payload(node._id),
            auth=user.auth
        )

        assert_equal(res.status_code, 201)
        node.reload()
        assert_in(self.institution, node.affiliated_institutions.all())
开发者ID:adlius,项目名称:osf.io,代码行数:17,代码来源:test_institution_relationship_nodes.py

示例7: test_user_is_read_only

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_contributor [as 别名]
    def test_user_is_read_only(self):
        user = AuthUserFactory()
        user.affiliated_institutions.add(self.institution)
        node = NodeFactory()
        node.add_contributor(user, permissions=[permissions.READ])
        node.save()

        res = self.app.post_json_api(
            self.institution_nodes_url,
            self.create_payload(node._id),
            auth=user.auth,
            expect_errors=True
        )

        assert_equal(res.status_code, 403)
        node.reload()
        assert_not_in(self.institution, node.affiliated_institutions.all())
开发者ID:adlius,项目名称:osf.io,代码行数:19,代码来源:test_institution_relationship_nodes.py

示例8: LinkedRegistrationsTestCase

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_contributor [as 别名]
class LinkedRegistrationsTestCase(ApiTestCase):

    def setUp(self):
        super(LinkedRegistrationsTestCase, self).setUp()
        self.registration = RegistrationFactory(is_public=True)

        self.public_node = NodeFactory(is_public=True)
        self.public_node.add_pointer(self.registration, auth=Auth(self.public_node.creator))
        self.public_node.save()

        self.admin_contributor = AuthUserFactory()
        self.rw_contributor = AuthUserFactory()
        self.read_contributor = AuthUserFactory()
        self.non_contributor = AuthUserFactory()

        self.private_node = NodeFactory(creator=self.admin_contributor)
        self.private_node.add_contributor(self.rw_contributor, auth=Auth(self.admin_contributor))
        self.private_node.add_contributor(self.read_contributor, permissions=['read'], auth=Auth(self.admin_contributor))
        self.private_node.add_pointer(self.registration, auth=Auth(self.admin_contributor))
        self.private_node.save()
开发者ID:adlius,项目名称:osf.io,代码行数:22,代码来源:test_node_linked_registrations.py

示例9: test_get_contributors_from_parent

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_contributor [as 别名]
    def test_get_contributors_from_parent(self):
        self.project.add_contributor(
            AuthUserFactory(),
            auth=self.auth,
            visible=True,
        )
        self.project.add_contributor(
            AuthUserFactory(),
            auth=self.auth,
            visible=False,
        )
        component = NodeFactory(parent=self.project, creator=self.user)

        user_already_on_component = AuthUserFactory()
        component.add_contributor(
            user_already_on_component,
            auth=self.auth,
            visible=True,
        )
        self.project.add_contributor(
            user_already_on_component,
            auth=self.auth,
            visible=True,
        )

        self.project.save()
        component.save()

        url = component.api_url_for('get_contributors_from_parent')
        res = self.app.get(url, auth=self.user.auth)
        # Should be all contributors, client-side handles marking
        # contributors that are already added to the child.

        ids = [contrib['id'] for contrib in res.json['contributors']]
        assert_not_in(user_already_on_component.id, ids)
        assert_equal(
            len(res.json['contributors']),
            2,
        )
开发者ID:CenterForOpenScience,项目名称:osf.io,代码行数:41,代码来源:test_contributors_views.py

示例10: test_node_children_related_counts_duplicate_query_results

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_contributor [as 别名]
    def test_node_children_related_counts_duplicate_query_results(self, app, user, public_project,
            private_project, public_project_url):
        user_2 = AuthUserFactory()

        # Adding a child component
        child = NodeFactory(parent=public_project, creator=user, is_public=True, category='software')
        child.add_contributor(user_2, ['read', 'write'], save=True)
        # Adding a grandchild
        NodeFactory(parent=child, creator=user, is_public=True)
        # Adding a node link
        public_project.add_pointer(
            private_project,
            auth=Auth(public_project.creator)
        )
        # Assert NodeChildrenList returns one result
        res = app.get(public_project_url, auth=user.auth)
        assert len(res.json['data']) == 1
        assert res.json['data'][0]['id'] == child._id

        project_url = '/{}nodes/{}/?related_counts=children'.format(API_BASE, public_project._id)
        res = app.get(project_url, auth=user.auth)
        assert res.status_code == 200
        # Verifying related_counts match direct children count (grandchildren not included, pointers not included)
        assert res.json['data']['relationships']['children']['links']['related']['meta']['count'] == 1
开发者ID:CenterForOpenScience,项目名称:osf.io,代码行数:26,代码来源:test_node_children_list.py

示例11: test__initiate_approval_adds_admins_on_child_nodes

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_contributor [as 别名]
    def test__initiate_approval_adds_admins_on_child_nodes(self):
        project_admin = UserFactory()
        project_non_admin = UserFactory()
        child_admin = UserFactory()
        child_non_admin = UserFactory()
        grandchild_admin = UserFactory()

        project = ProjectFactory(creator=project_admin)
        project.add_contributor(project_non_admin, auth=Auth(project.creator), save=True)

        child = NodeFactory(creator=child_admin, parent=project)
        child.add_contributor(child_non_admin, auth=Auth(child.creator), save=True)

        grandchild = NodeFactory(creator=grandchild_admin, parent=child)  # noqa

        registration = RegistrationFactory(project=project)

        approval = registration._initiate_approval(registration.creator)
        assert_in(project_admin._id, approval.approval_state)
        assert_in(child_admin._id, approval.approval_state)
        assert_in(grandchild_admin._id, approval.approval_state)

        assert_not_in(project_non_admin._id, approval.approval_state)
        assert_not_in(child_non_admin._id, approval.approval_state)
开发者ID:CenterForOpenScience,项目名称:osf.io,代码行数:26,代码来源:test_registration_approvals.py

示例12: test_get_children_only_returns_child_nodes_with_admin_permissions

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_contributor [as 别名]
    def test_get_children_only_returns_child_nodes_with_admin_permissions(self):
        user = UserFactory()
        admin_project = ProjectFactory()
        admin_project.add_contributor(user, auth=Auth(admin_project.creator),
                                      permissions=permissions.expand_permissions(permissions.ADMIN))
        admin_project.save()

        admin_component = NodeFactory(parent=admin_project)
        admin_component.add_contributor(user, auth=Auth(admin_component.creator),
                                        permissions=permissions.expand_permissions(permissions.ADMIN))
        admin_component.save()

        read_and_write = NodeFactory(parent=admin_project)
        read_and_write.add_contributor(user, auth=Auth(read_and_write.creator),
                                       permissions=permissions.expand_permissions(permissions.WRITE))
        read_and_write.save()
        read_only = NodeFactory(parent=admin_project)
        read_only.add_contributor(user, auth=Auth(read_only.creator),
                                  permissions=permissions.expand_permissions(permissions.READ))
        read_only.save()

        non_contributor = NodeFactory(parent=admin_project)
        components = _get_children(admin_project, Auth(user))
        assert_equal(len(components), 1)
开发者ID:leb2dg,项目名称:osf.io,代码行数:26,代码来源:test_serializers.py

示例13: TestNodeRelationshipNodeLinks

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_contributor [as 别名]
class TestNodeRelationshipNodeLinks(ApiTestCase):

    def setUp(self):
        super(TestNodeRelationshipNodeLinks, self).setUp()
        self.user = AuthUserFactory()
        self.user2 = AuthUserFactory()
        self.auth = Auth(self.user)
        self.linking_node = NodeFactory(creator=self.user)
        self.admin_node = NodeFactory(creator=self.user)
        self.contributor_node = NodeFactory(creator=self.user2)
        self.contributor_node.add_contributor(self.user, auth=Auth(self.user2))
        self.contributor_node.save()
        self.other_node = NodeFactory()
        self.private_node = NodeFactory(creator=self.user)
        self.public_node = NodeFactory(is_public=True)
        self.linking_node.add_pointer(self.private_node, auth=self.auth)
        self.public_linking_node = NodeFactory(is_public=True, creator=self.user2)
        self.public_linking_node.add_pointer(self.private_node, auth=Auth(self.user2))
        self.public_linking_node.add_pointer(self.public_node, auth=Auth(self.user2))
        self.url = '/{}nodes/{}/relationships/linked_nodes/'.format(API_BASE, self.linking_node._id)
        self.public_url = '/{}nodes/{}/relationships/linked_nodes/'.format(API_BASE, self.public_linking_node._id)

    def payload(self, node_ids=None):
        node_ids = node_ids or [self.admin_node._id]
        env_linked_nodes = [{'type': 'linked_nodes', 'id': node_id} for node_id in node_ids]
        return {"data": env_linked_nodes}

    def test_get_relationship_linked_nodes(self):
        res = self.app.get(
            self.url, auth=self.user.auth
        )

        assert_equal(res.status_code, 200)

        assert_in(self.linking_node.linked_nodes_self_url, res.json['links']['self'])
        assert_in(self.linking_node.linked_nodes_related_url, res.json['links']['html'])
        assert_equal(res.json['data'][0]['id'], self.private_node._id)

    def test_get_public_relationship_linked_nodes_logged_out(self):
        res = self.app.get(self.public_url)

        assert_equal(res.status_code, 200)
        assert_equal(len(res.json['data']), 1)
        assert_equal(res.json['data'][0]['id'], self.public_node._id)

    def test_get_public_relationship_linked_nodes_logged_in(self):
        res = self.app.get(self.public_url, auth=self.user.auth)

        assert_equal(res.status_code, 200)
        assert_equal(len(res.json['data']), 2)

    def test_get_private_relationship_linked_nodes_logged_out(self):
        res = self.app.get(self.url, expect_errors=True)

        assert_equal(res.status_code, 401)

    def test_post_contributing_node(self):
        res = self.app.post_json_api(
            self.url, self.payload([self.contributor_node._id]),
            auth=self.user.auth
        )

        assert_equal(res.status_code, 201)

        ids = [data['id'] for data in res.json['data']]
        assert_in(self.contributor_node._id, ids)
        assert_in(self.private_node._id, ids)

    def test_post_public_node(self):
        res = self.app.post_json_api(
            self.url, self.payload([self.public_node._id]),
            auth=self.user.auth
        )

        assert_equal(res.status_code, 201)

        ids = [data['id'] for data in res.json['data']]
        assert_in(self.public_node._id, ids)
        assert_in(self.private_node._id, ids)

    def test_post_private_node(self):
        res = self.app.post_json_api(
            self.url, self.payload([self.other_node._id]),
            auth=self.user.auth,
            expect_errors=True
        )

        assert_equal(res.status_code, 403)

        res = self.app.get(
            self.url, auth=self.user.auth
        )

        ids = [data['id'] for data in res.json['data']]
        assert_not_in(self.other_node._id, ids)
        assert_in(self.private_node._id, ids)

    def test_post_mixed_nodes(self):
        res = self.app.post_json_api(
            self.url, self.payload([self.other_node._id, self.contributor_node._id]),
#.........这里部分代码省略.........
开发者ID:adlius,项目名称:osf.io,代码行数:103,代码来源:test_node_linked_nodes.py

示例14: TestInstitutionRelationshipNodes

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_contributor [as 别名]

#.........这里部分代码省略.........
        assert_in(node._id, node_ids)

        node.reload()
        assert_in(self.institution, node.affiliated_institutions.all())

    def test_user_does_not_have_node(self):
        node = NodeFactory()
        res = self.app.post_json_api(
            self.institution_nodes_url,
            self.create_payload(node._id),
            expect_errors=True,
            auth=self.user.auth
        )

        assert_equal(res.status_code, 403)
        node.reload()
        assert_not_in(self.institution, node.affiliated_institutions.all())

    def test_user_is_admin(self):
        node = NodeFactory(creator=self.user)
        res = self.app.post_json_api(
            self.institution_nodes_url,
            self.create_payload(node._id),
            auth=self.user.auth
        )
        assert_equal(res.status_code, 201)
        node.reload()
        assert_in(self.institution, node.affiliated_institutions.all())

    def test_user_is_read_write(self):
        user = AuthUserFactory()
        user.affiliated_institutions.add(self.institution)
        node = NodeFactory()
        node.add_contributor(user)
        node.save()
        res = self.app.post_json_api(
            self.institution_nodes_url,
            self.create_payload(node._id),
            auth=user.auth
        )

        assert_equal(res.status_code, 201)
        node.reload()
        assert_in(self.institution, node.affiliated_institutions.all())

    def test_user_is_read_only(self):
        user = AuthUserFactory()
        user.affiliated_institutions.add(self.institution)
        node = NodeFactory()
        node.add_contributor(user, permissions=[permissions.READ])
        node.save()

        res = self.app.post_json_api(
            self.institution_nodes_url,
            self.create_payload(node._id),
            auth=user.auth,
            expect_errors=True
        )

        assert_equal(res.status_code, 403)
        node.reload()
        assert_not_in(self.institution, node.affiliated_institutions.all())

    def test_user_is_admin_but_not_affiliated(self):
        user = AuthUserFactory()
        node = NodeFactory(creator=user)
开发者ID:adlius,项目名称:osf.io,代码行数:70,代码来源:test_institution_relationship_nodes.py

示例15: node_contrib

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_contributor [as 别名]
 def node_contrib(self, user, user_two):
     node_contrib = NodeFactory(creator=user_two)
     node_contrib.add_contributor(user, auth=Auth(user_two))
     node_contrib.save()
     return node_contrib
开发者ID:leb2dg,项目名称:osf.io,代码行数:7,代码来源:test_node_linked_nodes.py


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