本文整理汇总了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))
示例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',),
)