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


Python ProjectFactory.web_url_for方法代码示例

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


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

示例1: TestExplorePublicActivity

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import web_url_for [as 别名]
class TestExplorePublicActivity(OsfTestCase):

    def setUp(self):
        super(TestExplorePublicActivity, self).setUp()
        self.project = ProjectFactory(is_public=True)
        self.registration = RegistrationFactory(project=self.project)
        self.private_project = ProjectFactory(title="Test private project")
        self.popular_project = ProjectFactory(is_public=True)
        self.popular_registration = RegistrationFactory(project=self.project)

        # Add project to new and noteworthy projects
        self.new_and_noteworthy_links_node = ProjectFactory()
        self.new_and_noteworthy_links_node._id = settings.NEW_AND_NOTEWORTHY_LINKS_NODE
        self.new_and_noteworthy_links_node.add_pointer(self.project, auth=Auth(self.new_and_noteworthy_links_node.creator), save=True)

        # Set up popular projects and registrations
        self.popular_links_node = ProjectFactory()
        self.popular_links_node._id = settings.POPULAR_LINKS_NODE
        self.popular_links_node.add_pointer(self.popular_project, auth=Auth(self.popular_links_node.creator), save=True)

        self.popular_links_registrations = ProjectFactory()
        self.popular_links_registrations._id = settings.POPULAR_LINKS_REGISTRATIONS
        self.popular_links_registrations.add_pointer(self.popular_registration, auth=Auth(self.popular_links_registrations.creator), save=True)

    def tearDown(self):
        super(TestExplorePublicActivity, self).tearDown()
        Node.remove()

    def test_explore_page_loads_when_settings_not_configured(self):

        old_settings_values = settings.POPULAR_LINKS_NODE, settings.NEW_AND_NOTEWORTHY_LINKS_NODE, settings.POPULAR_LINKS_REGISTRATIONS

        settings.POPULAR_LINKS_NODE = 'notanode'
        settings.NEW_AND_NOTEWORTHY_LINKS_NODE = 'alsototallywrong'
        settings.POPULAR_LINKS_REGISTRATIONS = 'nopenope'

        url = self.project.web_url_for('activity')
        res = self.app.get(url)
        assert_equal(res.status_code, 200)

        settings.POPULAR_LINKS_NODE, settings.NEW_AND_NOTEWORTHY_LINKS_NODE, settings.POPULAR_LINKS_REGISTRATIONS = old_settings_values

    def test_new_and_noteworthy_and_popular_nodes_show_in_explore_activity(self):

        url = self.project.web_url_for('activity')
        res = self.app.get(url)

        # New and Noteworthy
        assert_in(str(self.project.title), res)
        assert_in(str(self.project.date_created.date()), res)
        assert_in(str(self.registration.title), res)
        assert_in(str(self.registration.registered_date.date()), res)
        assert_not_in(str(self.private_project.title), res)

        # Popular Projects and Registrations
        assert_in(str(self.popular_project.title), res)
        assert_in(str(self.popular_project.date_created.date()), res)
        assert_in(str(self.popular_registration.title), res)
        assert_in(str(self.popular_registration.registered_date.date()), res)
开发者ID:baylee-d,项目名称:osf.io,代码行数:61,代码来源:webtest_tests.py

