def test_remove_local_object(self): remote_msg_trans = RemoteMessageTransport("remote_object", self.target) local_msg_trans = LocalMessageTransport("local_object", self.target) self.target._MessageDispatcher__local_objects =\ {"remote_object": remote_msg_trans, "local_object": local_msg_trans} subscription_map =\ self.target._MessageDispatcher__subscription_map subscription_map._EventSubscriptionMap__subscriptions =\ {"remote_object": set(["key01:value01", "key01:value02"]), "local_object": set(["key01:value01", "key01:value02"])} subscription_map._EventSubscriptionMap__subscription_map =\ {"key01:value01": set(["remote_object", "local_object"]), "key01:value02": set(["remote_object", "local_object"])} self.target.remove_local_object(local_msg_trans) self.assertEqual(self.target._MessageDispatcher__local_objects, {"remote_object": remote_msg_trans}) self.assertEqual( subscription_map._EventSubscriptionMap__subscriptions, {"remote_object": set(["key01:value01", "key01:value02"])}) self.assertEqual( subscription_map._EventSubscriptionMap__subscription_map, { "key01:value01": set(["remote_object"]), "key01:value02": set(["remote_object"]) })
def __get_message_client(self, object_id): if object_id not in self.__clients: if object_id in self.__local_objects: client = LocalMessageTransport(object_id, self) else: client = RemoteMessageTransport(object_id, self) self.__clients[object_id] = client return self.__clients[object_id]
def setUp(self): self.target = LocalMessageTransport("LocalMessageTransport", self.Dispatcher)