Ejemplo n.º 1
0
    def test_with_yml(self):
        with open(os.path.join(RESOURCE_PATH, 'node58p1_0.wc_wfp.dat')) as stream_handle:
            parser = CtdpfCklWfpSioParser(self.config, stream_handle,
                                      self.exception_callback)

            particles = parser.get_records(50)
            self.assertEqual(len(particles), 50)
            self.assert_particles(particles, 'node58p1_0.wc_wfp.yml', RESOURCE_PATH)

        self.assertEqual(self.exception_callback_value, [])
Ejemplo n.º 2
0
    def test_with_yml(self):
        with open(os.path.join(RESOURCE_PATH,
                               'node58p1_0.wc_wfp.dat')) as stream_handle:
            parser = CtdpfCklWfpSioParser(self.config, stream_handle,
                                          self.exception_callback)

            particles = parser.get_records(50)
            self.assertEqual(len(particles), 50)
            self.assert_particles(particles, 'node58p1_0.wc_wfp.yml',
                                  RESOURCE_PATH)

        self.assertEqual(self.exception_callback_value, [])
Ejemplo n.º 3
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.wc_wfp.dat'), 'rb')

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

        particles = parser.get_records(800)

        self.particle_to_yml(particles, 'node58p1_0.wc_wfp_ALL.yml')
        fid.close()
Ejemplo n.º 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.wc_wfp.dat'), 'rb')

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

        particles = parser.get_records(800)

        self.particle_to_yml(particles, 'node58p1_0.wc_wfp_ALL.yml')
        fid.close()
Ejemplo n.º 5
0
 def test_simple_with_no_time_stamp(self):
     """
     Read test data. Should detect that the data is missing the time stamp.
     Data stream should be rejected.
     """
     log.debug('CAG TEST: NO TIME STAMP')
     stream_handle = StringIO(TEST_DATA_nts)
     parser = CtdpfCklWfpSioParser(self.config, stream_handle,
                                   self.exception_callback)
     # next get records
     result = parser.get_records(4)
     if result:
         log.debug('CAG TEST: FAILED TO DETECT NO TIME STAMP')
         self.fail()
     else:
         log.debug('CAG TEST: NO TIME STAMP DETECTED')
         pass
Ejemplo n.º 6
0
 def test_simple_with_incorrect_header(self):
     """
     Read test data. Should detect that the header is NOT for a WC SIO block
     Data stream should be rejected.
     """
     log.debug('CAG TEST: INCORRECT HEADER')
     stream_handle = StringIO(TEST_DATA_bts)
     parser = CtdpfCklWfpSioParser(self.config, stream_handle,
                                   self.exception_callback)
     # next get records
     result = parser.get_records(4)
     if result:
         log.debug('CAG TEST: FAILED TO DETECT INCORRECT HEADER')
         self.fail()
     else:
         log.debug('CAG TEST: INCORRECT HEADER DETECTED')
         pass
Ejemplo n.º 7
0
    def test_simple_with_decimation_factor(self):
        """
        Read test data. Should detect that there is a decimation factor in the data.
        Check that the data matches the expected results.
        """
        log.debug('CAG TEST: FILE HAS DECIMATION FACTOR')
        stream_handle = StringIO(TEST_DATA_wdf)
        parser = CtdpfCklWfpSioParser(self.config, stream_handle,
                                      self.exception_callback)
        # next get records
        result = parser.get_records(4)

        self.assertEqual(result, [self.particle_meta,
                                  self.particle_a,
                                  self.particle_b,
                                  self.particle_c])
        log.debug('CAG TEST: DECIMATION FACTOR TEST PASSES')
