Exemple #1
0
    def test_simple(self):
        """
        Read test data from the file and pull out data particles one at a time.
        Assert that the results are those we expected.
        This test only verifies the raw data in the particle is correct
        """

        log.debug('-Starting test_simple')
        self.stream_handle = open(
            os.path.join(RESOURCE_PATH, 'node58p1_0.we_wfp.dat'))
        self.parser = DostaLnWfpSioParser(self.config, self.stream_handle,
                                          self.exception_callback)

        result = self.parser.get_records(1)
        self.assertEqual(result, [self.particle_1a])

        result = self.parser.get_records(1)
        self.assertEqual(result, [self.particle_1b])

        result = self.parser.get_records(1)
        self.assertEqual(result, [self.particle_1c])

        result = self.parser.get_records(1)
        self.assertEqual(result, [self.particle_1d])
        self.assertEquals(self.exception_callback_value, [])

        self.stream_handle.close()
    def _build_parser(self, stream_handle):

        parser_config = {
            DataSetDriverConfigKeys.PARTICLE_MODULE:
            'mi.dataset.parser.dosta_ln_wfp_sio',
            DataSetDriverConfigKeys.PARTICLE_CLASS: 'DostaLnWfpSioDataParticle'
        }

        parser = DostaLnWfpSioParser(parser_config, stream_handle,
                                     self._exception_callback)

        return parser
Exemple #3
0
 def test_bad_data(self):
     """
     Ensure that the bad record ( in this case a currupt status message ) causes a sample exception
     """
     self.stream_handle = open(
         os.path.join(RESOURCE_PATH, 'node58p1_BADFLAGS.dat'))
     log.debug('--Starting test_bad_data')
     self.parser = DostaLnWfpSioParser(self.config, self.stream_handle,
                                       self.exception_callback)
     self.parser.get_records(1)
     self.assert_(
         isinstance(self.exception_callback_value[0],
                    UnexpectedDataException))
Exemple #4
0
    def create_yml(self):
        """
        This utility creates a yml file
        """

        #ADCP_data_20130702.PD0 has one record in it
        fid = open(os.path.join(RESOURCE_PATH, 'node58p1_0.we_wfp.dat'), 'rb')

        stream_handle = fid
        parser = DostaLnWfpSioParser(self.config, stream_handle,
                                     self.exception_callback)

        particles = parser.get_records(100)

        self.particle_to_yml(particles, 'node58p1_0.we_wfp.yml')
        fid.close()
Exemple #5
0
    def test_bad_e_record(self):
        """
        Ensure that the bad record causes a sample exception. The file 'bad_e_record.dat'
        includes a record containing one byte less than the expected 30 for the
        dosta_ln_wfp_sio. The 'Number of Data Bytes' and the 'CRC Checksum' values in the
        SIO Mule header have been modified accordingly.
        """
        self.stream_handle = open(
            os.path.join(RESOURCE_PATH, 'bad_e_record.dat'))

        self.parser = DostaLnWfpSioParser(self.config, self.stream_handle,
                                          self.exception_callback)
        self.parser.get_records(1)
        self.assert_(
            isinstance(self.exception_callback_value[0],
                       UnexpectedDataException))
Exemple #6
0
    def test_long_stream(self):
        """
        Test a long stream 
        """

        log.debug('--Starting test_long_stream')
        self.stream_handle = open(
            os.path.join(RESOURCE_PATH, 'node58p1_0.we_wfp.dat'))
        self.stream_handle.seek(0)
        self.parser = DostaLnWfpSioParser(self.config, self.stream_handle,
                                          self.exception_callback)

        result = self.parser.get_records(100)

        self.assert_particles(result, 'node58p1_0.we_wfp.yml', RESOURCE_PATH)
        self.assertEquals(self.exception_callback_value, [])

        self.stream_handle.close()
Exemple #7
0
    def test_get_many(self):
        """
        Read test data from the file and pull out multiple data particles at one time.
        Assert that the results are those we expected.
        """

        log.debug('--Starting test_get_many')
        self.stream_handle = open(
            os.path.join(RESOURCE_PATH, 'node58p1_0.we_wfp.dat'))
        self.parser = DostaLnWfpSioParser(self.config, self.stream_handle,
                                          self.exception_callback)

        result = self.parser.get_records(4)
        self.assertEqual(result, [
            self.particle_1a, self.particle_1b, self.particle_1c,
            self.particle_1d
        ])
        self.assertEquals(self.exception_callback_value, [])

        self.stream_handle.close()