def test_invalid_tide_record(self):
        """
        The file used here has a damaged tide record ( the p = $$$ is replaced by a q = $$$ )
        """
        log.debug('===== START TEST INVALID TIDE RECORD =====')

        with open(os.path.join(RESOURCE_PATH, '20140105_invts.presf.log'), 'r') as file_handle:

            num_particles_to_request = 20
            num_expected_particles = 19

            parser = PresfAbcDclParser(file_handle, self.exception_callback, True)
            particles = parser.get_records(num_particles_to_request)

            self.assertEquals(len(particles), num_expected_particles)
            self.assert_particles(particles, "20140105_invts.presf_telem.yml", RESOURCE_PATH)

            for i in range(len(self.exception_callback_value)):
                self.assert_(isinstance(self.exception_callback_value[i], RecoverableSampleException))
 
        with open(os.path.join(RESOURCE_PATH, '20140105_invts.presf.log'), 'r') as file_handle:

            num_particles_to_request = 20
            num_expected_particles = 19

            parser = PresfAbcDclParser(file_handle, self.exception_callback, False)
            particles = parser.get_records(num_particles_to_request)

            self.assertEquals(len(particles), num_expected_particles)
            self.assert_particles(particles, "20140105_invts.presf_recov.yml", RESOURCE_PATH)

            for i in range(len(self.exception_callback_value)):
                self.assert_(isinstance(self.exception_callback_value[i], RecoverableSampleException))

        log.debug('===== END TEST INVALID TIDE RECORD =====')
    def test_get_many(self):
        """
        Read test data and pull out multiple data particles at one time.
        Assert that the results are those we expected.
        """

        log.debug('===== START TEST MANY =====')
        with open(os.path.join(RESOURCE_PATH, '20140105_trim.presf.log'), 'r') as file_handle:

            parser = PresfAbcDclParser(file_handle, self.exception_callback, True)
            particles = parser.get_records(20)

            # Make sure there were no errors
            self.assertTrue(len(self.exception_callback_value) == 0)
            # Make sure we obtained 20 particles
            self.assertTrue(len(particles) == 20)
            self.assert_particles(particles, "20140105_trim.presf_telem.yml", RESOURCE_PATH)

        with open(os.path.join(RESOURCE_PATH, '20140105_trim.presf.log'), 'r') as file_handle:

            parser = PresfAbcDclParser(file_handle, self.exception_callback, False)
            particles = parser.get_records(20)
                
            # Make sure there were no errors
            self.assertTrue(len(self.exception_callback_value) == 0)
            # Make sure we obtained 20 particles
            self.assertTrue(len(particles) == 20)
            self.assert_particles(particles, "20140105_trim.presf_recov.yml", RESOURCE_PATH)

        log.debug('===== END TEST MANY =====')
