• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python factories.PrivateLinkFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: setUp

    def setUp(self):
        super(TestMustBeContributorOrPublicButNotAnonymizedDecorator, self).setUp()
        self.contrib = AuthUserFactory()
        self.non_contrib = AuthUserFactory()
        admin = UserFactory()
        self.public_project = ProjectFactory(is_public=True)
        self.public_project.add_contributor(admin, auth=Auth(self.public_project.creator), permissions=['read', 'write', 'admin'])
        self.private_project = ProjectFactory(is_public=False)
        self.private_project.add_contributor(admin, auth=Auth(self.private_project.creator), permissions=['read', 'write', 'admin'])
        self.public_project.add_contributor(self.contrib, auth=Auth(self.public_project.creator))
        self.private_project.add_contributor(self.contrib, auth=Auth(self.private_project.creator))
        self.public_project.save()
        self.private_project.save()
        self.anonymized_link_to_public_project = PrivateLinkFactory(anonymous=True)
        self.anonymized_link_to_private_project = PrivateLinkFactory(anonymous=True)
        self.anonymized_link_to_public_project.nodes.append(self.public_project)
        self.anonymized_link_to_public_project.save()
        self.anonymized_link_to_private_project.nodes.append(self.private_project)
        self.anonymized_link_to_private_project.save()
        self.flaskapp = Flask('Testing decorator')

        @self.flaskapp.route('/project/<pid>/')
        @must_be_contributor_or_public_but_not_anonymized
        def project_get(**kwargs):
            return 'success', 200
        self.app = TestApp(self.flaskapp)
开发者ID:cslzchen,项目名称:osf.io,代码行数:26,代码来源:test_auth.py


示例2: TestPrivateLink

class TestPrivateLink(OsfTestCase):

    def setUp(self):
        super(TestPrivateLink, self).setUp()
        self.flaskapp = Flask('testing_private_links')

        @self.flaskapp.route('/project/<pid>/')
        @must_be_contributor
        def project_get(**kwargs):
            return 'success', 200

        self.app = TestApp(self.flaskapp)

        self.user = AuthUserFactory()
        self.project = ProjectFactory(is_public=False)
        self.link = PrivateLinkFactory()
        self.link.nodes.append(self.project)
        self.link.save()

    @mock.patch('website.project.decorators.Auth.from_kwargs')
    def test_has_private_link_key(self, mock_from_kwargs):
        mock_from_kwargs.return_value = Auth(user=None)
        res = self.app.get('/project/{0}'.format(self.project._primary_key),
            {'view_only': self.link.key})
        res = res.follow()
        assert_equal(res.status_code, 200)
        assert_equal(res.body, 'success')

    @mock.patch('website.project.decorators.Auth.from_kwargs')
    def test_does_not_have_key(self, mock_from_kwargs):
        mock_from_kwargs.return_value = Auth(user=None)
        res = self.app.get('/project/{0}'.format(self.project._primary_key),
            {'key': None})
        assert_is_redirect(res)
开发者ID:erinmayhood,项目名称:osf.io,代码行数:34,代码来源:test_auth.py


示例3: test_public_node_user_with_private_link_can_view_comment

 def test_public_node_user_with_private_link_can_view_comment(self):
     self._set_up_public_project_with_comment()
     private_link = PrivateLinkFactory(anonymous=False)
     private_link.nodes.append(self.public_project)
     private_link.save()
     res = self.app.get('/{}comments/{}/'.format(API_BASE, self.public_comment._id), {'view_only': private_link.key}, expect_errors=True)
     assert_equal(self.public_comment._id, res.json['data']['id'])
     assert_equal(self.public_comment.content, res.json['data']['attributes']['content'])
开发者ID:baylee-d,项目名称:osf.io,代码行数:8,代码来源:test_comment_detail.py


示例4: test_private_node_user_with_view_only_link_can_view_wiki

 def test_private_node_user_with_view_only_link_can_view_wiki(self):
     self._set_up_private_project_with_wiki_page()
     private_link = PrivateLinkFactory(anonymous=False)
     private_link.nodes.append(self.private_project)
     private_link.save()
     url = furl.furl(self.private_url).add(query_params={'view_only': private_link.key}).url
     res = self.app.get(url)
     assert_equal(res.status_code, 200)
     assert_equal(res.json['data']['id'], self.private_wiki._id)
开发者ID:caspinelli,项目名称:osf.io,代码行数:9,代码来源:test_wiki_detail.py


