def test_no_groups(self):

        self.expect(self.gtool.getGroupsByUserId(ANY)).result([])

        self.replay()

        executor = UsersSearchResultExecutor(self.context, '', True)
        result = executor.get_group_names_of_user('user')

        self.assertEquals(result, 'No Group')
    def test_filter_groups(self):

        groups = [Group('group%s' % i) for i in range(5)]
        groups.append(Group('AuthenticatedUsers'))

        self.expect(self.gtool.getGroupsByUserId(ANY)).result(groups)

        self.replay()

        executor = UsersSearchResultExecutor(self.context, '', True)
        result = executor.get_group_names_of_user('invalid')

        self.assertEquals(result, 'group0, group1, group2, group3, group4')
    def test_unsorted_groups(self):

        groups = [Group('group%s' % i) for i in range(5)]
        groups.reverse()

        self.expect(self.gtool.getGroupsByUserId(ANY)).result(groups)

        self.replay()

        executor = UsersSearchResultExecutor(self.context, '', True)
        result = executor.get_group_names_of_user('user')

        self.assertEquals(result, 'group0, group1, group2, group3, group4')