예제 #3
0
    def test_no_particles(self):
        """
        Verify that no particles are produced if the input file
        has no instrument records.
        """
        log.debug('===== START TEST NO PARTICLES =====')

        with open(os.path.join(RESOURCE_PATH, '20140417.presf1.log'),
                  'r') as file_handle:

            NUM_PARTICLES_TO_REQUEST = 10
            NUM_EXPECTED_PARTICLES = 0

            parser = PresfAbcDclParser(
                self.config.get(DataTypeKey.PRESF_ABC_DCL_TELEMETERED), None,
                file_handle, lambda state, ingested: None, lambda data: None,
                self.exception_callback)

            particles = parser.get_records(NUM_PARTICLES_TO_REQUEST)

            self.assertEquals(len(particles), NUM_EXPECTED_PARTICLES)

            self.assertEqual(self._exception_occurred, False)

        log.debug('===== END TEST NO PARTICLES =====')
    def test_simple(self):
        """
        Read data from a file and pull out data particles
        one at a time. Verify that the results are those we expected.
        """
        log.debug('===== START TEST SIMPLE =====')

        with open(os.path.join(RESOURCE_PATH, '20140417.presf3.log'), 'r') as file_handle:

            parser = PresfAbcDclParser(file_handle, self.exception_callback, True)
            # file has one tide particle and one wave particle
            particles = parser.get_records(2)
                
            # Make sure there were no errors
            self.assertTrue(len(self.exception_callback_value) == 0)
            # Make sure we obtained 2 particles
            self.assertTrue(len(particles) == 2)
            self.assert_particles(particles, '20140417.presf3_telem.yml', RESOURCE_PATH)

        with open(os.path.join(RESOURCE_PATH, '20140417.presf3.log'), 'r') as file_handle:

            parser = PresfAbcDclParser(file_handle, self.exception_callback, False)
            # file has one tide particle and one wave particle
            particles = parser.get_records(2)
                
            # Make sure there were no errors
            self.assertTrue(len(self.exception_callback_value) == 0)
            # Make sure we obtained 2 particles
            self.assertTrue(len(particles) == 2)
            self.assert_particles(particles, '20140417.presf3_recov.yml', RESOURCE_PATH)

        log.debug('===== END TEST SIMPLE =====')
    def test_long_stream(self):
        """
        Test a long stream
        """
        log.debug('===== START TEST LONG STREAM =====')
        with open(os.path.join(RESOURCE_PATH, '20140105.presf.log'), 'r') as file_handle:

            parser = PresfAbcDclParser(file_handle, self.exception_callback, True)
            particles = parser.get_records(48)
                
            # Make sure there were no errors
            self.assertTrue(len(self.exception_callback_value) == 0)
            # Make sure we obtained 20 particles
            self.assertTrue(len(particles) == 48)

        log.debug('===== END TEST LONG STREAM =====')
    def test_Bug_3021(self):
        """
        Read data from a file and pull out data particles
        one at a time. Verify that the results are those we expected.
        """
        log.debug('===== START TEST SIMPLE =====')

        with open(os.path.join(RESOURCE_PATH, '20141204.presf.log'), 'r') as file_handle:

            parser = PresfAbcDclParser(file_handle, self.exception_callback, True)
            # file has one tide particle and one wave particle
            particles = parser.get_records(20)

            # Make sure there was one error due to the "time out"
            self.assertTrue(len(self.exception_callback_value) == 1)
            # Make sure we obtained 0 particles
            self.assertEquals(len(particles), 0)
예제 #7
0
    def test_invalid_wave_record(self):
        """
        Two of the wave records in this file are damaged.  The first is missing the pt subrecord,
        and the second is missing the termination of the wave record.
        """
        log.debug('===== START TEST INVALID WAVE RECORD =====')

        with open(os.path.join(RESOURCE_PATH, '20140105_invwv.presf.log'), 'r') as file_handle:

            NUM_PARTICLES_TO_REQUEST = 20
            NUM_EXPECTED_PARTICLES = 18

            parser = PresfAbcDclParser(self.config.get(DataTypeKey.PRESF_ABC_DCL_TELEMETERED),
                                       None, file_handle,
                                       lambda state, ingested: None, lambda data: None,
                                       self.exception_callback)

            particles = parser.get_records(NUM_PARTICLES_TO_REQUEST)
            
            self.assertEquals(len(particles), NUM_EXPECTED_PARTICLES)

            self.assert_particles(particles, "20140105_invwv.presf_telem.yml", RESOURCE_PATH)

            for i in range(len(self.exception_callback_value)):
                self.assert_(isinstance(self.exception_callback_value[i], RecoverableSampleException))
 
        with open(os.path.join(RESOURCE_PATH, '20140105_invwv.presf.log'), 'r') as file_handle:

            NUM_PARTICLES_TO_REQUEST = 20
            NUM_EXPECTED_PARTICLES = 18

            parser = PresfAbcDclParser(self.config.get(DataTypeKey.PRESF_ABC_DCL_RECOVERED),
                                       None, file_handle,
                                       lambda state, ingested: None, lambda data: None,
                                       self.exception_callback)

            particles = parser.get_records(NUM_PARTICLES_TO_REQUEST)

            self.assertEquals(len(particles), NUM_EXPECTED_PARTICLES)

            self.assert_particles(particles, "20140105_invwv.presf_recov.yml", RESOURCE_PATH)

            for i in range(len(self.exception_callback_value)):
                self.assert_(isinstance(self.exception_callback_value[i], RecoverableSampleException))
 
        log.debug('===== END TEST INVALID TIDE RECORD =====')
