本文整理汇总了Python中tests.factories.NodeFactory.reload方法的典型用法代码示例。如果您正苦于以下问题:Python NodeFactory.reload方法的具体用法?Python NodeFactory.reload怎么用?Python NodeFactory.reload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.factories.NodeFactory
的用法示例。
在下文中一共展示了NodeFactory.reload方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_a_public_component_from_home_page
# 需要导入模块: from tests.factories import NodeFactory [as 别名]
# 或者: from tests.factories.NodeFactory import reload [as 别名]
def test_a_public_component_from_home_page(self):
component = NodeFactory(title='Foobar Component', is_public=True)
# Searches a part of the name
res = self.app.get('/').maybe_follow()
component.reload()
form = res.forms['searchBar']
form['q'] = 'Foobar'
res = form.submit().maybe_follow()
# A link to the component is shown as a result
assert_in('Foobar Component', res)
示例2: test_user_is_admin
# 需要导入模块: from tests.factories import NodeFactory [as 别名]
# 或者: from tests.factories.NodeFactory import reload [as 别名]
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)
示例3: test_user_does_not_have_node
# 需要导入模块: from tests.factories import NodeFactory [as 别名]
# 或者: from tests.factories.NodeFactory import reload [as 别名]
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)
示例4: test_new_draft_registration_POST
# 需要导入模块: from tests.factories import NodeFactory [as 别名]
# 或者: from tests.factories.NodeFactory import reload [as 别名]
def test_new_draft_registration_POST(self):
target = NodeFactory(creator=self.user)
payload = {
'schema_name': self.meta_schema.name,
'schema_version': self.meta_schema.schema_version
}
url = target.web_url_for('new_draft_registration')
res = self.app.post(url, payload, auth=self.user.auth)
assert_equal(res.status_code, http.FOUND)
target.reload()
draft = DraftRegistration.find_one(Q('branched_from', 'eq', target))
assert_equal(draft.registration_schema, self.meta_schema)
示例5: test_user_is_admin_but_not_affiliated
# 需要导入模块: from tests.factories import NodeFactory [as 别名]
# 或者: from tests.factories.NodeFactory import reload [as 别名]
def test_user_is_admin_but_not_affiliated(self):
user = AuthUserFactory()
node = NodeFactory(creator=user)
res = self.app.post_json_api(
self.institution_nodes_url,
self.create_payload(node._id),
expect_errors=True,
auth=user.auth
)
assert_equal(res.status_code, 403)
node.reload()
assert_not_in(self.institution, node.affiliated_institutions)
示例6: test_remove_institution_admin
# 需要导入模块: from tests.factories import NodeFactory [as 别名]
# 或者: from tests.factories.NodeFactory import reload [as 别名]
def test_remove_institution_admin(self):
node = NodeFactory(creator=self.user)
node.primary_institution = self.institution
node.save()
res = self.app.put_json_api(
'/{0}nodes/{1}/relationships/institution/'.format(API_BASE, node._id),
{'data': None},
auth=self.user.auth
)
assert_equal(res.status_code, 204)
node.reload()
assert_equal(node.primary_institution, None)
示例7: test_user_with_nodes_and_permissions
# 需要导入模块: from tests.factories import NodeFactory [as 别名]
# 或者: from tests.factories.NodeFactory import reload [as 别名]
def test_user_with_nodes_and_permissions(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_ids = [node_['id'] for node_ in res.json['data']]
assert_in(node._id, node_ids)
node.reload()
assert_in(self.institution, node.affiliated_institutions)
示例8: test_user_is_read_write
# 需要导入模块: from tests.factories import NodeFactory [as 别名]
# 或者: from tests.factories.NodeFactory import reload [as 别名]
def test_user_is_read_write(self):
user = AuthUserFactory()
user.affiliated_institutions.append(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)
示例9: test_add_some_existant_others_not
# 需要导入模块: from tests.factories import NodeFactory [as 别名]
# 或者: from tests.factories.NodeFactory import reload [as 别名]
def test_add_some_existant_others_not(self):
assert_in(self.institution, self.node1.affiliated_institutions)
node = NodeFactory(creator=self.user)
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, 201)
node.reload()
self.node1.reload()
assert_in(self.institution, self.node1.affiliated_institutions)
assert_in(self.institution, node.affiliated_institutions)
示例10: test_add_some_with_permissions_others_without
# 需要导入模块: from tests.factories import NodeFactory [as 别名]
# 或者: from tests.factories.NodeFactory import reload [as 别名]
def test_add_some_with_permissions_others_without(self):
node1 = NodeFactory(creator=self.user)
node2 = NodeFactory()
res = self.app.post_json_api(
self.institution_nodes_url,
self.create_payload(node1._id, node2._id),
expect_errors=True,
auth=self.user.auth
)
assert_equal(res.status_code, 403)
node1.reload()
node2.reload()
assert_not_in(self.institution, node1.affiliated_institutions)
assert_not_in(self.institution, node2.affiliated_institutions)
示例11: test_user_with_institution_and_permissions_through_patch
# 需要导入模块: from tests.factories import NodeFactory [as 别名]
# 或者: from tests.factories.NodeFactory import reload [as 别名]
def test_user_with_institution_and_permissions_through_patch(self):
self.user.affiliated_institutions.append(self.institution)
self.user.save()
node = NodeFactory(creator=self.user)
res = self.app.patch_json_api(
'/{0}nodes/{1}/relationships/institution/'.format(API_BASE, node._id),
{'data': {'type': 'institutions', 'id': self.institution._id}},
auth=self.user.auth
)
assert_equal(res.status_code, 200)
data = res.json['data']
assert_equal(data['type'], 'institutions')
assert_equal(data['id'], self.institution._id)
node.reload()
assert_equal(node.primary_institution, self.institution)
示例12: test_delete_user_is_admin_but_not_affiliated_with_inst
# 需要导入模块: from tests.factories import NodeFactory [as 别名]
# 或者: from tests.factories.NodeFactory import reload [as 别名]
def test_delete_user_is_admin_but_not_affiliated_with_inst(self):
user = AuthUserFactory()
node = NodeFactory(creator=user)
node.affiliated_institutions.append(self.institution1)
node.save()
assert_in(self.institution1, node.affiliated_institutions)
res = self.app.delete_json_api(
'/{0}nodes/{1}/relationships/institutions/'.format(API_BASE, node._id),
self.create_payload(self.institution1._id),
auth=user.auth,
)
assert_equal(res.status_code, 204)
node.reload()
assert_not_in(self.institution1, node.affiliated_institutions)
示例13: test_delete_user_is_admin_but_not_affiliated_with_inst
# 需要导入模块: from tests.factories import NodeFactory [as 别名]
# 或者: from tests.factories.NodeFactory import reload [as 别名]
def test_delete_user_is_admin_but_not_affiliated_with_inst(self):
user = AuthUserFactory()
node = NodeFactory(creator=user)
node.affiliated_institutions.append(self.institution)
node.save()
assert_in(self.institution, node.affiliated_institutions)
res = self.app.delete_json_api(
self.institution_nodes_url,
self.create_payload(node._id),
auth=user.auth
)
assert_equal(res.status_code, 204)
node.reload()
assert_not_in(self.institution, node.affiliated_institutions)
示例14: test_user_is_read_only
# 需要导入模块: from tests.factories import NodeFactory [as 别名]
# 或者: from tests.factories.NodeFactory import reload [as 别名]
def test_user_is_read_only(self):
user = AuthUserFactory()
user.affiliated_institutions.append(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)
示例15: test_migrate_node
# 需要导入模块: from tests.factories import NodeFactory [as 别名]
# 或者: from tests.factories.NodeFactory import reload [as 别名]
def test_migrate_node(self):
external_admin = UserFactory()
personal_admin = UserFactory()
staff_user = UserFactory()
personal_accounts = [personal_admin.username]
conference = ConferenceFactory(admins=[external_admin, personal_admin])
node = NodeFactory()
node.add_contributor(staff_user)
node.add_contributor(external_admin)
node.add_contributor(personal_admin)
migrate_node(node, conference, staff_user, personal_accounts, dry_run=False)
node.reload()
assert_in(staff_user, node.contributors)
assert_in(external_admin, node.contributors)
assert_not_in(personal_admin, node.contributors)
# Verify that migration is idempotent
migrate_node(node, conference, staff_user, personal_accounts, dry_run=False)
node.reload()
assert_in(staff_user, node.contributors)
assert_in(external_admin, node.contributors)
assert_not_in(personal_admin, node.contributors)