示例2: TestWikiCompare

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import web_url_for [as 别名]
class TestWikiCompare(OsfTestCase):

    def setUp(self):
        super(TestWikiCompare, self).setUp()

        self.project = ProjectFactory(is_public=True)
        api_key = ApiKeyFactory()
        self.project.creator.api_keys.append(api_key)
        self.project.creator.save()
        self.consolidate_auth = Auth(user=self.project.creator, api_key=api_key)
        self.auth = ('test', api_key._primary_key)
        self.project.update_node_wiki('home', 'hello world', self.consolidate_auth)
        self.wiki = self.project.get_wiki_page('home')

    def test_compare_wiki_page_valid(self):
        self.project.update_node_wiki('home', 'Hello World', self.consolidate_auth)

        url_v1_to_v2 = self.project.web_url_for('project_wiki_compare', wname='home', wver=1)
        res = self.app.get(url_v1_to_v2)
        comparison_v1_to_v2 = \
            '<span style="background:#D16587; font-size:1.5em;">h</span>' \
            '<span style="background:#4AA02C; font-size:1.5em; ">H</span>ello ' \
            '<span style="background:#D16587; font-size:1.5em;">w</span>' \
            '<span style="background:#4AA02C; font-size:1.5em; ">W</span>orld'
        assert_equal(res.status_int, http.OK)
        assert_true(comparison_v1_to_v2 in res.body)

        url_v2_to_v2 = self.project.web_url_for('project_wiki_compare', wname='home', wver=2)
        res = self.app.get(url_v2_to_v2)
        comparison_v2_to_v2 = 'Hello World'
        assert_equal(res.status_int, http.OK)
        assert_true(comparison_v2_to_v2 in res.body)

    def test_compare_wiki_page_sanitized(self):
        content_js_script = '<script>alert(''a problem'');</script>'
        self.project.update_node_wiki('home', content_js_script, self.consolidate_auth)

        url_v1_to_v2 = self.project.web_url_for('project_wiki_compare', wname='home', wver=1)
        res = self.app.get(url_v1_to_v2)
        comparison_v1_to_v2 = \
            '<span style="background:#D16587; font-size:1.5em;">h</span>' \
            '<span style="background:#4AA02C; font-size:1.5em; ">&lt;script&gt;al</span>e' \
            '<span style="background:#4AA02C; font-size:1.5em; ">rt(''a prob</span>l' \
            '<span style="background:#D16587; font-size:1.5em;">lo wo</span>' \
            '<span style="background:#4AA02C; font-size:1.5em; ">em'');</span>r' \
            '<span style="background:#D16587; font-size:1.5em;">ld</span>' \
            '<span style="background:#4AA02C; font-size:1.5em; ">ipt&gt;</span>'
        assert_equal(res.status_int, http.OK)
        assert_true(content_js_script not in res.body)
        assert_true(comparison_v1_to_v2 in res.body)

        url_v2_to_v2 = self.project.web_url_for('project_wiki_compare', wname='home', wver=2)
        res = self.app.get(url_v2_to_v2)
        comparison_v2_to_v2 = '&lt;script&gt;alert(''a problem'');&lt;/script&gt;'
        assert_equal(res.status_int, http.OK)
        assert_true(content_js_script not in res.body)
        assert_true(comparison_v2_to_v2 in res.body)
开发者ID:AndrewSallans,项目名称:osf.io,代码行数:59,代码来源:test_wiki.py

示例3: test_project_dashboard_shows_no_wiki_content_text

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import web_url_for [as 别名]
 def test_project_dashboard_shows_no_wiki_content_text(self):
     # Regression test for:
     # https://github.com/CenterForOpenScience/openscienceframework.org/issues/1104
     project = ProjectFactory(creator=self.user)
     url = project.web_url_for('view_project')
     res = self.app.get(url, auth=self.user.auth)
     assert_in('No wiki content', res)
开发者ID:AndrewSallans,项目名称:osf.io,代码行数:9,代码来源:test_wiki.py

示例4: test_build_dropbox_urls_file

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import web_url_for [as 别名]
 def test_build_dropbox_urls_file(self):
     node = ProjectFactory()
     fake_metadata = mock_responses['metadata_single']
     result = utils.build_dropbox_urls(fake_metadata, node)
     path = utils.clean_path(fake_metadata['path'])
     assert_equal(
         result['download'],
         node.web_url_for('dropbox_download', path=path)
     )
     assert_equal(
         result['view'],
         node.web_url_for('dropbox_view_file', path=path)
     )
     assert_equal(
         result['delete'],
         node.api_url_for('dropbox_delete_file', path=path)
     )
开发者ID:AndrewSallans,项目名称:osf.io,代码行数:19,代码来源:test_utils.py

示例5: RegistrationsTestBase

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import web_url_for [as 别名]
class RegistrationsTestBase(OsfTestCase):
    def setUp(self):
        super(RegistrationsTestBase, self).setUp()

        self.user = AuthUserFactory()
        self.auth = Auth(self.user)
        self.node = ProjectFactory(creator=self.user)
        self.non_admin = AuthUserFactory()
        self.node.add_contributor(
            self.non_admin,
            permissions.DEFAULT_CONTRIBUTOR_PERMISSIONS,
            auth=self.auth,
            save=True
        )
        self.non_contrib = AuthUserFactory()

        MetaSchema.remove()
        ensure_schemas()
        self.meta_schema = MetaSchema.find_one(
            Q('name', 'eq', 'Open-Ended Registration') &
            Q('schema_version', 'eq', 2)
        )
        self.draft = DraftRegistrationFactory(
            initiator=self.user,
            branched_from=self.node,
            registration_schema=self.meta_schema,
            registration_metadata={
                'summary': {'value': 'Some airy'}
            }
        )

        current_month = dt.datetime.now().strftime("%B")
        current_year = dt.datetime.now().strftime("%Y")

        valid_date = dt.datetime.now() + dt.timedelta(days=180)
        self.embargo_payload = {
            u'embargoEndDate': unicode(valid_date.strftime('%a, %d, %B %Y %H:%M:%S')) + u' GMT',
            u'registrationChoice': 'embargo'
        }
        self.invalid_embargo_date_payload = {
            u'embargoEndDate': u"Thu, 01 {month} {year} 05:00:00 GMT".format(
                month=current_month,
                year=str(int(current_year) - 1)
            ),
            u'registrationChoice': 'embargo'
        }
        self.immediate_payload = {
            'registrationChoice': 'immediate'
        }
        self.invalid_payload = {
            'registrationChoice': 'foobar'
        }

    def draft_url(self, view_name):
        return self.node.web_url_for(view_name, draft_id=self.draft._id)

    def draft_api_url(self, view_name):
        return self.node.api_url_for(view_name, draft_id=self.draft._id)