예제 #8
0
    def test_invalid_tide_record(self):
        """
        The file used here has a damaged tide record ( the p = $$$ is replaced by a q = $$$ )
        """
        log.debug('===== START TEST INVALID TIDE RECORD =====')

        with open(os.path.join(RESOURCE_PATH, '20140105_invts.presf.log'), 'r') as file_handle:

            NUM_PARTICLES_TO_REQUEST = 20
            NUM_EXPECTED_PARTICLES = 19

            parser = PresfAbcDclParser(self.config.get(DataTypeKey.PRESF_ABC_DCL_TELEMETERED),
                                       None, file_handle,
                                       lambda state, ingested: None, lambda data: None,
                                       self.exception_callback)

            particles = parser.get_records(NUM_PARTICLES_TO_REQUEST)

            self.assertEquals(len(particles), NUM_EXPECTED_PARTICLES)

            self.assert_particles(particles, "20140105_invts.presf_telem.yml", RESOURCE_PATH)

            for i in range(len(self.exception_callback_value)):
                self.assert_(isinstance(self.exception_callback_value[i], RecoverableSampleException))
 
        with open(os.path.join(RESOURCE_PATH, '20140105_invts.presf.log'), 'r') as file_handle:

            NUM_PARTICLES_TO_REQUEST = 20
            NUM_EXPECTED_PARTICLES = 19

            parser = PresfAbcDclParser(self.config.get(DataTypeKey.PRESF_ABC_DCL_RECOVERED),
                                       None, file_handle,
                                       lambda state, ingested: None, lambda data: None,
                                       self.exception_callback)

            particles = parser.get_records(NUM_PARTICLES_TO_REQUEST)

            self.assertEquals(len(particles), NUM_EXPECTED_PARTICLES)

            self.assert_particles(particles, "20140105_invts.presf_recov.yml", RESOURCE_PATH)

            for i in range(len(self.exception_callback_value)):
                self.assert_(isinstance(self.exception_callback_value[i], RecoverableSampleException))

        log.debug('===== END TEST INVALID TIDE RECORD =====')
예제 #9
0
    def test_long_stream(self):
        """
        Test a long stream
        """
        log.debug('===== START TEST LONG STREAM =====')
        with open(os.path.join(RESOURCE_PATH, '20140105.presf.log'), 'r') as file_handle:

            parser = PresfAbcDclParser(file_handle, self.exception_callback, True)
    
            particles = parser.get_records(48)
                
            # Make sure there were no errors
            self.assertTrue(len(self.exception_callback_value) == 0)

            # Make sure we obtained 20 particles
            self.assertTrue(len(particles) == 48)

        log.debug('===== END TEST LONG STREAM =====')
예제 #10
0
    def test_long_stream(self):
        """
        Test a long stream
        """
        log.debug('===== START TEST LONG STREAM =====')
        with open(os.path.join(RESOURCE_PATH, '20140105.presf.log'), 'r') as file_handle:

            parser = PresfAbcDclParser(self.config.get(DataTypeKey.PRESF_ABC_DCL_TELEMETERED),
                                       None, file_handle,
                                       lambda state, ingested: None, lambda data: None,
                                       self.exception_callback)
    
            particles = parser.get_records(48)
                
            # Make sure we obtained 20 particles
            self.assertTrue(len(particles) == 48)

        log.debug('===== END TEST LONG STREAM =====')
예제 #11
0
    def test_Bug_3021(self):
        """
        Read data from a file and pull out data particles
        one at a time. Verify that the results are those we expected.
        """
        log.debug('===== START TEST SIMPLE =====')

        with open(os.path.join(RESOURCE_PATH, '20141204.presf.log'), 'r') as file_handle:

            parser = PresfAbcDclParser(file_handle, self.exception_callback, True)

            # file has one tide particle and one wave particle
            particles = parser.get_records(20)

            # Make sure there was one error due to the "time out"
            self.assertTrue(len(self.exception_callback_value) == 1)

            # Make sure we obtained 0 particles
            self.assertEquals(len(particles), 0)