示例5: test_private_node_user_with_anonymous_link_cannot_see_commenter_info

 def test_private_node_user_with_anonymous_link_cannot_see_commenter_info(self):
     self._set_up_private_project_with_comment()
     private_link = PrivateLinkFactory(anonymous=True)
     private_link.nodes.append(self.private_project)
     private_link.save()
     res = self.app.get('/{}comments/{}/'.format(API_BASE, self.comment._id), {'view_only': private_link.key})
     assert_equal(res.status_code, 200)
     assert_equal(self.comment._id, res.json['data']['id'])
     assert_equal(self.comment.content, res.json['data']['attributes']['content'])
     assert_not_in('user', res.json['data']['relationships'])
开发者ID:baylee-d,项目名称:osf.io,代码行数:10,代码来源:test_comment_detail.py


示例6: test_file_info_with_anonymous_link

 def test_file_info_with_anonymous_link(self):
     link = PrivateLinkFactory(anonymous=True)
     link.nodes.append(self.project)
     link.save()
     self._upload_file('firstfile', 'secondcontent')
     url = self.project.api_url_for(
         'file_info', fid=self.project.uploads[0].filename
     )
     res = self.app.get(url, {'view_only': link.key})
     assert_not_in(self.user.fullname, res.body)
     assert_not_in(self.user._id, res.body)
开发者ID:AndrewSallans,项目名称:osf.io,代码行数:11,代码来源:test_osffiles.py


示例7: test_public_node_view_only_link_user_cannot_see_deleted_comment

    def test_public_node_view_only_link_user_cannot_see_deleted_comment(self):
        self._set_up_public_project_with_comment()
        self.public_comment.is_deleted = True
        self.public_comment.save()

        private_link = PrivateLinkFactory(anonymous=False)
        private_link.nodes.append(self.public_project)
        private_link.save()

        res = self.app.get('/{}comments/{}/'.format(API_BASE, self.public_comment._id), {'view_only': private_link.key}, expect_errors=True)
        assert_equal(res.status_code, 200)
        assert_is_none(res.json['data']['attributes']['content'])
开发者ID:baylee-d,项目名称:osf.io,代码行数:12,代码来源:test_comment_detail.py


示例8: test_no_warning_for_read_only_user_with_valid_link

 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,
     )
开发者ID:Alpani,项目名称:osf.io,代码行数:12,代码来源:webtest_tests.py


示例9: TestPrivateLinkView

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,代码行数:52,代码来源:webtest_tests.py


示例10: test_view_file_with_anonymous_link

 def test_view_file_with_anonymous_link(self, mock_fig):
     link = PrivateLinkFactory(anonymous=True)
     link.nodes.append(self.project)
     link.save()
     mock_fig.return_value = self.figshare
     url = self.project.web_url_for(
         'figshare_view_file', aid='564',fid='1348803'
     )
     self.app.auth = self.user.auth
     resp = self.app.get(url, {'view_only': link.key}).maybe_follow()
     assert_equal(resp.status_int, http.OK)
     assert_true('file is unpublished we cannot render it.' in resp.body)
     assert_not_in('View on Figshare', resp.body)
开发者ID:AndrewSallans,项目名称:osf.io,代码行数:13,代码来源:test_views.py


示例11: test_build_addon_root_for_anonymous_vols_hides_path

    def test_build_addon_root_for_anonymous_vols_hides_path(self):
        private_anonymous_link = PrivateLinkFactory(anonymous=True)
        private_anonymous_link.nodes.append(self.project)
        private_anonymous_link.save()
        project_viewer = UserFactory()

        result = rubeus.build_addon_root(
            self.node_settings,
            self.node_settings.bucket,
            user=project_viewer,
            private_key=private_anonymous_link.key
        )

        assert result['name'] == 'Amazon S3'
开发者ID:atelic,项目名称:osf.io,代码行数:14,代码来源:test_rubeus.py


示例12: test_dataverse_view_file_with_anonymous_link

    def test_dataverse_view_file_with_anonymous_link(self, mock_fail_if_private, mock_get_files, mock_connection, mock_scrape):
        link = PrivateLinkFactory(anonymous=True)
        link.nodes.append(self.project)
        link.save()
        mock_connection.return_value = create_mock_connection()
        mock_get_files.return_value = [create_mock_draft_file('foo')]
        mock_scrape.return_value = ('filename', 'content')

        url = self.project.api_url_for('dataverse_get_file_info', path='foo')
        res = self.app.get(url, {'view_only': link.key}).maybe_follow()
        assert_equal(res.status_code, 200)
        assert_not_in(self.node_settings.dataverse_alias, res.body)
        assert_not_in(self.node_settings.dataverse, res.body)
        assert_not_in(self.node_settings.study, res.body)
