def test_dispatch(self): profile = MockProfile() dispatch = ContactDispatcher(profile=profile) a = A('digsby13', 'aim') b = B('digsby01', 'aim') dispatch.add_tofrom('im', b, a) profile.connected_accounts[:] = [a] _b, proto = dispatch.get_from(b) self.assertEquals(b, _b) self.assertEquals(a.connection, proto)
def __init__(self, conn_accts): Observable.__init__(self) self.dirty = False self.sorting_paused = True #self._listen_for_pref_load() self.rebuild_timer = wx.PyTimer(self.rebuild_later) self.rebuild_timer.StartRepeating(500) # Holds the final view that goes into the TreeList. self.view = DGroup('__root__', [], []) self.info = {} # Rootgroups are the "protocol" rootgroups with the original, # unmodified versions of the buddy list structure for each account self.rootgroups = [] self.base_attrs = frozenset([None, 'alias', 'status', 'status_message', 'icon', 'icon_hash', 'entering', 'leaving', 'idle', 'away','mobile']) self.attrs = set(self.base_attrs) # conn_accts must be an observable list of connected accounts conn_accts.add_observer(self.on_connections_changed) self.metacontacts = MetaContactManager(self) self._init_order() self.contact_info_changed = Delegate() self.dispatch = ContactDispatcher() self.caches = dict(tofrom = DiskCache('im_history.dat', validator = validate_tofrom)) self.load_local_data() # save local to/from data on exit hooks.register('digsby.app.exit', self.save_local_data) self._search_by = u'' self._search_results = (0, 0) # number of contacts found in last two searches #todo: make then_bys based on a pref self.sort_models = sort_model.build_models( then_bys = 1, obj = self) self.sbw = sort_model.SortByWatcher(self.sort_models)