def test_dosta(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('===== TEST SIMPLE: TELEM =====')
        # test along the telemetered path, current config
        with open(os.path.join(RESOURCE_PATH, 'ctdbp01_20150804_061734.DAT'), 'rU') as file_handle:
            parser = CtdbpPDclCommonParser(DOSTA_TELEM_CONFIG,
                                           file_handle,
                                           self.exception_callback)

            particles = parser.get_records(1)

            # Make sure we obtained 1 particle
            self.assertTrue(len(particles) == 1)
            self.assert_particles(particles, 'ctdbp01_20150804_061734_dosta_telemetered.yml', RESOURCE_PATH)

        log.debug('===== TEST SIMPLE: RECOV =====')
        # test the recovered path, current config
        with open(os.path.join(RESOURCE_PATH, 'ctdbp01_20150804_061734.DAT'), 'rU') as file_handle:
            parser = CtdbpPDclCommonParser(DOSTA_RECOV_CONFIG,
                                           file_handle,
                                           self.exception_callback)

            particles = parser.get_records(1)

            # Make sure we obtained 1 particle
            self.assertTrue(len(particles) == 1)
            # Make sure there were no errors
            self.assertEqual(self.exception_callback_value, [])
            self.assert_particles(particles, 'ctdbp01_20150804_061734_dosta_recovered.yml', RESOURCE_PATH)
    def _build_parser(self, stream_handle):

        # The parser inherits from simple parser - other callbacks not needed here
        parser = CtdbpPDclCommonParser(CTDBP_TELEM_CONFIG, stream_handle,
                                       self._exception_callback)

        return parser
    def test_invalid_record(self):
        """
        The file used here has a damaged tide record ( missing datum )
        """
        log.debug('===== START TEST INVALID RECORD =====')

        # check error handling on an uncorrected Endurance data file ( one record truncated )
        with open(os.path.join(RESOURCE_PATH, 'ctdbp01_20150804_061734_inval.DAT'), 'rU') as file_handle:

            parser = CtdbpPDclCommonParser(CTDBP_TELEM_CONFIG,
                                           file_handle,
                                           self.exception_callback)

            particles = parser.get_records(1)

            self.assertEquals(len(particles), 0)
            self.assert_(isinstance(self.exception_callback_value[0], RecoverableSampleException))
    def test_invalid_record(self):
        """
        The file used here has a damaged tide record ( missing datum )
        """
        log.debug('===== START TEST INVALID RECORD =====')

        # check error handling on an uncorrected Endurance data file ( one record truncated )
        with open(os.path.join(RESOURCE_PATH, 'ctdbp01_20150804_061734_inval.DAT'), 'rU') as file_handle:

            parser = CtdbpPDclCommonParser(CTDBP_TELEM_CONFIG,
                                           file_handle,
                                           self.exception_callback)

            particles = parser.get_records(1)

            self.assertEquals(len(particles), 0)
            self.assert_(isinstance(self.exception_callback_value[0], RecoverableSampleException))
    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, 'ctdbp01_20150804_061734_norec.DAT'), 'rU') as file_handle:

            num_particles_to_request = 1
            num_expected_particles = 0

            parser = CtdbpPDclCommonParser(CTDBP_TELEM_CONFIG,
                                           file_handle,
                                           self.exception_callback)

            particles = parser.get_records(num_particles_to_request)

            self.assertEquals(len(particles), num_expected_particles)

        log.debug('===== END TEST NO PARTICLES =====')
    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, 'ctdbp01_20150804_061734_norec.DAT'), 'rU') as file_handle:

            num_particles_to_request = 1
            num_expected_particles = 0

            parser = CtdbpPDclCommonParser(CTDBP_TELEM_CONFIG,
                                           file_handle,
                                           self.exception_callback)

            particles = parser.get_records(num_particles_to_request)

            self.assertEquals(len(particles), num_expected_particles)

        log.debug('===== END TEST NO PARTICLES =====')
    def test_ctdbp(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('===== TEST SIMPLE: TELEM =====')
        # test along the telemetered path, current config
        with open(os.path.join(RESOURCE_PATH, 'ctdbp01_20150804_061734.DAT'), 'rU') as file_handle:
            parser = CtdbpPDclCommonParser(CTDBP_TELEM_CONFIG,
                                           file_handle,
                                           self.exception_callback)

            particles = parser.get_records(1)

            # Make sure we obtained 1 particle
            self.assertTrue(len(particles) == 1)
            # Make sure there were no errors
            self.assertEqual(self.exception_callback_value, [])
            self.assert_particles(particles, 'ctdbp01_20150804_061734_ctdbp_telemetered.yml', RESOURCE_PATH)

        log.debug('===== TEST SIMPLE: RECOV =====')
        # test the recovered path, current config
        with open(os.path.join(RESOURCE_PATH, 'ctdbp01_20150804_061734.DAT'), 'rU') as file_handle:
            parser = CtdbpPDclCommonParser(CTDBP_RECOV_CONFIG,
                                           file_handle,
                                           self.exception_callback)

            particles = parser.get_records(1)

            # Make sure we obtained 1 particle
            self.assertTrue(len(particles) == 1)
            # Make sure there were no errors
            self.assertEqual(self.exception_callback_value, [])
            self.assert_particles(particles, 'ctdbp01_20150804_061734_ctdbp_recovered.yml', RESOURCE_PATH)