예제 #1
0
def main2():

    sorter = blist.BuddyListSorter()
    sorter.set_root(test_root_group)
    sorter.dump_root()

    sorter.root()
예제 #2
0
    def by_log_size(self):
        'Returns a list of MetaContacts and Contacts by log size.'

        sorter = blist.BuddyListSorter()
        sorter.addSorter(blist.ByGroup(False))
        sorter.addSorter(blist.ByOnline(True, False))
        sorter.setComparators([blist.LogSize])
        return remove_contacts_in_metacontacts(self.use_sorter(sorter))
예제 #3
0
    def test_leaks(self):
        '''
        test that python conversion methods don't leak refcounts
        '''

        sorter = blist.BuddyListSorter()
        leakcheck(sorter.set_contact_order, test_contact_order)
        leakcheck(sorter.set_contact_order, {})
예제 #4
0
    def test_missing(self):
        '''
        Test missing counts.
        '''
        s = blist.BuddyListSorter()
        s.addSorter(blist.ByGroup(False, 2))
        s.addSorter(blist.ByService(True))
        s.addSorter(blist.ByOnline(True, True))
        cmps = [
            blist.CustomOrder, blist.Service, blist.UserOrdering,
            blist.UserOrdering
        ]
        s.setComparators(cmps)

        p = Protocol('digsby01', 'aim')
        p2 = Protocol('steve', 'digsby')

        def show(root_group):
            s.set_root(root_group)
            g = s._gather()
            try:
                print
                dump_elem_tree(g)
            finally:
                s._done_gather(g)

        root_group = Group(
            'root', p, 'root',
            RootGroup(
                'root1', p, 'root1',
                Group('aim group', p, 'aim group',
                      Buddy('abc', p, status='available'),
                      Buddy('abc', p, status='away'),
                      Buddy('def', p, status='offline'),
                      Buddy('def', p, status='offline'),
                      Buddy('ghi', p, status='away')),
                Buddy('12345', p, service='icq', status='offline'),
                Buddy('12345', p, service='aim', status='offline'),
                Buddy('fadjkls', p, status='mobile'),
                Group('group #2', p, 'group #2',
                      Buddy('wut', p, status='mobile')),
                RootGroup(
                    'root2', p2, 'root2',
                    Group(
                        'digsby group',
                        p2,
                        'digsby group',
                        Buddy('ninjadigsby', p2, status='away'),
                    ))))

        leakcheck(show, root_group)
예제 #5
0
    def test_group_ownership(self):
        s = blist.BuddyListSorter()
        s.addSorter(blist.ByGroup(True))

        p = Protocol('aim', 'digsby01')
        s.set_root(
            Group('root', p, 'root',
                  Group('subgroup', p, 'root', Buddy('abc', p))))

        root = s._gather()
        assert root.name == 'root'
        subgroup = root[0]
        assert subgroup.name == 'subgroup'
        assert subgroup[0].name == 'abc'
        s._done_gather(root)
예제 #6
0
    def test_nodes(self):
        sorter = blist.BuddyListSorter()
        sorter.set_root(test_root_group)

        root = sorter.root()

        assert root.name == 'root', root.name

        assert len(root) == 1
        group = root[0]

        assert group.name == 'buddies', group.name

        assert len(group) == 1
        offline_group = group[0]
        root.destroy()
예제 #7
0
    def test_filter_offline(self):
        s = blist.BuddyListSorter()
        s.addSorter(blist.ByGroup(True))
        s.addSorter(blist.ByMobile(True))
        s.addSorter(blist.ByOnline(False, False))

        s.setComparators([blist.Name])

        p = Protocol('aim', 'digsby01')

        s.set_root(
            Group('root', p, 'root', Buddy('abc', p, status='available'),
                  Buddy('def', p, status='offline')))

        root = s._gather()
        s._done_gather(root)
        del s
예제 #8
0
    def foo():
        s = blist.BuddyListSorter()
        s.addSorter(blist.ByFakeRoot('Contacts'))
        s.addSorter(blist.ByGroup(True, 2))
        #        s.addSorter(blist.ByMobile(False))
        #        s.addSorter(blist.ByOnline(False))
        p = Protocol('aim', 'digsby01')
        root = Group(
            'root',
            p,
            'root',
            Group('root1', p, 'root1', Group('Contacts', p, 'subgroup'),
                  Buddy('abc', p)),
        )

        root_ref = ref(root)
        proto_ref = ref(p)
        sorter_ref = ref(s)

        s.set_root(root)

        gathered = s._gather()
        gathered_ref = ref(gathered)

        protocols, ids = gathered._protocol_ids
        #assert protocols == [p]
        #assert ids == ['root'], repr(ids)

        assert not sip.ispyowned(gathered)
        s._done_gather(gathered)
        del gathered
        del s
        del protocols, ids

        del p, root

        assert root_ref() is None
        assert proto_ref() is None

        assert sorter_ref() is None
        assert gathered_ref() is None
        '''
예제 #9
0
    def _setup_blist_sorter(self):
        if hasattr(self, 'new_sorter'):
            return

        blist.set_group_type((DGroup, Group, MockGroup))
        self.new_sorter = blist.BuddyListSorter()
        self.update_order()

        # link prefs
        cb = self._on_blist_sort_pref
        link = profile.prefs.link
        for prefname in ('buddylist.fakeroot_name',
                         'buddylist.show_offline',
                         'buddylist.group_offline',
                         'buddylist.show_mobile',
                         'buddylist.hide_offline_groups',
                         'buddylist.sortby'):
            link(prefname, cb)

        cb()
        assert on_thread('sorter').now
        self._reconfig_sorter(False)
예제 #10
0
    def test_group_counts(self):
        sorter = blist.BuddyListSorter()
        sorter.addSorter(blist.ByFakeRoot("Contacts"))
        sorter.addSorter(blist.ByGroup(True, 2))
        sorter.addSorter(blist.ByOnline(True, True))

        p = Protocol('aim', 'digsby01')
        sorter.set_root(
            Group(
                'root', p, 'root',
                Group('root1', p, 'root1', Buddy('abc', p), Buddy('def', p),
                      Group(
                          'Contacts',
                          p,
                          'Contacts',
                      ))))

        n = sorter._gather()
        try:
            # TODO: make 0 and 2 properties here.
            assert '0/2' in n[0].display_string
        finally:
            sorter._done_gather(n)
예제 #11
0
 def test_invalid_input(self):
     sorter = blist.BuddyListSorter()
     self.assertRaises(TypeError, sorter.set_contact_order, None)
예제 #12
0
 def test_sorts_by(self):
     import blist
     s = blist.BuddyListSorter()
     assert s.sortsBy(blist.Name)
     assert not s.sortsBy(blist.LogSize)
예제 #13
0
    def test_sorter_ownership(self):
        s = blist.BuddyListSorter()
        b = blist.ByGroup()
        s.addSorter(b)

        assert not sip.ispyowned(b)