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


Python IWorkspace.remove_from_team方法代码示例

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


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

示例1: TestWorkspace

# 需要导入模块: from collective.workspace.interfaces import IWorkspace [as 别名]
# 或者: from collective.workspace.interfaces.IWorkspace import remove_from_team [as 别名]
class TestWorkspace(unittest.TestCase):
    layer = COLLECTIVE_WORKSPACE_INTEGRATION_TESTING

    def setUp(self):
        self.app = self.layer["app"]
        self.portal = self.layer["portal"]
        self.request = self.layer["request"]
        z2.login(self.app["acl_users"], SITE_OWNER_NAME)
        self.user1 = api.user.create(email="[email protected]", username="user1", password="123")
        self.workspace = api.content.create(container=self.portal, type="Workspace", id="a-workspace")
        self.ws = IWorkspace(self.workspace)

    def test_add_to_team(self):
        self.ws.add_to_team(user=self.user1.getId())
        self.assertIn(self.user1.getId(), list(self.ws.members))

    def test_remove_from_team(self):
        self.ws.add_to_team(user=self.user1.getId())
        self.ws.remove_from_team(user=self.user1.getId())
        self.assertNotIn(self.user1.getId(), list(self.ws.members))
开发者ID:tud-mit-plone,项目名称:collective.workspace,代码行数:22,代码来源:test_workspace.py

示例2: TestWorkspace

# 需要导入模块: from collective.workspace.interfaces import IWorkspace [as 别名]
# 或者: from collective.workspace.interfaces.IWorkspace import remove_from_team [as 别名]

#.........这里部分代码省略.........
        self.ws[self.user1.getId()].update({'groups': set([u'Admins'])})
        self.assertIn(
            self.user1.getId(),
            self.portal.portal_groups.getGroupMembers(
                'Members:' + self.workspace.UID()),
        )
        self.assertIn(
            self.user1.getId(),
            self.portal.portal_groups.getGroupMembers(
                'Admins:' + self.workspace.UID()),
        )

    def test_direct_set_of_membership_property_is_blocked(self):
        self.ws.add_to_team(
            user=self.user1.getId()
        )
        try:
            self.ws[self.user1.getId()].position = u'Tester'
        except Exception as e:
            self.assertEqual(
                str(e),
                'Setting membership properties directly is not supported. '
                'Use the `update` method instead.'
            )
        else:
            self.fail('Expected exception')

    def test_local_role_team_member(self):
        self.ws.add_to_team(
            user=self.user1.getId()
        )
        self.assertIn('TeamMember', self._get_roles_in_workspace())

    def test_remove_from_team(self):
        self.ws.add_to_team(
            user=self.user1.getId()
        )
        self.ws.remove_from_team(
            user=self.user1.getId()
        )
        self.assertNotIn(self.user1.getId(), list(self.ws.members))

    def test_removing_team_member_updates_groups(self):
        self.ws.add_to_team(
            user=self.user1.getId(),
            groups=(u'Admins',),
        )
        self.ws.remove_from_team(
            user=self.user1.getId()
        )
        self.assertNotIn(
            self.user1.getId(),
            self.portal.portal_groups.getGroupMembers(
                'Members:' + self.workspace.UID()),
        )
        self.assertNotIn(
            self.user1.getId(),
            self.portal.portal_groups.getGroupMembers(
                'Admins:' + self.workspace.UID()),
        )

    def test_reparent_team_member(self):
        self.ws.add_to_team(
            user=self.user1.getId(),
            groups=(u'Admins',),
            )
开发者ID:collective,项目名称:collective.workspace,代码行数:70,代码来源:test_workspace.py


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