本文整理汇总了Python中tests.factories.NodeFactory.web_url_for方法的典型用法代码示例。如果您正苦于以下问题:Python NodeFactory.web_url_for方法的具体用法?Python NodeFactory.web_url_for怎么用?Python NodeFactory.web_url_for使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tests.factories.NodeFactory
的用法示例。
在下文中一共展示了NodeFactory.web_url_for方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestResolveGuid
# 需要导入模块: from tests.factories import NodeFactory [as 别名]
# 或者: from tests.factories.NodeFactory import web_url_for [as 别名]
class TestResolveGuid(OsfTestCase):
def setUp(self):
super(TestResolveGuid, self).setUp()
self.node = NodeFactory()
def test_resolve_guid(self):
res_guid = self.app.get(self.node.web_url_for('node_setting', _guid=True), auth=self.node.creator.auth)
res_full = self.app.get(self.node.web_url_for('node_setting'), auth=self.node.creator.auth)
assert_equal(res_guid.text, res_full.text)
def test_resolve_guid_no_referent(self):
guid = models.Guid.load(self.node._id)
guid.referent = None
guid.save()
res = self.app.get(
self.node.web_url_for('node_setting', _guid=True),
auth=self.node.creator.auth,
expect_errors=True,
)
assert_equal(res.status_code, 404)
@mock.patch('website.project.model.Node.deep_url', None)
def test_resolve_guid_no_url(self):
res = self.app.get(
self.node.web_url_for('node_setting', _guid=True),
auth=self.node.creator.auth,
expect_errors=True,
)
assert_equal(res.status_code, 404)
示例2: test_new_draft_registration_POST
# 需要导入模块: from tests.factories import NodeFactory [as 别名]
# 或者: from tests.factories.NodeFactory import web_url_for [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)
示例3: test_get_wiki_url_pointer_component
# 需要导入模块: from tests.factories import NodeFactory [as 别名]
# 或者: from tests.factories.NodeFactory import web_url_for [as 别名]
def test_get_wiki_url_pointer_component(self):
"""Regression test for issues
https://github.com/CenterForOpenScience/osf/issues/363 and
https://github.com/CenterForOpenScience/openscienceframework.org/issues/574
"""
user = UserFactory()
pointed_node = NodeFactory(creator=user)
project = ProjectFactory(creator=user)
auth = Auth(user=user)
project.add_pointer(pointed_node, auth=auth, save=True)
serialized = _serialize_wiki_toc(project, auth)
assert_equal(
serialized[0]['url'],
pointed_node.web_url_for('project_wiki_page', wname='home', _guid=True)
)
示例4: test_wiki_url_for_component_returns_200
# 需要导入模块: from tests.factories import NodeFactory [as 别名]
# 或者: from tests.factories.NodeFactory import web_url_for [as 别名]
def test_wiki_url_for_component_returns_200(self):
component = NodeFactory(project=self.project, is_public=True)
url = component.web_url_for('project_wiki_page', wname='home')
res = self.app.get(url)
assert_equal(res.status_code, 200)
示例5: TestComponents
# 需要导入模块: from tests.factories import NodeFactory [as 别名]
# 或者: from tests.factories.NodeFactory import web_url_for [as 别名]
class TestComponents(OsfTestCase):
def setUp(self):
super(TestComponents, self).setUp()
self.user = AuthUserFactory()
self.consolidate_auth = Auth(user=self.user)
self.project = ProjectFactory(creator=self.user)
self.project.add_contributor(contributor=self.user, auth=self.consolidate_auth)
# A non-project componenet
self.component = NodeFactory(
category='hypothesis',
creator=self.user,
parent=self.project,
)
self.component.save()
self.component.set_privacy('public', self.consolidate_auth)
self.component.set_privacy('private', self.consolidate_auth)
self.project.save()
self.project_url = self.project.web_url_for('view_project')
def test_can_create_component_from_a_project(self):
res = self.app.get(self.project.url, auth=self.user.auth).maybe_follow()
assert_in('Add Component', res)
def test_can_create_component_from_a_component(self):
res = self.app.get(self.component.url, auth=self.user.auth).maybe_follow()
assert_in('Add Component', res)
def test_sees_parent(self):
res = self.app.get(self.component.url, auth=self.user.auth).maybe_follow()
parent_title = res.html.find_all('h2', class_='node-parent-title')
assert_equal(len(parent_title), 1)
assert_in(self.project.title, parent_title[0].text) # Bs4 will handle unescaping HTML here
def test_delete_project(self):
res = self.app.get(
self.component.url + 'settings/',
auth=self.user.auth
).maybe_follow()
assert_in(
'Delete {0}'.format(self.component.project_or_component),
res
)
def test_cant_delete_project_if_not_admin(self):
non_admin = AuthUserFactory()
self.component.add_contributor(
non_admin,
permissions=['read', 'write'],
auth=self.consolidate_auth,
save=True,
)
res = self.app.get(
self.component.url + 'settings/',
auth=non_admin.auth
).maybe_follow()
assert_not_in(
'Delete {0}'.format(self.component.project_or_component),
res
)
def test_can_configure_comments_if_admin(self):
res = self.app.get(
self.component.url + 'settings/',
auth=self.user.auth,
).maybe_follow()
assert_in('Configure Commenting', res)
def test_cant_configure_comments_if_not_admin(self):
non_admin = AuthUserFactory()
self.component.add_contributor(
non_admin,
permissions=['read', 'write'],
auth=self.consolidate_auth,
save=True,
)
res = self.app.get(
self.component.url + 'settings/',
auth=non_admin.auth
).maybe_follow()
assert_not_in('Configure commenting', res)
def test_components_should_have_component_list(self):
res = self.app.get(self.component.url, auth=self.user.auth)
assert_in('Components', res)
def test_does_show_registration_button(self):
# No registrations on the component
url = self.component.web_url_for('node_registrations')
res = self.app.get(url, auth=self.user.auth)
# New registration button is hidden
assert_in('New Registration', res)