Example #1
0
    def _build_parser(self, parser_state, infile):
        config = self._parser_config
        config.update({
            'particle_module': 'mi.dataset.parser.adcpa',
            'particle_class': 'ADCPA_PD0_PARSED_DataParticle'
        })
        log.debug("MYCONFIG: %s", config)
        self._parser = AdcpaParser(config, parser_state, infile,
                                   self._save_parser_state,
                                   self._data_callback)

        return self._parser
Example #2
0
    def test_get_multi(self):
        """
        Test that the parser will read the data from a file and return multiple
        valid particles and values within the particles.
        """
        # reset the parser
        self.stream_handle.seek(0)
        self.position = {StateKey.POSITION: 0}
        self.parser = AdcpaParser(self.config, self.position, self.stream_handle,
                                  self.pos_callback, self.pub_callback)
        self.test01['byte_count'] = [1338, 1338, 1338]

        # get 3 records from the parser, and compare to expected values
        particles = self.parser.get_records(3)
        self.parse_particles(particles)
        self.assert_result(self.test01, self.parsed_data, particles)
Example #3
0
    def test_get_data(self):
        """
        Test that the parser will read the data from a file and return valid
        particles and values within the particles.
        """
        # reset the parser
        self.stream_handle.seek(0)
        self.position = {StateKey.POSITION: 0}
        self.parser = AdcpaParser(self.config, self.position, self.stream_handle,
                                  self.pos_callback, self.pub_callback)
        self.test01['byte_count'] = [446, 892, 1338]

        # get three records from the parser, one at a time, and compare to expected values
        for i in range(0, 2):
            particle = self.parser.get_records(1)
            self.parse_particles(particle)
            self.assert_result(self.test01, self.parsed_data, particle, i)
Example #4
0
    def test_set_state(self):
        """
        Test that the parser will start up at some mid-point in the file, and
        continue reading data from a file, returning valid particles and values
        within the particles.

        This tests the ability to set the POSITION state and have the parser
        pick up from there.
        """
        # reset the parser
        self.stream_handle.seek(0)
        self.position = {StateKey.POSITION: 10704}
        self.parser = AdcpaParser(self.config, self.position, self.stream_handle,
                                  self.pos_callback, self.pub_callback)

        # get 3 records from the parser, and compare to expected values
        particles = self.parser.get_records(3)
        self.parse_particles(particles)
        self.assert_result(self.test03, self.parsed_data, particles)
Example #5
0
    def test_get_bottom(self):
        """
        Test that the parser will start up at some mid-point in the file, and
        continue reading data from a file, returning valid particles and values
        within the particles.

        This duplicates test_set_state above, and extends it by grabbing the
        additional bottom-tracking (BT) data that will appear at this point in
        the file. This validates that the parser will correctly start adding
        the BT data when it is encountered. The first 2 particles will not have
        BT data, while the last three will.
        """
        # reset the parser
        self.stream_handle.seek(0)
        self.position = {StateKey.POSITION: 90538}
        self.parser = AdcpaParser(self.config, self.position, self.stream_handle,
                                  self.pos_callback, self.pub_callback)

        # get 3 records from the parser, and compare to expected values
        particles = self.parser.get_records(5)
        self.parse_particles(particles)
        self.assert_result(self.test04, self.parsed_data, particles)