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


Python NodeFactory.save方法代码示例

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


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

示例1: node_source

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import save [as 别名]
 def node_source(self, user, auth, private_node_one, private_node_two, public_node):
     node_source = NodeFactory(creator=user)
     node_source.add_pointer(private_node_one, auth=auth)
     node_source.add_pointer(private_node_two, auth=auth)
     node_source.add_pointer(public_node, auth=auth)
     node_source.save()
     return node_source
开发者ID:adlius,项目名称:osf.io,代码行数:9,代码来源:test_registration_linked_nodes.py

示例2: setUp

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import save [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

示例3: node_linking

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

示例4: test_is_current_with_single_version

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import save [as 别名]
 def test_is_current_with_single_version(self):
     node = NodeFactory()
     page = NodeWikiPage(page_name='foo', node=node)
     page.save()
     node.wiki_pages_current['foo'] = page._id
     node.wiki_pages_versions['foo'] = [page._id]
     node.save()
     assert page.is_current is True
开发者ID:geeksnglitter,项目名称:osf.io,代码行数:10,代码来源:test_models.py

示例5: child_node_two

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import save [as 别名]
 def child_node_two(self, user, parent_project, institution):
     child_node_two = NodeFactory(
         parent=parent_project,
         creator=user,
         is_public=True)
     child_node_two.affiliated_institutions.add(institution)
     child_node_two.save()
     return child_node_two
开发者ID:CenterForOpenScience,项目名称:osf.io,代码行数:10,代码来源:test_institution_nodes_list.py

示例6: great_grandchild_node_two

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import save [as 别名]
 def great_grandchild_node_two(
         self, user, grandchild_node_two,
         institution
 ):
     great_grandchild_node_two = NodeFactory(
         parent=grandchild_node_two, creator=user, is_public=True)
     great_grandchild_node_two.affiliated_institutions.add(institution)
     great_grandchild_node_two.save()
     return great_grandchild_node_two
开发者ID:CenterForOpenScience,项目名称:osf.io,代码行数:11,代码来源:test_institution_nodes_list.py

示例7: TestValidProject

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

    def setUp(self):
        super(TestValidProject, self).setUp()
        self.project = ProjectFactory()
        self.node = NodeFactory()
        self.auth = Auth(user=self.project.creator)

    def test_populates_kwargs_node(self):
        res = valid_project_helper(pid=self.project._id)
        assert_equal(res['node'], self.project)
        assert_is_none(res['parent'])

    def test_populates_kwargs_node_and_parent(self):
        res = valid_project_helper(pid=self.project._id, nid=self.node._id)
        assert_equal(res['parent'], self.project)
        assert_equal(res['node'], self.node)

    def test_project_not_found(self):
        with assert_raises(HTTPError) as exc_info:
            valid_project_helper(pid='fakepid')
        assert_equal(exc_info.exception.code, 404)

    def test_project_deleted(self):
        self.project.is_deleted = True
        self.project.save()
        with assert_raises(HTTPError) as exc_info:
            valid_project_helper(pid=self.project._id)
        assert_equal(exc_info.exception.code, 410)

    def test_node_not_found(self):
        with assert_raises(HTTPError) as exc_info:
            valid_project_helper(pid=self.project._id, nid='fakenid')
        assert_equal(exc_info.exception.code, 404)

    def test_node_deleted(self):
        self.node.is_deleted = True
        self.node.save()
        with assert_raises(HTTPError) as exc_info:
            valid_project_helper(pid=self.project._id, nid=self.node._id)
        assert_equal(exc_info.exception.code, 410)

    def test_valid_project_as_factory_allow_retractions_is_retracted(self):
        registration = RegistrationFactory(project=self.project)
        registration.retraction = RetractionFactory()
        registration.retraction.state = Sanction.UNAPPROVED
        registration.retraction.save()
        res = as_factory_allow_retractions(pid=registration._id)
        assert_equal(res['node'], registration)

    def test_collection_guid_not_found(self):
        collection = CollectionFactory()
        collection.collect_object(self.project, self.auth.user)
        with assert_raises(HTTPError) as exc_info:
            valid_project_helper(pid=collection._id, nid=collection._id)
        assert_equal(exc_info.exception.code, 404)
开发者ID:CenterForOpenScience,项目名称:osf.io,代码行数:58,代码来源:test_project_decorators.py

示例8: node

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import save [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

示例9: test_affiliated_component_with_affiliated_parent_not_returned

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import save [as 别名]
 def test_affiliated_component_with_affiliated_parent_not_returned(self, app, user, institution, public_node, institution_node_url):
     # version < 2.2
     component = NodeFactory(parent=public_node, is_public=True)
     component.affiliated_institutions.add(institution)
     component.save()
     res = app.get(institution_node_url, auth=user.auth)
     affiliated_node_ids = [node['id'] for node in res.json['data']]
     assert res.status_code == 200
     assert public_node._id in affiliated_node_ids
     assert component._id not in affiliated_node_ids
开发者ID:adlius,项目名称:osf.io,代码行数:12,代码来源:test_institution_nodes_list.py

示例10: public_linking_node_source

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import save [as 别名]
 def public_linking_node_source(
         self, contributor, private_node, public_node):
     public_linking_node_source = NodeFactory(
         is_public=True, creator=contributor)
     public_linking_node_source.add_pointer(
         private_node, auth=Auth(contributor))
     public_linking_node_source.add_pointer(
         public_node, auth=Auth(contributor))
     public_linking_node_source.save()
     return public_linking_node_source
开发者ID:CenterForOpenScience,项目名称:osf.io,代码行数:12,代码来源:test_registration_linked_nodes.py

示例11: test_is_current_with_multiple_versions

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import save [as 别名]
 def test_is_current_with_multiple_versions(self):
     node = NodeFactory()
     ver1 = NodeWikiPage(page_name='foo', node=node)
     ver2 = NodeWikiPage(page_name='foo', node=node)
     ver1.save()
     ver2.save()
     node.wiki_pages_current['foo'] = ver2._id
     node.wiki_pages_versions['foo'] = [ver1._id, ver2._id]
     node.save()
     assert ver1.is_current is False
     assert ver2.is_current is True
开发者ID:geeksnglitter,项目名称:osf.io,代码行数:13,代码来源:test_models.py

示例12: test_affiliated_component_without_affiliated_parent_returned

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import save [as 别名]
 def test_affiliated_component_without_affiliated_parent_returned(self, app, user, institution, public_node, institution_node_url):
     # version 2.2
     node = ProjectFactory(is_public=True)
     component = NodeFactory(parent=node, is_public=True)
     component.affiliated_institutions.add(institution)
     component.save()
     url = '{}?version=2.2'.format(institution_node_url)
     res = app.get(url, auth=user.auth)
     affiliated_node_ids = [item['id'] for item in res.json['data']]
     assert res.status_code == 200
     assert node._id not in affiliated_node_ids
     assert component._id in affiliated_node_ids
开发者ID:adlius,项目名称:osf.io,代码行数:14,代码来源:test_institution_nodes_list.py

示例13: child_node_one

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import save [as 别名]
 def child_node_one(
         self, user, parent_project,
         institution, parent_project_one
 ):
     child_node_one = NodeFactory(
         parent=parent_project,
         title='Friend of {}'.format(
             parent_project_one._id),
         creator=user,
         is_public=True)
     child_node_one.affiliated_institutions.add(institution)
     child_node_one.save()
     return child_node_one
开发者ID:CenterForOpenScience,项目名称:osf.io,代码行数:15,代码来源:test_institution_nodes_list.py

示例14: test_only_add_existent_with_permissions

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import save [as 别名]
    def test_only_add_existent_with_permissions(self):
        node = NodeFactory(creator=self.user)
        node.affiliated_institutions.add(self.institution)
        node.save()
        assert_in(self.institution, self.node1.affiliated_institutions.all())
        assert_in(self.institution, node.affiliated_institutions.all())

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

        assert_equal(res.status_code, 204)
开发者ID:adlius,项目名称:osf.io,代码行数:16,代码来源:test_institution_relationship_nodes.py

示例15: test_user_is_read_write

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import save [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


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