예제 #12
0
    def test_long_stream(self):
        """
        Test a long stream
        """
        log.debug('===== START TEST LONG STREAM =====')
        with open(os.path.join(RESOURCE_PATH, '20140105.presf.log'),
                  'r') as file_handle:

            parser = PresfAbcDclParser(
                self.config.get(DataTypeKey.PRESF_ABC_DCL_TELEMETERED), None,
                file_handle, lambda state, ingested: None, lambda data: None,
                self.exception_callback)

            particles = parser.get_records(48)

            # Make sure we obtained 20 particles
            self.assertTrue(len(particles) == 48)

        log.debug('===== END TEST LONG STREAM =====')
예제 #13
0
    def test_no_particles(self):
        """
        Verify that no particles are produced if the input file
        has no instrument records.
        """
        log.debug('===== START TEST NO PARTICLES =====')

        with open(os.path.join(RESOURCE_PATH, '20140417.presf1.log'), 'r') as file_handle:

            num_particles_to_request = 10
            num_expected_particles = 0

            parser = PresfAbcDclParser(file_handle, self.exception_callback, True)
            particles = parser.get_records(num_particles_to_request)

            # Make sure there were no errors
            self.assertTrue(len(self.exception_callback_value) == 0)
            self.assertEquals(len(particles), num_expected_particles)
            self.assertEqual(len(self.exception_callback_value), 0)

        log.debug('===== END TEST NO PARTICLES =====')
예제 #14
0
    def test_invalid_wave_record(self):
        """
        Two of the wave records in this file are damaged.  The first is missing the pt subrecord,
        and the second is missing the termination of the wave record.
        """
        log.debug('===== START TEST INVALID WAVE RECORD =====')

        with open(os.path.join(RESOURCE_PATH, '20140105_invwv.presf.log'), 'r') as file_handle:

            num_particles_to_request = 20
            num_expected_particles = 18

            parser = PresfAbcDclParser(file_handle, self.exception_callback, True)

            particles = parser.get_records(num_particles_to_request)
            
            self.assertEquals(len(particles), num_expected_particles)

            self.assert_particles(particles, "20140105_invwv.presf_telem.yml", RESOURCE_PATH)

            for i in range(len(self.exception_callback_value)):
                self.assert_(isinstance(self.exception_callback_value[i], RecoverableSampleException))
 
        with open(os.path.join(RESOURCE_PATH, '20140105_invwv.presf.log'), 'r') as file_handle:

            num_particles_to_request = 20
            num_expected_particles = 18

            parser = PresfAbcDclParser(file_handle, self.exception_callback, False)

            particles = parser.get_records(num_particles_to_request)

            self.assertEquals(len(particles), num_expected_particles)

            self.assert_particles(particles, "20140105_invwv.presf_recov.yml", RESOURCE_PATH)

            for i in range(len(self.exception_callback_value)):
                self.assert_(isinstance(self.exception_callback_value[i], RecoverableSampleException))
 
        log.debug('===== END TEST INVALID TIDE RECORD =====')
예제 #15
0
    def test_simple(self):
        """
        Read data from a file and pull out data particles
        one at a time. Verify that the results are those we expected.
        """
        log.debug('===== START TEST SIMPLE =====')

        with open(os.path.join(RESOURCE_PATH, '20140417.presf3.log'), 'r') as file_handle:

            parser = PresfAbcDclParser(self.config.get(DataTypeKey.PRESF_ABC_DCL_TELEMETERED),
                                       None, file_handle,
                                       lambda state, ingested: None, lambda data: None,
                                       self.exception_callback)
            
            # file has one tide particle and one wave particle
            particles = parser.get_records(2)
                
            # Make sure we obtained 2 particles
            self.assertTrue(len(particles) == 2)
       
            self.assert_particles(particles, '20140417.presf3_telem.yml', RESOURCE_PATH)

        with open(os.path.join(RESOURCE_PATH, '20140417.presf3.log'), 'r') as file_handle:

            parser = PresfAbcDclParser(self.config.get(DataTypeKey.PRESF_ABC_DCL_RECOVERED),
                                       None, file_handle,
                                       lambda state, ingested: None, lambda data: None,
                                       self.exception_callback)
            
            # file has one tide particle and one wave particle
            particles = parser.get_records(2)
                
            # Make sure we obtained 2 particles
            self.assertTrue(len(particles) == 2)
       
            self.assert_particles(particles, '20140417.presf3_recov.yml', RESOURCE_PATH)

        log.debug('===== END TEST SIMPLE =====')
