def setUp(self):
        from mi.core.kudu import _pkt
        log.debug("*********************************************************************")
        log.debug("Starting Dataset Test %s", self._testMethodName)
        log.debug("*********************************************************************")
        log.debug("ID: %s", self.id())
        log.debug("DataSetTestCase setUp")

        # Test to ensure we have initialized our test config
        if not self.test_config.initialized:
            return TestNotInitialized(msg="Tests non initialized. Missing DataSetTestCase.initialize(...)?")

        log.debug("Driver Config: %s", self._driver_config())


        self.state_callback_result = []
        self.data_callback_result = []
        self.event_callback_result = []
        self.exception_callback_result = []

        self.memento = {}

        self.PKT_ID = PKT_ID = 123
        self.PKT_TYPE = PKT_TYPE = 'GENC'
        self.PKT_DATA = PKT_DATA = 1,2,3,4
        self.PKT_TIME = PKT_TIME = 999
        self.PKT_SAMPRATE = PKT_SAMPRATE = 666
        self.PKT_NET = PKT_NET = 'net'
        self.PKT_STA = PKT_STA = 'sta'
        self.PKT_CHAN = PKT_CHAN = 'chan'
        self.PKT_LOC = PKT_LOC = 'loc'

        pkt = _pkt._newPkt()
        _pkt._Pkt_pkttype_set(pkt, PKT_TYPE)
        pktchan = _pkt._newPktChannel()
        _pkt._PktChannel_data_set(pktchan, PKT_DATA)
        _pkt._PktChannel_samprate_set(pktchan, PKT_SAMPRATE)
        _pkt._PktChannel_time_set(pktchan, PKT_TIME)
        _pkt._PktChannel_net_set(pktchan, PKT_NET)
        _pkt._PktChannel_sta_set(pktchan, PKT_STA)
        _pkt._PktChannel_chan_set(pktchan, PKT_CHAN)
        _pkt._PktChannel_loc_set(pktchan, PKT_LOC)
        _pkt._Pkt_channels_set(pkt, [pktchan,])
        self.pkttype, self.packet, self.srcname, self.time = _pkt._stuffPkt(pkt)
        _pkt._freePkt(pkt)

        self.driver = self._get_driver_object()

        # NOTE why not do this in tearDown?
        self.addCleanup(self._stop_driver)

        self._metadata = None
        self._get_metadata()
    def setUp(self):
        ParserUnitTestCase.setUp(self)

        self.error_callback_values = []
        self.state_callback_values = []
        self.publish_callback_values = []

        self.parser_config = {
            ParserConfigKey.ORBNAME: ParserConfigKey.ORBNAME,
            ParserConfigKey.SELECT: ParserConfigKey.SELECT,
            ParserConfigKey.REJECT: ParserConfigKey.REJECT,
        }

        self.parser_state = None

        self.PKT_ID = PKT_ID = 123
        self.PKT_TYPE = PKT_TYPE = 'GENC'
        self.PKT_DATA = PKT_DATA = 1,2,3,4
        self.PKT_TIME = PKT_TIME = 999
        self.PKT_SAMPRATE = PKT_SAMPRATE = 666
        self.PKT_NET = PKT_NET = 'net'
        self.PKT_STA = PKT_STA = 'sta'
        self.PKT_CHAN = PKT_CHAN = 'chan'
        self.PKT_LOC = PKT_LOC = 'loc'

        from mi.core.kudu import _pkt
        pkt = _pkt._newPkt()
        _pkt._Pkt_pkttype_set(pkt, PKT_TYPE)
        pktchan = _pkt._newPktChannel()
        _pkt._PktChannel_data_set(pktchan, PKT_DATA)
        _pkt._PktChannel_samprate_set(pktchan, PKT_SAMPRATE)
        _pkt._PktChannel_time_set(pktchan, PKT_TIME)
        _pkt._PktChannel_net_set(pktchan, PKT_NET)
        _pkt._PktChannel_sta_set(pktchan, PKT_STA)
        _pkt._PktChannel_chan_set(pktchan, PKT_CHAN)
        _pkt._PktChannel_loc_set(pktchan, PKT_LOC)
        _pkt._Pkt_channels_set(pkt, [pktchan,])
        pkttype, packet, srcname, time = _pkt._stuffPkt(pkt)
        _pkt._freePkt(pkt)

        with patch('mi.dataset.parser.antelope_orb.OrbReapThr') as MockOrbReapThr:
            self.parser = AntelopeOrbParser(self.parser_config, self.parser_state,
                            self.state_callback, self.pub_callback,
                            self.error_callback)
        self.parser._orbreapthr.get = MagicMock(return_value=(PKT_ID, srcname, time, packet))
def makepacket(data, samprate=666, net='net', sta='sta',
                chan='chan', loc='loc', type='GENC', time=0):
    """returns stuffed packet in form (pkttype, packet, srcname, time)

    Packet has one channel.
    """
    from mi.core.kudu import _pkt

    pkt = _pkt._newPkt()
    try:
        _pkt._Pkt_pkttype_set(pkt, type)
        _pkt._Pkt_time_set(pkt, time)
        pktchan = _pkt._newPktChannel()
        _pkt._PktChannel_time_set(pktchan, time)
        _pkt._PktChannel_data_set(pktchan, data)
        _pkt._PktChannel_samprate_set(pktchan, samprate)
        _pkt._PktChannel_net_set(pktchan, net)
        _pkt._PktChannel_sta_set(pktchan, sta)
        _pkt._PktChannel_chan_set(pktchan, chan)
        _pkt._PktChannel_loc_set(pktchan, loc)
        _pkt._Pkt_channels_set(pkt, [pktchan,])
        return _pkt._stuffPkt(pkt)
    finally:
        _pkt._freePkt(pkt)