Esempio n. 1
0
    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
Esempio n. 2
0
    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')
Esempio n. 3
0
    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
Esempio n. 4
0
    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
Esempio n. 5
0
    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'
Esempio n. 6
0
    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')
Esempio n. 7
0
    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
Esempio n. 8
0
    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
Esempio n. 9
0
    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
Esempio n. 10
0
    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
Esempio n. 11
0
    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'
Esempio n. 12
0
    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'
Esempio n. 13
0
    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)
Esempio n. 14
0
    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
Esempio n. 15
0
    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')
Esempio n. 16
0
    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'
Esempio n. 17
0
    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)
Esempio n. 18
0
    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')
Esempio n. 19
0
    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
Esempio n. 20
0
    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
Esempio n. 21
0
    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
Esempio n. 22
0
    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