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
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')
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
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'
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
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
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
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'
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)
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
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')
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
def test_create_adds_group_creator_to_members(self, db_session, users): svc = GroupService(db_session, users.get) group = svc.create('Anteater fans', 'foobar.com', 'cazimir') assert users['cazimir'] in group.members