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


Python NodeFactory.set_privacy方法代码示例

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


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

示例1: TestShortUrls

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import set_privacy [as 别名]
class TestShortUrls(OsfTestCase):

    def setUp(self):
        super(TestShortUrls, self).setUp()
        self.user = AuthUserFactory()
        self.auth = self.user.auth
        self.consolidate_auth = Auth(user=self.user)
        self.project = ProjectFactory(creator=self.user)
        # A non-project componenet
        self.component = NodeFactory(parent=self.project, category='hypothesis', creator=self.user)
        # Hack: Add some logs to component; should be unnecessary pending
        # improvements to factories from @rliebz
        self.component.set_privacy('public', auth=self.consolidate_auth)
        self.component.set_privacy('private', auth=self.consolidate_auth)
        self.wiki = WikiFactory(
            user=self.user,
            node=self.component,
        )

    def _url_to_body(self, url):
        return self.app.get(
            url,
            auth=self.auth
        ).maybe_follow(
            auth=self.auth,
        ).normal_body

    def test_project_url(self):
        assert_equal(
            self._url_to_body(self.project.deep_url),
            self._url_to_body(self.project.url),
        )

    def test_component_url(self):
        assert_equal(
            self._url_to_body(self.component.deep_url),
            self._url_to_body(self.component.url),
        )

    def test_wiki_url(self):
        assert_equal(
            self._url_to_body(self.wiki.deep_url),
            self._url_to_body(self.wiki.url),
        )
开发者ID:erinspace,项目名称:osf.io,代码行数:46,代码来源:test_webtests.py

示例2: TestComponents

# 需要导入模块: from osf_tests.factories import NodeFactory [as 别名]
# 或者: from osf_tests.factories.NodeFactory import set_privacy [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_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('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('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:erinspace,项目名称:osf.io,代码行数:79,代码来源:test_webtests.py


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