Example #1
0
    def test_invalid_data_recov(self):
        """
        Read files and verify that all expected particles can be read.
        Verify that invalid data is handled appropriately with the
        correct exceptions being reported.
        """
        log.debug('===== START TEST INVALID DATA RECOVERED =====')

        num_particles_to_request = 10
        num_expected_particles = 7

        with open(os.path.join(RESOURCE_PATH, 'pco2wXYZ_11212014_1625.DAT'),
                  'r') as file_handle:

            parser = Pco2wAbcImodemParser(self._recov_parser_config,
                                          file_handle, self.exception_callback)

            particles = parser.get_records(num_particles_to_request)

            self.assertEquals(len(particles), num_expected_particles)

            self.assert_particles(particles,
                                  "pco2wXYZ_11212014_1625.recov.yml",
                                  RESOURCE_PATH)

            self.assertEquals(len(self.exception_callback_value), 2)

            for exception in self.exception_callback_value:
                self.assertIsInstance(exception, RecoverableSampleException)

        log.debug('===== END TEST INVALID DATA RECOVERED =====')
Example #2
0
    def test_incomplete_metadata_two(self):
        """
        Read a file containing insufficient data to create a metadata particle.
        In this case, the line specifying the serial number is missing.
        Verify that the contents of the particles are correct ensuring no metadata
        particle was generated.
        There should be no exceptions generated.
        """
        log.debug('===== START TEST INCOMPLETE METADATA TWO =====')

        num_particles_to_request = 10
        num_expected_particles = 7

        with open(os.path.join(RESOURCE_PATH, 'pco2wXYZ_11212014_1627.DAT'),
                  'r') as file_handle:

            parser = Pco2wAbcImodemParser(self._telem_parser_config,
                                          file_handle, self.exception_callback)

            particles = parser.get_records(num_particles_to_request)

            self.assertEquals(len(particles), num_expected_particles)

            self.assert_particles(particles,
                                  "pco2wXYZ_11212014_1627.telem.yml",
                                  RESOURCE_PATH)

            self.assertEquals(len(self.exception_callback_value), 0)

        with open(os.path.join(RESOURCE_PATH, 'pco2wXYZ_11212014_1627.DAT'),
                  'r') as file_handle:

            parser = Pco2wAbcImodemParser(self._recov_parser_config,
                                          file_handle, self.exception_callback)

            particles = parser.get_records(num_particles_to_request)

            self.assertEquals(len(particles), num_expected_particles)

            self.assert_particles(particles,
                                  "pco2wXYZ_11212014_1627.recov.yml",
                                  RESOURCE_PATH)

            self.assertEquals(len(self.exception_callback_value), 0)

        log.debug('===== END TEST INCOMPLETE METADATA TWO =====')
Example #3
0
    def test_happy_path(self):
        """
        Read files and verify that all expected particles can be read.
        Verify that the contents of the particles are correct.
        There should be no exceptions generated.
        """
        log.debug('===== START TEST HAPPY PATH =====')

        num_particles_to_request = 10
        num_expected_particles = 7

        with open(os.path.join(RESOURCE_PATH, 'pco2wXYZ_11212014_1624.DAT'),
                  'r') as file_handle:

            parser = Pco2wAbcImodemParser(self._telem_parser_config,
                                          file_handle, self.exception_callback)

            particles = parser.get_records(num_particles_to_request)

            self.assertEquals(len(particles), num_expected_particles)

            self.assert_particles(particles,
                                  "pco2wXYZ_11212014_1624.telem.yml",
                                  RESOURCE_PATH)

            self.assertEquals(len(self.exception_callback_value), 0)

        with open(os.path.join(RESOURCE_PATH, 'pco2wXYZ_11212014_1624.DAT'),
                  'r') as file_handle:

            parser = Pco2wAbcImodemParser(self._recov_parser_config,
                                          file_handle, self.exception_callback)

            particles = parser.get_records(num_particles_to_request)

            self.assertEquals(len(particles), num_expected_particles)

            self.assert_particles(particles,
                                  "pco2wXYZ_11212014_1624.recov.yml",
                                  RESOURCE_PATH)

            self.assertEquals(len(self.exception_callback_value), 0)

        log.debug('===== END TEST HAPPY PATH =====')
Example #4
0
    def _build_parser(self, stream_handle):

        parser_config = {
            DataSetDriverConfigKeys.PARTICLE_MODULE:
            'mi.dataset.parser.pco2w_abc_particles',
            DataSetDriverConfigKeys.PARTICLE_CLASS: None,
            DataSetDriverConfigKeys.PARTICLE_CLASSES_DICT: {
                Pco2wAbcParticleClassKey.METADATA_PARTICLE_CLASS:
                Pco2wAbcImodemMetadataRecoveredDataParticle,
                Pco2wAbcParticleClassKey.POWER_PARTICLE_CLASS:
                Pco2wAbcImodemPowerRecoveredDataParticle,
                Pco2wAbcParticleClassKey.INSTRUMENT_PARTICLE_CLASS:
                Pco2wAbcImodemInstrumentRecoveredDataParticle,
                Pco2wAbcParticleClassKey.INSTRUMENT_BLANK_PARTICLE_CLASS:
                Pco2wAbcImodemInstrumentBlankRecoveredDataParticle,
                Pco2wAbcParticleClassKey.CONTROL_PARTICLE_CLASS:
                Pco2wAbcImodemControlRecoveredDataParticle,
            }
        }

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

        return parser