Ejemplo n.º 8
0
 def test_simple_with_incorrect_header(self):
     """
     Read test data. Should detect that the header is NOT for a WC SIO block
     Data stream should be rejected.
     """
     log.debug('CAG TEST: INCORRECT HEADER')
     stream_handle = StringIO(TEST_DATA_bts)
     parser = CtdpfCklWfpSioParser(self.config, stream_handle,
                                   self.exception_callback)
     # next get records
     result = parser.get_records(4)
     if result:
         log.debug('CAG TEST: FAILED TO DETECT INCORRECT HEADER')
         self.fail()
     else:
         log.debug('CAG TEST: INCORRECT HEADER DETECTED')
         pass
Ejemplo n.º 9
0
 def test_simple_with_wrong_header(self):
     """
     Read test data. Should detect that the input stream ?????
     Data stream should be rejected.
     """
     log.debug('CAG TEST: FILE HAS THE WRONG HEADER')
     stream_handle = StringIO(TEST_DATA_wwh)
     parser = CtdpfCklWfpSioParser(self.config, stream_handle,
                                   self.exception_callback)
     # next get records
     result = parser.get_records(1)
     if result:
         log.debug('CAG TEST: FAILED TO DETECT WRONG HEADER')
         self.fail()
     else:
         log.debug('CAG TEST: WRONG HEADER DETECTED')
         pass
Ejemplo n.º 10
0
 def test_simple_with_input_too_short(self):
     """
     Read test data. Should detect that the input stream ?????
     Data stream should be rejected.
     """
     log.debug('CAG TEST: FILE IS TOO SHORT')
     stream_handle = StringIO(TEST_DATA_wts)
     parser = CtdpfCklWfpSioParser(self.config, stream_handle,
                                   self.exception_callback)
     # next get records
     result = parser.get_records(1)
     if result:
         log.debug('CAG TEST: FAILED TO DETECT FILE IS TOO SHORT CASE')
         self.fail()
     else:
         log.debug('CAG TEST: FILE IS TOO SHORT DETECTED')
         pass
Ejemplo n.º 11
0
 def test_simple_with_no_eop(self):
     """
     Read test data. Should detect that the End of Profile (eop) is missing.
     Data stream should be rejected.
     """
     log.debug('CAG TEST: MISSING END OF PROFILE')
     stream_handle = StringIO(TEST_DATA_neop)
     parser = CtdpfCklWfpSioParser(self.config, stream_handle,
                                   self.exception_callback)
     # next get records
     result = parser.get_records(4)
     if result:
         log.debug('CAG TEST: FAILED TO DETECT MISSING END OF PROFILE')
         self.fail()
     else:
         log.debug('CAG TEST: MISSING END OF PROFILE DETECTED')
         pass
Ejemplo n.º 12
0
 def test_simple_with_no_time_stamp(self):
     """
     Read test data. Should detect that the data is missing the time stamp.
     Data stream should be rejected.
     """
     log.debug('CAG TEST: NO TIME STAMP')
     stream_handle = StringIO(TEST_DATA_nts)
     parser = CtdpfCklWfpSioParser(self.config, stream_handle,
                                   self.exception_callback)
     # next get records
     result = parser.get_records(4)
     if result:
         log.debug('CAG TEST: FAILED TO DETECT NO TIME STAMP')
         self.fail()
     else:
         log.debug('CAG TEST: NO TIME STAMP DETECTED')
         pass
Ejemplo n.º 13
0
 def test_simple_with_no_eop(self):
     """
     Read test data. Should detect that the End of Profile (eop) is missing.
     Data stream should be rejected.
     """
     log.debug('CAG TEST: MISSING END OF PROFILE')
     stream_handle = StringIO(TEST_DATA_neop)
     parser = CtdpfCklWfpSioParser(self.config, stream_handle,
                                   self.exception_callback)
     # next get records
     result = parser.get_records(4)
     if result:
         log.debug('CAG TEST: FAILED TO DETECT MISSING END OF PROFILE')
         self.fail()
     else:
         log.debug('CAG TEST: MISSING END OF PROFILE DETECTED')
         pass