开发者ID:545zhou,项目名称:osf.io,代码行数:60,代码来源:base.py

示例6: TestGoogleDriveUtils

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import web_url_for [as 别名]
class TestGoogleDriveUtils(OsfTestCase):

    def setUp(self):
        super(TestGoogleDriveUtils, self).setUp()
        self.user = AuthUserFactory()
        self.user.add_addon('googledrive')
        self.project = ProjectFactory(creator=self.user)
        self.project.add_addon('googledrive', Auth(self.user))
        self.node_settings = self.project.get_addon('googledrive')
        self.user_settings = self.user.get_addon('googledrive')
        oauth_settings = GoogleDriveOAuthSettingsFactory()
        self.user_settings.oauth_settings = oauth_settings
        self.node_settings.user_settings = self.user_settings
        self.node_settings.folder_id = '09120912'
        self.node_settings.folder_path = 'foo/bar'

        self.user_settings.save()
        self.node_settings.save()
        # Log user in
        self.app.authenticate(*self.user.auth)

    def test_serialize_settings_helper_returns_correct_urls(self):
        result = serialize_settings(self.node_settings, self.user)
        urls = result['urls']

        assert_equal(urls['files'], self.project.web_url_for('collect_file_trees'))
        assert_equal(urls['config'], self.project.api_url_for('googledrive_config_put'))
        assert_equal(urls['deauthorize'], self.project.api_url_for('googledrive_deauthorize'))
        assert_equal(urls['importAuth'], self.project.api_url_for('googledrive_import_user_auth'))
        # Includes endpoint for fetching folders only
        # NOTE: Querystring params are in camelCase
        assert_equal(urls['get_folders'], self.project.api_url_for('googledrive_folders'))

    def test_serialize_settings_helper_returns_correct_auth_info(self):
        self.user_settings.access_token = 'abc123'
        result = serialize_settings(self.node_settings, self.user)
        assert_equal(result['nodeHasAuth'], self.node_settings.has_auth)
        assert_true(result['userHasAuth'])
        assert_true(result['userIsOwner'])

    def test_serialize_settings_for_user_no_auth(self):
        no_addon_user = AuthUserFactory()
        result = serialize_settings(self.node_settings, no_addon_user)
        assert_false(result['userIsOwner'])
        assert_false(result['userHasAuth'])

    def test_googledrive_import_user_auth_returns_serialized_settings(self):
        self.node_settings.user_settings = None
        self.node_settings.save()
        url = api_url_for('googledrive_import_user_auth', pid=self.project._primary_key)
        res = self.app.put(url, auth=self.user.auth)
        self.project.reload()
        self.node_settings.reload()

        expected_result = serialize_settings(self.node_settings, self.user)
        result = res.json['result']
        assert_equal(result, expected_result)
开发者ID:KerryKDiehl,项目名称:osf.io,代码行数:59,代码来源:test_views.py

示例7: TestViewHelpers

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import web_url_for [as 别名]
class TestViewHelpers(OsfTestCase):

    def setUp(self):
        super(TestViewHelpers, self).setUp()
        self.project = ProjectFactory()
        self.wname = 'New page'
        self.project.update_node_wiki(self.wname, 'some content', Auth(self.project.creator))

    def test_get_wiki_web_urls(self):
        urls = _get_wiki_web_urls(self.project, self.wname)
        assert_equal(urls['compare'], self.project.web_url_for('project_wiki_compare',
                wname=self.wname, wver=1, _guid=True))
        assert_equal(urls['edit'], self.project.web_url_for('project_wiki_edit', wname=self.wname, _guid=True))
        assert_equal(urls['home'], self.project.web_url_for('project_wiki_home', _guid=True))
        assert_equal(urls['page'], self.project.web_url_for('project_wiki_page', wname=self.wname, _guid=True))

    def test_get_wiki_api_urls(self):
        urls = _get_wiki_api_urls(self.project, self.wname)
        assert_equal(urls['delete'], self.project.api_url_for('project_wiki_delete', wname=self.wname))
        assert_equal(urls['rename'], self.project.api_url_for('project_wiki_rename', wname=self.wname))