예제 #16
0
    def test_no_particles(self):
        """
        Verify that no particles are produced if the input file
        has no instrument records.
        """
        log.debug('===== START TEST NO PARTICLES =====')

        with open(os.path.join(RESOURCE_PATH, '20140417.presf1.log'),
                  'r') as file_handle:

            num_particles_to_request = 10
            num_expected_particles = 0

            parser = PresfAbcDclParser(file_handle, self.exception_callback,
                                       True)
            particles = parser.get_records(num_particles_to_request)

            # Make sure there were no errors
            self.assertTrue(len(self.exception_callback_value) == 0)
            self.assertEquals(len(particles), num_expected_particles)
            self.assertEqual(len(self.exception_callback_value), 0)

        log.debug('===== END TEST NO PARTICLES =====')
예제 #17
0
    def test_no_particles(self):
        """
        Verify that no particles are produced if the input file
        has no instrument records.
        """
        log.debug('===== START TEST NO PARTICLES =====')

        with open(os.path.join(RESOURCE_PATH, '20140417.presf1.log'), 'r') as file_handle:

            NUM_PARTICLES_TO_REQUEST = 10
            NUM_EXPECTED_PARTICLES = 0

            parser = PresfAbcDclParser(self.config.get(DataTypeKey.PRESF_ABC_DCL_TELEMETERED),
                                       None, file_handle,
                                       lambda state, ingested: None, lambda data: None,
                                       self.exception_callback)

            particles = parser.get_records(NUM_PARTICLES_TO_REQUEST)

            self.assertEquals(len(particles), NUM_EXPECTED_PARTICLES)

            self.assertEqual(self._exception_occurred, False)

        log.debug('===== END TEST NO PARTICLES =====')
    def process(self):
        def exception_callback(exception):
            log.debug("ERROR: %r", exception)
            self._particleDataHdlrObj.setParticleDataCaptureFailure()

        with open(self._sourceFilePath, 'r') as stream_handle:
            parser = PresfAbcDclParser(parser_config.get(self._data_type_key),
                                       None, stream_handle,
                                       lambda state, ingested: None,
                                       lambda data: None, exception_callback)

            driver = DataSetDriver(parser, self._particleDataHdlrObj)
            driver.processFileStream()

        return self._particleDataHdlrObj
예제 #19
0
    def test_get_many(self):
        """
        Read test data and pull out multiple data particles at one time.
        Assert that the results are those we expected.
        """

        log.debug('===== START TEST MANY =====')
        with open(os.path.join(RESOURCE_PATH, '20140105_trim.presf.log'), 'r') as file_handle:

            parser = PresfAbcDclParser(self.config.get(DataTypeKey.PRESF_ABC_DCL_TELEMETERED),
                                       None, file_handle,
                                       lambda state, ingested: None, lambda data: None,
                                       self.exception_callback)
            
            particles = parser.get_records(20)
                
            # Make sure we obtained 20 particles
            self.assertTrue(len(particles) == 20)
    
            self.assert_particles(particles, "20140105_trim.presf_telem.yml", RESOURCE_PATH)

        with open(os.path.join(RESOURCE_PATH, '20140105_trim.presf.log'), 'r') as file_handle:

            parser = PresfAbcDclParser(self.config.get(DataTypeKey.PRESF_ABC_DCL_RECOVERED),
                                       None, file_handle,
                                       lambda state, ingested: None, lambda data: None,
                                       self.exception_callback)
            
            particles = parser.get_records(20)
                
            # Make sure we obtained 20 particles
            self.assertTrue(len(particles) == 20)
    
            self.assert_particles(particles, "20140105_trim.presf_recov.yml", RESOURCE_PATH)

        log.debug('===== END TEST MANY =====')