开发者ID:KerryKDiehl,项目名称:osf.io,代码行数:14,代码来源:test_views.py


示例13: test_params_do_not_appear_on_private_project_with_anonymous_view_only_link

    def test_params_do_not_appear_on_private_project_with_anonymous_view_only_link(self):

        private_link = PrivateLinkFactory(anonymous=True)
        private_link.nodes.append(self.node)
        private_link.save()

        url = self.url + '{}/'.format(self.log_add_contributor._id)

        res = self.app.get(url, {'view_only': private_link.key}, expect_errors=True)
        assert_equal(res.status_code, 200)
        data = res.json['data']
        assert_in('attributes', data)
        assert_not_in('params', data['attributes'])
        body = res.body
        assert_not_in(self.user._id, body)
开发者ID:alexschiller,项目名称:osf.io,代码行数:15,代码来源:test_log_params.py


示例14: ViewOnlyLinkTestCase

class ViewOnlyLinkTestCase(ApiTestCase):

    def setUp(self):
        super(ViewOnlyLinkTestCase, self).setUp()
        self.user = AuthUserFactory()
        self.read_only_user = AuthUserFactory()
        self.read_write_user = AuthUserFactory()
        self.non_contributor = AuthUserFactory()

        self.public_project = ProjectFactory(is_public=True, creator=self.user)
        self.public_project.add_contributor(self.read_only_user, permissions=[permissions.READ])
        self.public_project.add_contributor(self.read_write_user, permissions=[permissions.WRITE])
        self.public_project.save()

        self.view_only_link = PrivateLinkFactory(name='testlink')
        self.view_only_link.nodes.append(self.public_project)
        self.view_only_link.save()
开发者ID:alexschiller,项目名称:osf.io,代码行数:17,代码来源:test_node_view_only_links_list.py


示例15: setUp

 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')
开发者ID:baylee-d,项目名称:osf.io,代码行数:8,代码来源:webtest_tests.py


示例16: test_deleted_vols_not_returned

    def test_deleted_vols_not_returned(self):
        view_only_link = PrivateLinkFactory(name='testlink2')
        view_only_link.nodes.append(self.public_project)
        view_only_link.save()

        res = self.app.get(self.url, auth=self.user.auth)
        data = res.json['data']
        assert_equal(res.status_code, 200)
        assert_equal(len(data), 2)

        view_only_link.nodes.remove(self.public_project)
        view_only_link.save()

        res = self.app.get(self.url, auth=self.user.auth)
        data = res.json['data']
        assert_equal(res.status_code, 200)
        assert_equal(len(data), 1)
开发者ID:alexschiller,项目名称:osf.io,代码行数:17,代码来源:test_node_view_only_links_list.py


示例17: test_file_view_with_anonymous_link

    def test_file_view_with_anonymous_link(self, mock_repo, mock_file, mock_commits):
        mock_commits.return_value = [Commit.from_json({
            "url": "https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e",
            "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
            "commit": {
                "url": "https://api.github.com/repos/octocat/Hello-World/git/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e",
                "author": {
                    "name": "Monalisa Octocat",
                    "email": "[email protected]",
                   "date": "2011-04-14T16:00:49Z"
                }
            }
        })]

        mock_repo.return_value = Repository.from_json({
            "default_branch": "dev",
            'url': u'https://api.github.com/repos/{user}/mock-repo/git/trees/dev'.format(user=self.user),
            'sha': 'dev',
            'private': False,
            'tree': [
                {u'mode': u'100644',
                 u'path': u'coveragerc',
                 u'sha': u'92029ff5ce192425d346b598d7e7dd25f5f05185',
                 u'size': 245,
                 u'type': u'file',
                 u'url': u'https://api.github.com/repos/{user}/mock-repo/git/blobs/92029ff5ce192425d346b598d7e7dd25f5f05185'.format(user=self.user)}]
        })

        mock_file.return_value = {
            u'name': u'coveragerc',
            u'content': u'ClRleHRCbG9iOiBTaW1wbGlmaWVkIFRleHQgUHJvY2Vzc2luZwo9PT09PT09',
            u'size': 245
        }

        link = PrivateLinkFactory(anonymous=True)
        link.nodes.append(self.project)
        link.save()
        url = self.project.web_url_for('github_view_file', path="coveragerc")
        res = self.app.get(url, {'view_only': link.key}).maybe_follow()
        assert_in("6dcb09b5b57875f334f61aebed695e2e4193db5e", res)
        assert_in("Thu Apr 14 16:00:49 2011", res)
        assert_in("file-version-history", res)
        assert_in("icon-download-alt", res)
        assert_not_in("Monalisa Octocat", res)
        assert_not_in("[email protected]", res)
