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


Python PrivateLinkFactory.save方法代码示例

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


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

示例1: TestPrivateLink

# 需要导入模块: from tests.factories import PrivateLinkFactory [as 别名]
# 或者: from tests.factories.PrivateLinkFactory import save [as 别名]
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,代码行数:36,代码来源:test_auth.py

示例2: test_public_node_user_with_private_link_can_view_comment

# 需要导入模块: from tests.factories import PrivateLinkFactory [as 别名]
# 或者: from tests.factories.PrivateLinkFactory import save [as 别名]
 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,代码行数:10,代码来源:test_comment_detail.py

示例3: test_private_node_user_with_view_only_link_can_view_wiki

# 需要导入模块: from tests.factories import PrivateLinkFactory [as 别名]
# 或者: from tests.factories.PrivateLinkFactory import save [as 别名]
 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,代码行数:11,代码来源:test_wiki_detail.py

示例4: test_private_node_user_with_anonymous_link_cannot_see_commenter_info

# 需要导入模块: from tests.factories import PrivateLinkFactory [as 别名]
# 或者: from tests.factories.PrivateLinkFactory import save [as 别名]
 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,代码行数:12,代码来源:test_comment_detail.py

示例5: test_file_info_with_anonymous_link

# 需要导入模块: from tests.factories import PrivateLinkFactory [as 别名]
# 或者: from tests.factories.PrivateLinkFactory import save [as 别名]
 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,代码行数:13,代码来源:test_osffiles.py

示例6: test_no_warning_for_read_only_user_with_valid_link

# 需要导入模块: from tests.factories import PrivateLinkFactory [as 别名]
# 或者: from tests.factories.PrivateLinkFactory import save [as 别名]
 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,代码行数:14,代码来源:webtest_tests.py

示例7: test_public_node_view_only_link_user_cannot_see_deleted_comment

# 需要导入模块: from tests.factories import PrivateLinkFactory [as 别名]
# 或者: from tests.factories.PrivateLinkFactory import save [as 别名]
    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,代码行数:14,代码来源:test_comment_detail.py

示例8: TestPrivateLinkView

# 需要导入模块: from tests.factories import PrivateLinkFactory [as 别名]
# 或者: from tests.factories.PrivateLinkFactory import save [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

示例9: test_view_file_with_anonymous_link

# 需要导入模块: from tests.factories import PrivateLinkFactory [as 别名]
# 或者: from tests.factories.PrivateLinkFactory import save [as 别名]
 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,代码行数:15,代码来源:test_views.py

示例10: test_dataverse_view_file_with_anonymous_link

# 需要导入模块: from tests.factories import PrivateLinkFactory [as 别名]
# 或者: from tests.factories.PrivateLinkFactory import save [as 别名]
    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,代码行数:16,代码来源:test_views.py

示例11: test_build_addon_root_for_anonymous_vols_hides_path

# 需要导入模块: from tests.factories import PrivateLinkFactory [as 别名]
# 或者: from tests.factories.PrivateLinkFactory import save [as 别名]
    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,代码行数:16,代码来源:test_rubeus.py

示例12: test_params_do_not_appear_on_private_project_with_anonymous_view_only_link

# 需要导入模块: from tests.factories import PrivateLinkFactory [as 别名]
# 或者: from tests.factories.PrivateLinkFactory import save [as 别名]
    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,代码行数:17,代码来源:test_log_params.py

示例13: test_deleted_vols_not_returned

# 需要导入模块: from tests.factories import PrivateLinkFactory [as 别名]
# 或者: from tests.factories.PrivateLinkFactory import save [as 别名]
    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,代码行数:19,代码来源:test_node_view_only_links_list.py

示例14: ViewOnlyLinkTestCase

# 需要导入模块: from tests.factories import PrivateLinkFactory [as 别名]
# 或者: from tests.factories.PrivateLinkFactory import save [as 别名]
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,代码行数:19,代码来源:test_node_view_only_links_list.py

示例15: test_file_view_with_anonymous_link

# 需要导入模块: from tests.factories import PrivateLinkFactory [as 别名]
# 或者: from tests.factories.PrivateLinkFactory import save [as 别名]
    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,代码行数:47,代码来源:webtest_tests.py


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