def testComparison(self): meta1 = MetaData() meta2 = MetaData() meta2.setCreateTime(meta1.getCreateTime()) self.assertEquals(meta1, meta2) meta1.setCreateTime(213123) self.assertNotEquals(meta1, meta2) meta2.setCreateTime(meta1.getCreateTime()) self.assertEquals(meta1, meta2) meta1.setSendTime() self.assertNotEquals(meta1, meta2) meta2.setSendTime(meta1.getSendTime()) self.assertEquals(meta1, meta2) meta1.setReceiveTime() self.assertNotEquals(meta1, meta2) meta2.setReceiveTime(meta1.getReceiveTime()) self.assertEquals(meta1, meta2) meta1.setDeliverTime() self.assertNotEquals(meta1, meta2) meta2.setDeliverTime(meta1.getDeliverTime()) self.assertEquals(meta1, meta2) meta1.setUserTime("foo") self.assertNotEquals(meta1, meta2) meta2.setUserTime("foo", meta1.getUserTimes()["foo"]) self.assertEquals(meta1, meta2) meta1.setUserInfo("foox", "bla") self.assertNotEquals(meta1, meta2) meta2.setUserInfo("foox", meta1.getUserInfos()["foox"]) self.assertEquals(meta1, meta2)
def send_transform(self, transform, transform_type): ''' Add transform information to the rct data structure. :param transform: :param transform_type: :return: True unless an error occured ''' if not self.__rsb_informer_transform: self.__logger.error( "[{}] RSB communicator was not initialized!".format( self.__authority)) # some small type checks for usability assert isinstance( transform, Transform ), "Input transformation has to be of type rct.Transform! (Input was: {})".format( type(transform)) assert hasattr( TransformType, transform_type ), "Input transformation type has to be of type rct.TransformType! (Input was: {})".format( type(transform_type)) cache_key = transform.get_frame_parent() + transform.get_frame_child() meta_data = MetaData() if transform.get_authority() is "": meta_data.setUserInfo(self.__user_key_authority, self.__authority) else: meta_data.setUserInfo(self.__user_key_authority, transform.get_authority()) self.__logger.info("[{}] Publishing transform from {}".format( self.__authority, self.__rsb_informer_transform.getId())) # TODO: threaded? event = Event() event.setData(transform) event.setType(type(transform)) event.setMetaData(meta_data) if transform_type is TransformType.STATIC: self.__send_cache_static[cache_key] = (transform, meta_data) event.setScope(self.__rsb_informer_transform.getScope().concat( Scope(self.__scope_suffix_static))) elif transform_type is TransformType.DYNAMIC: self.__send_cache_dynamic[cache_key] = (transform, meta_data) event.setScope(self.__rsb_informer_transform.getScope().concat( Scope(self.__scope_suffix_dynamic))) else: self.__logger.error( "[{}] Cannot send transform. Reason: Unknown TransformType: {}" .format(self.__authority, str(transform_type))) return False self.__logger.info("[{}] Sending {} to scope {}".format( self.__authority, transform.__str__(), event.getScope())) self.__rsb_informer_transform.publishEvent(event) self.__logger.debug("[{}] Sending successful!".format( self.__authority)) return True