开发者ID:AndrewSallans,项目名称:osf.io,代码行数:22,代码来源:test_wiki.py

示例8: test_links

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import web_url_for [as 别名]
 def test_links(self):
     user = AuthUserFactory()
     project = ProjectFactory(creator=user)
     wiki = NodeWikiFactory(
         content='[[wiki2]]',
         user=user,
         node=project,
     )
     assert_in(
         project.web_url_for('project_wiki_page', wname='wiki2'),
         wiki.html(project),
     )
开发者ID:AndrewSallans,项目名称:osf.io,代码行数:14,代码来源:test_wiki.py

示例9: TestComponents

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory 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)
开发者ID:Alpani,项目名称:osf.io,代码行数:54,代码来源:webtest_tests.py

示例10: TestPrivateLinkView

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import web_url_for [as 别名]
class TestPrivateLinkView(OsfTestCase):

    def setUp(self):
        super(TestPrivateLinkView, self).setUp()
        self.user = AuthUserFactory()  # Is NOT a contributor
        self.project = ProjectFactory(is_public=False)
        self.link = PrivateLinkFactory(anonymous=True)
        self.link.nodes.append(self.project)
        self.link.save()
        self.project_url = self.project.web_url_for('view_project')

    def test_anonymous_link_hide_contributor(self):
        res = self.app.get(self.project_url, {'view_only': self.link.key})
        assert_in("Anonymous Contributors", res.body)
        assert_not_in(self.user.fullname, res)

    def test_anonymous_link_hides_citations(self):
        res = self.app.get(self.project_url, {'view_only': self.link.key})
        assert_not_in('Citation:', res)

    def test_no_warning_for_read_only_user_with_valid_link(self):
        link2 = PrivateLinkFactory(anonymous=False)
        link2.nodes.append(self.project)
        link2.save()
        self.project.add_contributor(
            self.user,
            permissions=['read'],
            save=True,
        )
        res = self.app.get(self.project_url, {'view_only': link2.key},
                           auth=self.user.auth)
        assert_not_in(
            "is being viewed through a private, view-only link. "
            "Anyone with the link can view this project. Keep "
            "the link safe.",
            res.body
        )

    def test_no_warning_for_read_only_user_with_invalid_link(self):
        self.project.add_contributor(
            self.user,
            permissions=['read'],
            save=True,
        )
        res = self.app.get(self.project_url, {'view_only': "not_valid"},
                           auth=self.user.auth)
        assert_not_in(
            "is being viewed through a private, view-only link. "
            "Anyone with the link can view this project. Keep "
            "the link safe.",
            res.body
        )
开发者ID:baylee-d,项目名称:osf.io,代码行数:54,代码来源:webtest_tests.py

示例11: TestExplorePublicActivity

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import web_url_for [as 别名]
class TestExplorePublicActivity(OsfTestCase):
    def setUp(self):
        super(TestExplorePublicActivity, self).setUp()
        self.project = ProjectFactory(is_public=True)
        self.registration = RegistrationFactory(project=self.project)
        self.private_project = ProjectFactory(title="Test private project")

    def test_newest_public_project_and_registrations_show_in_explore_activity(self):
        url = self.project.web_url_for("activity")
        res = self.app.get(url)

        assert_in(str(self.project.title), res)
        assert_in(str(self.project.date_created.date()), res)
        assert_in(str(self.registration.title), res)
        assert_in(str(self.registration.registered_date.date()), res)
        assert_not_in(str(self.private_project.title), res)
开发者ID:Alpani,项目名称:osf.io,代码行数:18,代码来源:webtest_tests.py

