def test_10603(self):
        """
        Read test data from the file and pull out telemetered data particles.
        Assert that the results are those we expected.
        """
        with open(os.path.join(
                RESOURCE_PATH,
                'node25p1_46.dosta_1237201.dat')) as stream_handle:
            parser = DostaAbcdjmSioParser(self.config_telem, stream_handle,
                                          self.exception_callback)

            particles = parser.get_records(700)

            self.assertEqual(len(particles), 45)
            self.assertEqual(self.exception_callback_value, [])
    def test_long_stream_recovered(self):
        """
        Read test data and pull out recovered data particles
        """
        with open(os.path.join(RESOURCE_PATH,
                               'DOS15908.DAT')) as stream_handle:
            parser = DostaAbcdjmSioParser(self.config_recov, stream_handle,
                                          self.exception_callback)

            particles = parser.get_records(100)

            # confirm we get requested number
            self.assertEqual(len(particles), 97)

            self.assertEqual(self.exception_callback_value, [])
    def _build_parser(self, stream_handle):

        parser_config = {
            DataSetDriverConfigKeys.PARTICLE_MODULE: 'mi.dataset.parser.dosta_abcdjm_sio',
            DataSetDriverConfigKeys.PARTICLE_CLASS: None,
            DataSetDriverConfigKeys.PARTICLE_CLASSES_DICT: {
                METADATA_PARTICLE_CLASS_KEY: DostaAbcdjmSioRecoveredMetadataDataParticle,
                DATA_PARTICLE_CLASS_KEY: DostaAbcdjmSioRecoveredDataParticle
            }
        }

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

        return parser
    def test_long_stream(self):
        """
        Read test data and pull out recovered data particles
        """
        with open(os.path.join(RESOURCE_PATH,
                               'node59p1_0.dosta.dat')) as stream_handle:
            parser = DostaAbcdjmSioParser(self.config_telem, stream_handle,
                                          self.exception_callback)

            # request more particles than available
            particles = parser.get_records(40)
            # confirm we only get requested number
            self.assertEqual(len(particles), 37)

            # confirm no exceptions occurred
            self.assertEqual(self.exception_callback_value, [])
    def test_simple(self):
        """
        Read test data from the file and pull out telemetered data particles.
        Assert that the results are those we expected.
        """
        with open(os.path.join(RESOURCE_PATH,
                               'node59p1_1.dosta.dat')) as stream_handle:
            parser = DostaAbcdjmSioParser(self.config_telem, stream_handle,
                                          self.exception_callback)

            particles = parser.get_records(7)

            self.assert_particles(particles, "dosta_telem_1.yml",
                                  RESOURCE_PATH)

            self.assertEqual(self.exception_callback_value, [])
    def test_simple_recovered(self):
        """
        Read test data and pull out recovered data particles
        """
        with open(os.path.join(RESOURCE_PATH,
                               'DOS15908_1st7.DAT')) as stream_handle:
            parser = DostaAbcdjmSioParser(self.config_recov, stream_handle,
                                          self.exception_callback)
            # get the first 4 particles
            particles = parser.get_records(4)
            self.assert_particles(particles, "dosta_recov_1.yml",
                                  RESOURCE_PATH)

            # get the next 4 particles (confirming we can break up getting records)
            particles = parser.get_records(4)
            self.assert_particles(particles, "dosta_recov_2.yml",
                                  RESOURCE_PATH)

            # confirm no exceptions occurred
            self.assertEqual(self.exception_callback_value, [])
    def test_drain(self):
        """
        This test ensures that we stop parsing chunks when we have completed parsing
        all the records in the input file.
        """
        with open(os.path.join(RESOURCE_PATH,
                               'node59p1_0.dosta.dat')) as stream_handle:
            parser = DostaAbcdjmSioParser(self.config_telem, stream_handle,
                                          self.exception_callback)

            # request more particles than available
            particles = parser.get_records(40)
            # confirm we only get requested number
            self.assertEqual(len(particles), 37)

            # request more particles than available
            particles = parser.get_records(40)
            # confirm we only get requested number
            self.assertEqual(len(particles), 0)

            # confirm no exceptions occurred
            self.assertEqual(self.exception_callback_value, [])