本文整理汇总了Python中osf_tests.factories.NodeFactory.add_pointer方法的典型用法代码示例。如果您正苦于以下问题:Python NodeFactory.add_pointer方法的具体用法?Python NodeFactory.add_pointer怎么用?Python NodeFactory.add_pointer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osf_tests.factories.NodeFactory
的用法示例。
在下文中一共展示了NodeFactory.add_pointer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: node_source
# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_pointer [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
示例2: node_linking
# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_pointer [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
示例3: public_linking_node_source
# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_pointer [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
示例4: node_private
# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_pointer [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
示例5: setUp
# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_pointer [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)
示例6: test_linked_nodes_only_return_viewable_nodes
# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_pointer [as 别名]
def test_linked_nodes_only_return_viewable_nodes(
self, app, auth, private_node_one, private_node_two,
public_node, node_ids):
user = AuthUserFactory()
new_linking_node = NodeFactory(creator=user)
private_node_one.add_contributor(user, auth=auth, save=True)
private_node_two.add_contributor(user, auth=auth, save=True)
public_node.add_contributor(user, auth=auth, save=True)
new_linking_node.add_pointer(private_node_one, auth=Auth(user))
new_linking_node.add_pointer(private_node_two, auth=Auth(user))
new_linking_node.add_pointer(public_node, auth=Auth(user))
new_linking_node.save()
new_linking_registration = RegistrationFactory(
project=new_linking_node, creator=user)
res = app.get(
'/{}registrations/{}/linked_nodes/'.format(API_BASE, new_linking_registration._id),
auth=user.auth
)
assert res.status_code == 200
nodes_returned = [linked_node['id']
for linked_node in res.json['data']]
assert len(nodes_returned) == len(node_ids)
for node_id in node_ids:
assert node_id in nodes_returned
# Disconnect contributor_removed so that we don't check in files
# We can remove this when StoredFileNode is implemented in osf-models
with disconnected_from_listeners(contributor_removed):
private_node_two.remove_contributor(user, auth=auth)
public_node.remove_contributor(user, auth=auth)
res = app.get(
'/{}registrations/{}/linked_nodes/'.format(API_BASE, new_linking_registration._id),
auth=user.auth
)
nodes_returned = [
linked_node['id'] for linked_node in res.json['data']
]
assert len(nodes_returned) == len(node_ids) - 1
assert private_node_one._id in nodes_returned
assert public_node._id in nodes_returned
assert private_node_two._id not in nodes_returned
示例7: test_linked_nodes_only_return_viewable_nodes
# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_pointer [as 别名]
def test_linked_nodes_only_return_viewable_nodes(
self, app, user, node_one, node_two, node_public, node_ids):
user_two = AuthUserFactory()
node_linking_two = NodeFactory(creator=user_two)
node_one.add_contributor(user_two, auth=Auth(user), save=True)
node_two.add_contributor(user_two, auth=Auth(user), save=True)
node_public.add_contributor(user_two, auth=Auth(user), save=True)
node_linking_two.add_pointer(node_one, auth=Auth(user_two))
node_linking_two.add_pointer(node_two, auth=Auth(user_two))
node_linking_two.add_pointer(node_public, auth=Auth(user_two))
node_linking_two.save()
res = app.get(
'/{}nodes/{}/linked_nodes/'.format(API_BASE, node_linking_two._id),
auth=user_two.auth
)
assert res.status_code == 200
nodes_returned = [
linked_node['id']for linked_node in res.json['data']
]
assert len(nodes_returned) == len(node_ids)
for node_id in node_ids:
assert node_id in nodes_returned
# Disconnect contributor_removed so that we don't check in files
# We can remove this when StoredFileNode is implemented in osf-models
with disconnected_from_listeners(contributor_removed):
node_two.remove_contributor(user_two, auth=Auth(user))
node_public.remove_contributor(user_two, auth=Auth(user))
res = app.get(
'/{}nodes/{}/linked_nodes/'.format(
API_BASE, node_linking_two._id
),
auth=user_two.auth
)
nodes_returned = [
linked_node['id']for linked_node in res.json['data']
]
assert len(nodes_returned) == len(node_ids) - 1
assert node_one._id in nodes_returned
assert node_public._id in nodes_returned
assert node_two._id not in nodes_returned
示例8: LinkedRegistrationsTestCase
# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_pointer [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()
示例9: test_linked_nodes_only_return_viewable_nodes
# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_pointer [as 别名]
def test_linked_nodes_only_return_viewable_nodes(self):
user = AuthUserFactory()
new_linking_node = NodeFactory(creator=user)
self.linked_node.add_contributor(user, auth=self.auth, save=True)
self.linked_node2.add_contributor(user, auth=self.auth, save=True)
self.public_node.add_contributor(user, auth=self.auth, save=True)
new_linking_node.add_pointer(self.linked_node, auth=Auth(user))
new_linking_node.add_pointer(self.linked_node2, auth=Auth(user))
new_linking_node.add_pointer(self.public_node, auth=Auth(user))
new_linking_node.save()
res = self.app.get(
'/{}nodes/{}/linked_nodes/'.format(API_BASE, new_linking_node._id),
auth=user.auth
)
assert_equal(res.status_code, 200)
nodes_returned = [linked_node['id'] for linked_node in res.json['data']]
assert_equal(len(nodes_returned), len(self.node_ids))
for node_id in self.node_ids:
assert_in(node_id, nodes_returned)
# Disconnect contributor_removed so that we don't check in files
# We can remove this when StoredFileNode is implemented in osf-models
with disconnected_from_listeners(contributor_removed):
self.linked_node2.remove_contributor(user, auth=self.auth)
self.public_node.remove_contributor(user, auth=self.auth)
res = self.app.get(
'/{}nodes/{}/linked_nodes/'.format(API_BASE, new_linking_node._id),
auth=user.auth
)
nodes_returned = [linked_node['id'] for linked_node in res.json['data']]
assert_equal(len(nodes_returned), len(self.node_ids) - 1)
assert_in(self.linked_node._id, nodes_returned)
assert_in(self.public_node._id, nodes_returned)
assert_not_in(self.linked_node2._id, nodes_returned)
示例10: linking_node_source
# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_pointer [as 别名]
def linking_node_source(self, user, auth, private_node, admin_node):
linking_node_source = NodeFactory(creator=user)
linking_node_source.add_pointer(private_node, auth=auth)
linking_node_source.add_pointer(admin_node, auth=auth)
return linking_node_source
示例11: node_public
# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_pointer [as 别名]
def node_public(self, registration):
node_public = NodeFactory(is_public=True)
node_public.add_pointer(registration, auth=Auth(node_public.creator))
node_public.save()
return node_public
示例12: node_linking_public
# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_pointer [as 别名]
def node_linking_public(self, user_two, node_private, node_public):
node_linking_public = NodeFactory(is_public=True, creator=user_two)
node_linking_public.add_pointer(node_private, auth=Auth(user_two))
node_linking_public.add_pointer(node_public, auth=Auth(user_two))
return node_linking_public
示例13: node_linking_private
# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_pointer [as 别名]
def node_linking_private(self, user, node_private):
node_linking_private = NodeFactory(creator=user)
node_linking_private.add_pointer(node_private, auth=Auth(user))
return node_linking_private
示例14: TestNodeLinkedNodes
# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_pointer [as 别名]
class TestNodeLinkedNodes(ApiTestCase):
def setUp(self):
super(TestNodeLinkedNodes, self).setUp()
self.user = AuthUserFactory()
self.auth = Auth(self.user)
self.linking_node = NodeFactory(creator=self.user)
self.linked_node = NodeFactory(creator=self.user)
self.linked_node2 = NodeFactory(creator=self.user)
self.public_node = NodeFactory(is_public=True, creator=self.user)
self.linking_node.add_pointer(self.linked_node, auth=self.auth)
self.linking_node.add_pointer(self.linked_node2, auth=self.auth)
self.linking_node.add_pointer(self.public_node, auth=self.auth)
self.linking_node.save()
self.url = '/{}nodes/{}/linked_nodes/'.format(API_BASE, self.linking_node._id)
self.node_ids = self.linking_node.linked_nodes.values_list('guids___id', flat=True)
def test_linked_nodes_returns_everything(self):
res = self.app.get(self.url, auth=self.user.auth)
assert_equal(res.status_code, 200)
nodes_returned = [linked_node['id'] for linked_node in res.json['data']]
assert_equal(len(nodes_returned), len(self.node_ids))
for node_id in self.node_ids:
assert_in(node_id, nodes_returned)
def test_linked_nodes_only_return_viewable_nodes(self):
user = AuthUserFactory()
new_linking_node = NodeFactory(creator=user)
self.linked_node.add_contributor(user, auth=self.auth, save=True)
self.linked_node2.add_contributor(user, auth=self.auth, save=True)
self.public_node.add_contributor(user, auth=self.auth, save=True)
new_linking_node.add_pointer(self.linked_node, auth=Auth(user))
new_linking_node.add_pointer(self.linked_node2, auth=Auth(user))
new_linking_node.add_pointer(self.public_node, auth=Auth(user))
new_linking_node.save()
res = self.app.get(
'/{}nodes/{}/linked_nodes/'.format(API_BASE, new_linking_node._id),
auth=user.auth
)
assert_equal(res.status_code, 200)
nodes_returned = [linked_node['id'] for linked_node in res.json['data']]
assert_equal(len(nodes_returned), len(self.node_ids))
for node_id in self.node_ids:
assert_in(node_id, nodes_returned)
# Disconnect contributor_removed so that we don't check in files
# We can remove this when StoredFileNode is implemented in osf-models
with disconnected_from_listeners(contributor_removed):
self.linked_node2.remove_contributor(user, auth=self.auth)
self.public_node.remove_contributor(user, auth=self.auth)
res = self.app.get(
'/{}nodes/{}/linked_nodes/'.format(API_BASE, new_linking_node._id),
auth=user.auth
)
nodes_returned = [linked_node['id'] for linked_node in res.json['data']]
assert_equal(len(nodes_returned), len(self.node_ids) - 1)
assert_in(self.linked_node._id, nodes_returned)
assert_in(self.public_node._id, nodes_returned)
assert_not_in(self.linked_node2._id, nodes_returned)
def test_linked_nodes_doesnt_return_deleted_nodes(self):
self.linked_node.is_deleted = True
self.linked_node.save()
res = self.app.get(self.url, auth=self.user.auth)
assert_equal(res.status_code, 200)
nodes_returned = [linked_node['id'] for linked_node in res.json['data']]
assert_equal(len(nodes_returned), len(self.node_ids) - 1)
assert_not_in(self.linked_node._id, nodes_returned)
assert_in(self.linked_node2._id, nodes_returned)
assert_in(self.public_node._id, nodes_returned)
def test_attempt_to_return_linked_nodes_logged_out(self):
res = self.app.get(
self.url, auth=None,
expect_errors=True
)
assert_equal(res.status_code, 401)
示例15: TestNodeRelationshipNodeLinks
# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import add_pointer [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]),
#.........这里部分代码省略.........