示例12: TestExplorePublicActivity

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import web_url_for [as 别名]
class TestExplorePublicActivity(OsfTestCase):

    def setUp(self):
        super(TestExplorePublicActivity, self).setUp()
        self.project = ProjectFactory(is_public=True)
        self.registration = RegistrationFactory(project=self.project)
        self.private_project = ProjectFactory(title="Test private project")

    @mock.patch('website.discovery.views.KeenClient')
    def test_newest_public_project_and_registrations_show_in_explore_activity(self, mock_client):

        mock_client.count.return_value = {
            'result': [
                {
                    'result': 5,
                    'node.id': self.project._id
                },
                {
                    'result': 5,
                    'node.id': self.registration._id
                }
            ]
        }

        mock_client.count_unique.return_value = {
            'result': [
                {
                    'result': 2,
                    'node.id': self.project._id
                },
                {
                    'result': 2,
                    'node.id': self.registration._id
                }
            ]
        }

        url = self.project.web_url_for('activity')
        res = self.app.get(url)

        assert_in(str(self.project.title), res)
        assert_in(str(self.project.date_created.date()), res)
        assert_in(str(self.registration.title), res)
        assert_in(str(self.registration.registered_date.date()), res)
        assert_not_in(str(self.private_project.title), res)
开发者ID:atelic,项目名称:osf.io,代码行数:47,代码来源:webtest_tests.py

示例13: TestPrivateLinkView

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import web_url_for [as 别名]
class TestPrivateLinkView(OsfTestCase):

    def setUp(self):
        super(TestPrivateLinkView, self).setUp()
        self.user = AuthUserFactory()  # Is NOT a contributor
        self.project = ProjectFactory(is_public=False)
        self.link = PrivateLinkFactory(anonymous=True)
        self.link.nodes.append(self.project)
        self.link.save()
        self.project_url = self.project.web_url_for('view_project')

    def test_anonymous_link_hide_contributor(self):
        res = self.app.get(self.project_url, {'view_only': self.link.key})
        assert_in("Anonymous Contributors", res.body)
        assert_not_in(self.user.fullname, res)

    def test_anonymous_link_hides_citations(self):
        res = self.app.get(self.project_url, {'view_only': self.link.key})
        assert_not_in('Citation:', res)
开发者ID:AndrewSallans,项目名称:osf.io,代码行数:21,代码来源:webtest_tests.py

示例14: test_POST_register_embargo_does_not_make_project_or_children_public

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import web_url_for [as 别名]
    def test_POST_register_embargo_does_not_make_project_or_children_public(self, mock_enqueue):
        public_project = ProjectFactory(creator=self.user, is_public=True)
        component = NodeFactory(
            creator=self.user,
            parent=public_project,
            title='Component',
            is_public=True
        )
        subproject = ProjectFactory(
            creator=self.user,
            parent=public_project,
            title='Subproject',
            is_public=True
        )
        subproject_component = NodeFactory(
            creator=self.user,
            parent=subproject,
            title='Subcomponent',
            is_public=True
        )
        res = self.app.post(
            public_project.api_url_for('node_register_template_page_post', template=u'Open-Ended_Registration'),
            self.valid_embargo_payload,
            content_type='application/json',
            auth=self.user.auth
        )
        public_project.reload()
        assert_equal(res.status_code, 201)
        assert_equal(res.json['urls']['registrations'], public_project.web_url_for('node_registrations'))

        # Last node directly registered from self.project
        registration = Node.load(public_project.node__registrations[-1])

        assert_true(registration.is_registration)
        assert_false(registration.is_public)
        assert_true(registration.is_pending_embargo_for_existing_registration)
        assert_is_not_none(registration.embargo)

        for node in registration.get_descendants_recursive():
            assert_true(node.is_registration)
            assert_false(node.is_public)
开发者ID:ZobairAlijan,项目名称:osf.io,代码行数:43,代码来源:test_registration_embargoes.py

示例15: test_GET_disapprove_with_valid

# 需要导入模块: from tests.factories import ProjectFactory [as 别名]
# 或者: from tests.factories.ProjectFactory import web_url_for [as 别名]
    def test_GET_disapprove_with_valid(self):
        project = ProjectFactory(creator=self.user)
        registration = RegistrationFactory(project=project)
        registration.embargo_registration(
            self.user,
            datetime.datetime.utcnow() + datetime.timedelta(days=10)
        )
        registration.save()
        assert_true(registration.is_pending_embargo)

        rejection_token = registration.embargo.approval_state[self.user._id]['rejection_token']

        res = self.app.get(
            registration.registered_from.web_url_for('view_project', token=rejection_token),
            auth=self.user.auth,
        )
        registration.embargo.reload()
        assert_equal(registration.embargo.state, Embargo.REJECTED)
        assert_false(registration.is_pending_embargo)
        assert_equal(res.status_code, 200)
        assert_equal(project.web_url_for('view_project'), res.request.path)
开发者ID:mchelen,项目名称:osf.io,代码行数:23,代码来源:test_embargoes.py


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