예제 #20
0
    def test_invalid_wave_record(self):
        """
        Two of the wave records in this file are damaged.  The first is missing the pt subrecord,
        and the second is missing the termination of the wave record.
        """
        log.debug('===== START TEST INVALID WAVE RECORD =====')

        with open(os.path.join(RESOURCE_PATH, '20140105_invwv.presf.log'),
                  'r') as file_handle:

            NUM_PARTICLES_TO_REQUEST = 20
            NUM_EXPECTED_PARTICLES = 18

            parser = PresfAbcDclParser(
                self.config.get(DataTypeKey.PRESF_ABC_DCL_TELEMETERED), None,
                file_handle, lambda state, ingested: None, lambda data: None,
                self.exception_callback)

            particles = parser.get_records(NUM_PARTICLES_TO_REQUEST)

            self.assertEquals(len(particles), NUM_EXPECTED_PARTICLES)

            self.assert_particles(particles, "20140105_invwv.presf_telem.yml",
                                  RESOURCE_PATH)

            for i in range(len(self.exception_callback_value)):
                self.assert_(
                    isinstance(self.exception_callback_value[i],
                               RecoverableSampleException))

        with open(os.path.join(RESOURCE_PATH, '20140105_invwv.presf.log'),
                  'r') as file_handle:

            NUM_PARTICLES_TO_REQUEST = 20
            NUM_EXPECTED_PARTICLES = 18

            parser = PresfAbcDclParser(
                self.config.get(DataTypeKey.PRESF_ABC_DCL_RECOVERED), None,
                file_handle, lambda state, ingested: None, lambda data: None,
                self.exception_callback)

            particles = parser.get_records(NUM_PARTICLES_TO_REQUEST)

            self.assertEquals(len(particles), NUM_EXPECTED_PARTICLES)

            self.assert_particles(particles, "20140105_invwv.presf_recov.yml",
                                  RESOURCE_PATH)

            for i in range(len(self.exception_callback_value)):
                self.assert_(
                    isinstance(self.exception_callback_value[i],
                               RecoverableSampleException))

        log.debug('===== END TEST INVALID TIDE RECORD =====')
예제 #21
0
    def test_invalid_tide_record(self):
        """
        The file used here has a damaged tide record ( the p = $$$ is replaced by a q = $$$ )
        """
        log.debug('===== START TEST INVALID TIDE RECORD =====')

        with open(os.path.join(RESOURCE_PATH, '20140105_invts.presf.log'),
                  'r') as file_handle:

            NUM_PARTICLES_TO_REQUEST = 20
            NUM_EXPECTED_PARTICLES = 19

            parser = PresfAbcDclParser(
                self.config.get(DataTypeKey.PRESF_ABC_DCL_TELEMETERED), None,
                file_handle, lambda state, ingested: None, lambda data: None,
                self.exception_callback)

            particles = parser.get_records(NUM_PARTICLES_TO_REQUEST)

            self.assertEquals(len(particles), NUM_EXPECTED_PARTICLES)

            self.assert_particles(particles, "20140105_invts.presf_telem.yml",
                                  RESOURCE_PATH)

            for i in range(len(self.exception_callback_value)):
                self.assert_(
                    isinstance(self.exception_callback_value[i],
                               RecoverableSampleException))

        with open(os.path.join(RESOURCE_PATH, '20140105_invts.presf.log'),
                  'r') as file_handle:

            NUM_PARTICLES_TO_REQUEST = 20
            NUM_EXPECTED_PARTICLES = 19

            parser = PresfAbcDclParser(
                self.config.get(DataTypeKey.PRESF_ABC_DCL_RECOVERED), None,
                file_handle, lambda state, ingested: None, lambda data: None,
                self.exception_callback)

            particles = parser.get_records(NUM_PARTICLES_TO_REQUEST)

            self.assertEquals(len(particles), NUM_EXPECTED_PARTICLES)

            self.assert_particles(particles, "20140105_invts.presf_recov.yml",
                                  RESOURCE_PATH)

            for i in range(len(self.exception_callback_value)):
                self.assert_(
                    isinstance(self.exception_callback_value[i],
                               RecoverableSampleException))

        log.debug('===== END TEST INVALID TIDE RECORD =====')
