def test_bad_header(self): """ The file used in this test has a header with 'D0' instead of 'FL' in the first record. (A dosta_abcdjm_sio record was copied in for the test.) This results in 5 particles being retrieved instead of 6, and also result in the exception callback being called. """ log.debug('===== START TEST BAD HEADER =====') num_particles_to_request = 6 num_expected_particles = 5 self.stream_handle = open( os.path.join(RESOURCE_PATH, 'FLO_bad_header.DAT')) self.build_recov_parser() particles = self.parser.get_records(num_particles_to_request) self.assertEquals(len(particles), num_expected_particles) particle_to_yml(particles, os.path.join(RESOURCE_PATH, 'flo_bad_header.yml')) self.assert_particles(particles, "flo_bad_header.yml", RESOURCE_PATH) log.debug('Exceptions : %s', self.exception_callback_value) self.assert_( isinstance(self.exception_callback_value[0], UnexpectedDataException)) log.debug('===== END TEST BAD HEADER =====')
def test_bad_header(self): """ The file used in this test has a header with 'D0' instead of 'FL' in the first record. (A dosta_abcdjm_sio record was copied in for the test.) This results in 5 particles being retrieved instead of 6, and also result in the exception callback being called. """ log.debug('===== START TEST BAD HEADER =====') num_particles_to_request = 6 num_expected_particles = 5 self.stream_handle = open(os.path.join(RESOURCE_PATH, 'FLO_bad_header.DAT')) self.build_recov_parser() particles = self.parser.get_records(num_particles_to_request) self.assertEquals(len(particles), num_expected_particles) particle_to_yml(particles, os.path.join(RESOURCE_PATH, 'flo_bad_header.yml')) self.assert_particles(particles, "flo_bad_header.yml", RESOURCE_PATH) log.debug('Exceptions : %s', self.exception_callback_value) self.assert_(isinstance(self.exception_callback_value[0], UnexpectedDataException)) log.debug('===== END TEST BAD HEADER =====')
def test_long_stream(self): """ Read test data and pull out telemetered data particles and compare against yml """ self.stream_handle = open(os.path.join(RESOURCE_PATH, 'node59p1_0.flort.dat')) self.build_telem_parser() particles = self.parser.get_records(18) particle_to_yml(particles, os.path.join(RESOURCE_PATH, 'node59p1_0.flort.yml')) self.assert_particles(particles, "node59p1_0.flort.yml", RESOURCE_PATH) # confirm no exceptions occurred self.assertEqual(self.exception_callback_value, [])
def test_against_yml_recov(self): """ Read test data and pull out recovered data particles and compare against yml """ self.stream_handle = open(os.path.join(RESOURCE_PATH, 'FLO15908.DAT')) self.build_recov_parser() # get 20 particles particles = self.parser.get_records(96) particle_to_yml(particles, os.path.join(RESOURCE_PATH, 'FLO15908.yml')) self.assert_particles(particles, "FLO15908.yml", RESOURCE_PATH) # confirm no exceptions occurred self.assertEqual(self.exception_callback_value, [])
def test_dash(self): """ Test that the particle with a field replaced by dashes is found """ self.stream_handle = open(os.path.join(RESOURCE_PATH, 'node59p1_0_dash.flort.dat')) self.build_telem_parser() result = self.parser.get_records(18) particle_to_yml(result, os.path.join(RESOURCE_PATH, 'node59p1_0_dash.flort.yml')) self.assert_particles(result, "node59p1_0_dash.flort.yml", RESOURCE_PATH) # make sure there were no exceptions self.assertEqual(self.exception_callback_value, [])
def test_against_yml_recov(self): """ Read test data and pull out recovered data particles and compare against yml """ self.stream_handle = open(os.path.join(RESOURCE_PATH, 'FLO15908.DAT')) self.build_recov_parser() # get 20 particles particles = self.parser.get_records(96) particle_to_yml(particles, os.path.join(RESOURCE_PATH, 'FLO15908.yml')) self.assert_particles(particles, "FLO15908.yml", RESOURCE_PATH) # confirm no exceptions occurred self.assertEqual(self.exception_callback_value, [])
def test_long_stream(self): """ Read test data and pull out telemetered data particles and compare against yml """ self.stream_handle = open( os.path.join(RESOURCE_PATH, 'node59p1_0.flort.dat')) self.build_telem_parser() particles = self.parser.get_records(18) particle_to_yml(particles, os.path.join(RESOURCE_PATH, 'node59p1_0.flort.yml')) self.assert_particles(particles, "node59p1_0.flort.yml", RESOURCE_PATH) # confirm no exceptions occurred self.assertEqual(self.exception_callback_value, [])
def test_dash(self): """ Test that the particle with a field replaced by dashes is found """ self.stream_handle = open( os.path.join(RESOURCE_PATH, 'node59p1_0_dash.flort.dat')) self.build_telem_parser() result = self.parser.get_records(18) particle_to_yml( result, os.path.join(RESOURCE_PATH, 'node59p1_0_dash.flort.yml')) self.assert_particles(result, "node59p1_0_dash.flort.yml", RESOURCE_PATH) # make sure there were no exceptions self.assertEqual(self.exception_callback_value, [])
def test_simple_telem(self): """ retrieves and verifies the first 6 particles """ file_path = os.path.join(RESOURCE_PATH, 'first_data.txt') stream_handle = open(file_path, 'rU') parser = FlortDjCsppParser(self._telemetered_config, stream_handle, self.exception_callback) particles = parser.get_records(20) particle_to_yml(particles, os.path.join(RESOURCE_PATH, 'first_data_20_telemetered.yml')) self.assert_particles(particles, 'first_data_20_telemetered.yml', RESOURCE_PATH) self.assertEqual(len(self.exception_callback_value), 0) stream_handle.close()
def test_get_many(self): """ Read test data from the file and pull out multiple data particles a few a time. Assert that the results are those we expected. """ self.stream_handle = open(os.path.join(RESOURCE_PATH, 'node59p1_0.flort.dat')) self.build_telem_parser() # get 18 total result = self.parser.get_records(3) result.extend(self.parser.get_records(10)) result.extend(self.parser.get_records(5)) particle_to_yml(result, os.path.join(RESOURCE_PATH, 'node59p1_0.flort.yml')) self.stream_handle.close() self.assert_particles(result, "node59p1_0.flort.yml", RESOURCE_PATH) # make sure there were no exceptions self.assertEqual(self.exception_callback_value, [])
def test_long_stream(self): """ retrieve all of particles, verify the expected number, confirm results """ file_path = os.path.join(RESOURCE_PATH, 'first_data.txt') stream_handle = open(file_path, 'rU') parser = FlortDjCsppParser(self._recovered_config, stream_handle, self.exception_callback) particles = parser.get_records(1000) particle_to_yml(particles, os.path.join(RESOURCE_PATH, 'first_data_recovered.yml')) self.assertTrue(len(particles) == 193) self.assert_particles(particles, 'first_data_recovered.yml', RESOURCE_PATH) self.assertEqual(len(self.exception_callback_value), 0) stream_handle.close()
def test_bad_data_telem(self): """ Ensure that bad data is skipped when it exists. A variety of malformed records are used in order to verify this """ file_path = os.path.join(RESOURCE_PATH, 'BAD.txt') stream_handle = open(file_path, 'rU') parser = FlortDjCsppParser(self._telemetered_config, stream_handle, self.exception_callback) particles = parser.get_records(4) particle_to_yml(particles, os.path.join(RESOURCE_PATH, 'BAD_telemetered.yml')) self.assert_particles(particles, 'BAD_telemetered.yml', RESOURCE_PATH) self.assertIsInstance(self.exception_callback_value[0], RecoverableSampleException) stream_handle.close()
def test_get_many(self): """ Read test data from the file and pull out multiple data particles a few a time. Assert that the results are those we expected. """ self.stream_handle = open( os.path.join(RESOURCE_PATH, 'node59p1_0.flort.dat')) self.build_telem_parser() # get 18 total result = self.parser.get_records(3) result.extend(self.parser.get_records(10)) result.extend(self.parser.get_records(5)) particle_to_yml(result, os.path.join(RESOURCE_PATH, 'node59p1_0.flort.yml')) self.stream_handle.close() self.assert_particles(result, "node59p1_0.flort.yml", RESOURCE_PATH) # make sure there were no exceptions self.assertEqual(self.exception_callback_value, [])
def create_yml(self, particles, filename): particle_to_yml(particles, os.path.join(RESOURCE_PATH, filename))
def create_yml(self, particles, filename): particle_to_yml(particles, os.path.join(RESOURCE_PATH, filename))