Ejemplo n.º 14
0
    def test_simple_with_decimation_factor(self):
        """
        Read test data. Should detect that there is a decimation factor in the data.
        Check that the data matches the expected results.
        """
        log.debug('CAG TEST: FILE HAS DECIMATION FACTOR')
        stream_handle = StringIO(TEST_DATA_wdf)
        parser = CtdpfCklWfpSioParser(self.config, stream_handle,
                                      self.exception_callback)
        # next get records
        result = parser.get_records(4)

        self.assertEqual(result, [
            self.particle_meta, self.particle_a, self.particle_b,
            self.particle_c
        ])
        log.debug('CAG TEST: DECIMATION FACTOR TEST PASSES')
Ejemplo n.º 15
0
 def test_simple_with_input_too_short(self):
     """
     Read test data. Should detect that the input stream ?????
     Data stream should be rejected.
     """
     log.debug('CAG TEST: FILE IS TOO SHORT')
     stream_handle = StringIO(TEST_DATA_wts)
     parser = CtdpfCklWfpSioParser(self.config, stream_handle,
                                   self.exception_callback)
     # next get records
     result = parser.get_records(1)
     if result:
         log.debug('CAG TEST: FAILED TO DETECT FILE IS TOO SHORT CASE')
         self.fail()
     else:
         log.debug('CAG TEST: FILE IS TOO SHORT DETECTED')
         pass
Ejemplo n.º 16
0
 def test_simple_with_wrong_header(self):
     """
     Read test data. Should detect that the input stream ?????
     Data stream should be rejected.
     """
     log.debug('CAG TEST: FILE HAS THE WRONG HEADER')
     stream_handle = StringIO(TEST_DATA_wwh)
     parser = CtdpfCklWfpSioParser(self.config, stream_handle,
                                   self.exception_callback)
     # next get records
     result = parser.get_records(1)
     if result:
         log.debug('CAG TEST: FAILED TO DETECT WRONG HEADER')
         self.fail()
     else:
         log.debug('CAG TEST: WRONG HEADER DETECTED')
         pass
Ejemplo n.º 17
0
    def test_simple_with_no_data_recs(self):
        """
        Read test data. Should detect that there is no data between the header and footer.
        Data out should be a metadata particle only
        """
        log.debug('CAG TEST: NO DATA RECORDS')
        stream_handle = StringIO(TEST_DATA_ndr)
        parser = CtdpfCklWfpSioParser(self.config, stream_handle,
                                      self.exception_callback)
        # next get records
        result = parser.get_records(1)

        if result:
            log.debug('CAG TEST: FAILED TO DETECT NO DATA RECORDS CASE')
            self.fail()
        else:
            log.debug('CAG TEST: NO DATA RECORDS DETECTED')
            pass
Ejemplo n.º 18
0
    def test_simple_with_no_data_recs(self):
        """
        Read test data. Should detect that there is no data between the header and footer.
        Data out should be a metadata particle only
        """
        log.debug('CAG TEST: NO DATA RECORDS')
        stream_handle = StringIO(TEST_DATA_ndr)
        parser = CtdpfCklWfpSioParser(self.config, stream_handle,
                                      self.exception_callback)
        # next get records
        result = parser.get_records(1)

        if result:
            log.debug('CAG TEST: FAILED TO DETECT NO DATA RECORDS CASE')
            self.fail()
        else:
            log.debug('CAG TEST: NO DATA RECORDS DETECTED')
            pass
Ejemplo n.º 19
0
    def _build_parser(self, stream_handle):

        parser_config = {
            DataSetDriverConfigKeys.PARTICLE_MODULE: 'mi.dataset.parser.ctdpf_ckl_wfp_sio',
            DataSetDriverConfigKeys.PARTICLE_CLASS: ['CtdpfCklWfpSioDataParticle',
                                                     'CtdpfCklWfpSioMetadataParticle']
        }

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

        return parser