예제 #22
0
    def test_simple(self):
        """
        Read data from a file and pull out data particles
        one at a time. Verify that the results are those we expected.
        """
        log.debug('===== START TEST SIMPLE =====')

        with open(os.path.join(RESOURCE_PATH, '20140417.presf3.log'),
                  'r') as file_handle:

            parser = PresfAbcDclParser(
                self.config.get(DataTypeKey.PRESF_ABC_DCL_TELEMETERED), None,
                file_handle, lambda state, ingested: None, lambda data: None,
                self.exception_callback)

            # file has one tide particle and one wave particle
            particles = parser.get_records(2)

            # Make sure there were no errors
            self.assertTrue(len(self.exception_callback_value) == 0)

            # Make sure we obtained 2 particles
            self.assertTrue(len(particles) == 2)

            self.assert_particles(particles, '20140417.presf3_telem.yml',
                                  RESOURCE_PATH)

        with open(os.path.join(RESOURCE_PATH, '20140417.presf3.log'),
                  'r') as file_handle:

            parser = PresfAbcDclParser(
                self.config.get(DataTypeKey.PRESF_ABC_DCL_RECOVERED), None,
                file_handle, lambda state, ingested: None, lambda data: None,
                self.exception_callback)

            # file has one tide particle and one wave particle
            particles = parser.get_records(2)

            # Make sure there were no errors
            self.assertTrue(len(self.exception_callback_value) == 0)

            # Make sure we obtained 2 particles
            self.assertTrue(len(particles) == 2)

            self.assert_particles(particles, '20140417.presf3_recov.yml',
                                  RESOURCE_PATH)

        log.debug('===== END TEST SIMPLE =====')
예제 #23
0
    def test_get_many(self):
        """
        Read test data and pull out multiple data particles at one time.
        Assert that the results are those we expected.
        """

        log.debug('===== START TEST MANY =====')
        with open(os.path.join(RESOURCE_PATH, '20140105_trim.presf.log'),
                  'r') as file_handle:

            parser = PresfAbcDclParser(
                self.config.get(DataTypeKey.PRESF_ABC_DCL_TELEMETERED), None,
                file_handle, lambda state, ingested: None, lambda data: None,
                self.exception_callback)

            particles = parser.get_records(20)

            # Make sure there were no errors
            self.assertTrue(len(self.exception_callback_value) == 0)

            # Make sure we obtained 20 particles
            self.assertTrue(len(particles) == 20)

            self.assert_particles(particles, "20140105_trim.presf_telem.yml",
                                  RESOURCE_PATH)

        with open(os.path.join(RESOURCE_PATH, '20140105_trim.presf.log'),
                  'r') as file_handle:

            parser = PresfAbcDclParser(
                self.config.get(DataTypeKey.PRESF_ABC_DCL_RECOVERED), None,
                file_handle, lambda state, ingested: None, lambda data: None,
                self.exception_callback)

            particles = parser.get_records(20)

            # Make sure there were no errors
            self.assertTrue(len(self.exception_callback_value) == 0)

            # Make sure we obtained 20 particles
            self.assertTrue(len(particles) == 20)

            self.assert_particles(particles, "20140105_trim.presf_recov.yml",
                                  RESOURCE_PATH)

        log.debug('===== END TEST MANY =====')
예제 #24
0
    def test_invalid_wave_record(self):
        """
        Two of the wave records in this file are damaged.  The first is missing the pt subrecord,
        and the second is missing the termination of the wave record.
        """
        log.debug('===== START TEST INVALID WAVE RECORD =====')

        with open(os.path.join(RESOURCE_PATH, '20140105_invwv.presf.log'),
                  'r') as file_handle:

            num_particles_to_request = 20
            num_expected_particles = 18

            parser = PresfAbcDclParser(file_handle, self.exception_callback,
                                       True)
            particles = parser.get_records(num_particles_to_request)

            self.assertEquals(len(particles), num_expected_particles)
            self.assert_particles(particles, "20140105_invwv.presf_telem.yml",
                                  RESOURCE_PATH)

            for i in range(len(self.exception_callback_value)):
                self.assert_(
                    isinstance(self.exception_callback_value[i],
                               RecoverableSampleException))

        with open(os.path.join(RESOURCE_PATH, '20140105_invwv.presf.log'),
                  'r') as file_handle:

            num_particles_to_request = 20
            num_expected_particles = 18

            parser = PresfAbcDclParser(file_handle, self.exception_callback,
                                       False)
            particles = parser.get_records(num_particles_to_request)

            self.assertEquals(len(particles), num_expected_particles)
            self.assert_particles(particles, "20140105_invwv.presf_recov.yml",
                                  RESOURCE_PATH)

            for i in range(len(self.exception_callback_value)):
                self.assert_(
                    isinstance(self.exception_callback_value[i],
                               RecoverableSampleException))

        log.debug('===== END TEST INVALID TIDE RECORD =====')
예제 #25
0
    def test_invalid_tide_record(self):
        """
        The file used here has a damaged tide record ( the p = $$$ is replaced by a q = $$$ )
        """
        log.debug('===== START TEST INVALID TIDE RECORD =====')

        with open(os.path.join(RESOURCE_PATH, '20140105_invts.presf.log'),
                  'r') as file_handle:

            num_particles_to_request = 20
            num_expected_particles = 19

            parser = PresfAbcDclParser(file_handle, self.exception_callback,
                                       True)
            particles = parser.get_records(num_particles_to_request)

            self.assertEquals(len(particles), num_expected_particles)
            self.assert_particles(particles, "20140105_invts.presf_telem.yml",
                                  RESOURCE_PATH)

            for i in range(len(self.exception_callback_value)):
                self.assert_(
                    isinstance(self.exception_callback_value[i],
                               RecoverableSampleException))

        with open(os.path.join(RESOURCE_PATH, '20140105_invts.presf.log'),
                  'r') as file_handle:

            num_particles_to_request = 20
            num_expected_particles = 19

            parser = PresfAbcDclParser(file_handle, self.exception_callback,
                                       False)
            particles = parser.get_records(num_particles_to_request)

            self.assertEquals(len(particles), num_expected_particles)
            self.assert_particles(particles, "20140105_invts.presf_recov.yml",
                                  RESOURCE_PATH)

            for i in range(len(self.exception_callback_value)):
                self.assert_(
                    isinstance(self.exception_callback_value[i],
                               RecoverableSampleException))

        log.debug('===== END TEST INVALID TIDE RECORD =====')
예제 #26
0
    def test_get_many(self):
        """
        Read test data and pull out multiple data particles at one time.
        Assert that the results are those we expected.
        """

        log.debug('===== START TEST MANY =====')
        with open(os.path.join(RESOURCE_PATH, '20140105_trim.presf.log'), 'r') as file_handle:

            parser = PresfAbcDclParser(file_handle, self.exception_callback, True)
            
            particles = parser.get_records(20)
                
            # Make sure there were no errors
            self.assertTrue(len(self.exception_callback_value) == 0)

            # Make sure we obtained 20 particles
            self.assertTrue(len(particles) == 20)
    
            self.assert_particles(particles, "20140105_trim.presf_telem.yml", RESOURCE_PATH)

        with open(os.path.join(RESOURCE_PATH, '20140105_trim.presf.log'), 'r') as file_handle:

            parser = PresfAbcDclParser(file_handle, self.exception_callback, False)
            
            particles = parser.get_records(20)
                
            # Make sure there were no errors
            self.assertTrue(len(self.exception_callback_value) == 0)

            # Make sure we obtained 20 particles
            self.assertTrue(len(particles) == 20)
    
            self.assert_particles(particles, "20140105_trim.presf_recov.yml", RESOURCE_PATH)

        log.debug('===== END TEST MANY =====')
    def _build_parser(self, stream_handle):

        parser = PresfAbcDclParser(stream_handle, self._exception_callback,
                                   True)

        return parser