本文整理匯總了Python中h.services.group.GroupService類的典型用法代碼示例。如果您正苦於以下問題:Python GroupService類的具體用法?Python GroupService怎麽用?Python GroupService使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了GroupService類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_create_publishes_join_event
def test_create_publishes_join_event(self, db_session, users):
publish = mock.Mock(spec_set=[])
svc = GroupService(db_session, users.get, publish=publish)
group = svc.create('Dishwasher disassemblers', 'foobar.com', 'theresa')
publish.assert_called_once_with('group-join', group.pubid, 'theresa')
示例2: test_member_join_is_idempotent
def test_member_join_is_idempotent(self, db_session, group, users):
svc = GroupService(db_session, users.get)
svc.member_join(group, 'theresa')
svc.member_join(group, 'theresa')
assert group.members.count(users['theresa']) == 1
示例3: test_create_sets_group_ids
def test_create_sets_group_ids(self, db_session, users):
svc = GroupService(db_session, users.get)
group = svc.create('Anteater fans', 'foobar.com', 'cazimir')
assert group.id
assert group.pubid
示例4: test_member_join_publishes_join_event
def test_member_join_publishes_join_event(self, db_session, group, users):
publish = mock.Mock(spec_set=[])
svc = GroupService(db_session, users.get, publish=publish)
group.pubid = 'abc123'
svc.member_join(group, 'theresa')
publish.assert_called_once_with('group-join', 'abc123', 'theresa')
示例5: test_member_leave_removes_user_from_group
def test_member_leave_removes_user_from_group(self, db_session, users):
svc = GroupService(db_session, users.get)
group = Group(name='Theresa and her buddies',
authority='foobar.com',
creator=users['theresa'])
group.members.append(users['cazimir'])
svc.member_leave(group, 'cazimir')
assert users['cazimir'] not in group.members
示例6: test_create_sets_access_flags_for_group_types
def test_create_sets_access_flags_for_group_types(self,
db_session,
users,
group_type,
flag,
expected_value):
svc = GroupService(db_session, users.get)
group = svc.create('Anteater fans', 'foobar.com', 'cazimir', type_=group_type)
assert getattr(group, flag) == expected_value
示例7: test_member_leave_publishes_leave_event
def test_member_leave_publishes_leave_event(self, db_session, users):
publish = mock.Mock(spec_set=[])
svc = GroupService(db_session, users.get, publish=publish)
group = Group(name='Donkey Trust',
authority='foobari.com',
creator=users['theresa'])
group.members.append(users['cazimir'])
group.pubid = 'abc123'
svc.member_leave(group, 'cazimir')
publish.assert_called_once_with('group-leave', 'abc123', 'cazimir')
示例8: test_create_adds_group_to_session
def test_create_adds_group_to_session(self, db_session, users):
svc = GroupService(db_session, users.get)
group = svc.create('Anteater fans', 'foobar.com', 'cazimir')
assert group in db_session
示例9: test_create_raises_for_invalid_group_type
def test_create_raises_for_invalid_group_type(self, db_session, users):
svc = GroupService(db_session, users.get)
with pytest.raises(ValueError):
svc.create('Anteater fans', 'foobar.com', 'cazimir', type_='foo')
示例10: test_create_skips_setting_description_when_missing
def test_create_skips_setting_description_when_missing(self, db_session, users):
svc = GroupService(db_session, users.get)
group = svc.create('Anteater fans', 'foobar.com', 'cazimir')
assert group.description is None
示例11: test_create_sets_description_when_present
def test_create_sets_description_when_present(self, db_session, users):
svc = GroupService(db_session, users.get)
group = svc.create('Anteater fans', 'foobar.com', 'cazimir', 'all about ant eaters')
assert group.description == 'all about ant eaters'
示例12: test_create_sets_group_authority
def test_create_sets_group_authority(self, db_session, users):
svc = GroupService(db_session, users.get)
group = svc.create('Anteater fans', 'foobar.com', 'cazimir')
assert group.authority == 'foobar.com'
示例13: test_create_returns_group
def test_create_returns_group(self, db_session, users):
svc = GroupService(db_session, users.get)
group = svc.create('Anteater fans', 'foobar.com', 'cazimir')
assert isinstance(group, Group)
示例14: test_member_join_adds_user_to_group
def test_member_join_adds_user_to_group(self, db_session, group, users):
svc = GroupService(db_session, users.get)
svc.member_join(group, 'theresa')
assert users['theresa'] in group.members
示例15: test_create_doesnt_add_group_creator_to_members_for_publisher_groups
def test_create_doesnt_add_group_creator_to_members_for_publisher_groups(self, db_session, users):
svc = GroupService(db_session, users.get)
group = svc.create('Anteater fans', 'foobar.com', 'cazimir', type_='publisher')
assert users['cazimir'] not in group.members