开发者ID:AndrewSallans,项目名称:osf.io,代码行数:45,代码来源:webtest_tests.py


示例18: TestPrivateLinkView

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,代码行数:19,代码来源:webtest_tests.py


示例19: setUp

    def setUp(self):
        super(ViewOnlyTestCase, self).setUp()
        self.creation_user = AuthUserFactory()
        self.viewing_user = AuthUserFactory()
        self.contributing_read_user = AuthUserFactory()
        self.contributing_write_user = AuthUserFactory()
        self.valid_contributors = [
            self.creation_user._id,
            self.contributing_read_user._id,
            self.contributing_write_user._id,
        ]

        self.private_node_one = ProjectFactory(is_public=False, creator=self.creation_user, title="Private One")
        self.private_node_one.add_contributor(self.contributing_read_user, permissions=[permissions.READ], save=True)
        self.private_node_one.add_contributor(self.contributing_write_user, permissions=[permissions.WRITE], save=True)
        self.private_node_one_anonymous_link = PrivateLinkFactory(anonymous=True)
        self.private_node_one_anonymous_link.nodes.append(self.private_node_one)
        self.private_node_one_anonymous_link.save()
        self.private_node_one_private_link = PrivateLinkFactory(anonymous=False)
        self.private_node_one_private_link.nodes.append(self.private_node_one)
        self.private_node_one_private_link.save()
        self.private_node_one_url = '/{}nodes/{}/'.format(API_BASE, self.private_node_one._id)

        self.private_node_two = ProjectFactory(is_public=False, creator=self.creation_user, title="Private Two")
        self.private_node_two.add_contributor(self.contributing_read_user, permissions=[permissions.READ], save=True)
        self.private_node_two.add_contributor(self.contributing_write_user, permissions=[permissions.WRITE], save=True)
        self.private_node_two_url = '/{}nodes/{}/'.format(API_BASE, self.private_node_two._id)

        self.public_node_one = ProjectFactory(is_public=True, creator=self.creation_user, title="Public One")
        self.public_node_one.add_contributor(self.contributing_read_user, permissions=[permissions.READ], save=True)
        self.public_node_one.add_contributor(self.contributing_write_user, permissions=[permissions.WRITE], save=True)
        self.public_node_one_anonymous_link = PrivateLinkFactory(anonymous=True)
        self.public_node_one_anonymous_link.nodes.append(self.public_node_one)
        self.public_node_one_anonymous_link.save()
        self.public_node_one_private_link = PrivateLinkFactory(anonymous=False)
        self.public_node_one_private_link.nodes.append(self.public_node_one)
        self.public_node_one_private_link.save()
        self.public_node_one_url = '/{}nodes/{}/'.format(API_BASE, self.public_node_one._id)

        self.public_node_two = ProjectFactory(is_public=True, creator=self.creation_user, title="Public Two")
        self.public_node_two.add_contributor(self.contributing_read_user, permissions=[permissions.READ], save=True)
        self.public_node_two.add_contributor(self.contributing_write_user, permissions=[permissions.WRITE], save=True)
        self.public_node_two_url = '/{}nodes/{}/'.format(API_BASE, self.public_node_two._id)
开发者ID:atelic,项目名称:osf.io,代码行数:43,代码来源:test_view_only_query_parameter.py


示例20: setUp

    def setUp(self):
        super(TestPrivateLink, self).setUp()
        self.flaskapp = Flask('testing_private_links')

        @self.flaskapp.route('/project/<pid>/')
        @must_be_contributor
        def project_get(**kwargs):
            return 'success', 200

        self.app = TestApp(self.flaskapp)

        self.user = AuthUserFactory()
        self.project = ProjectFactory(is_public=False)
        self.link = PrivateLinkFactory()
        self.link.nodes.append(self.project)
        self.link.save()
开发者ID:erinmayhood,项目名称:osf.io,代码行数:16,代码来源:test_auth.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python factories.ProjectFactory类代码示例发布时间:2022-05-27
下一篇:
Python factories.PreprintFactory类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap