Ejemplo n.º 1
0
    def test_parsing_of_input_file_with_unexpected_data(self):
        """
        This test method will process a flord_l_wfp_sio input file that includes unexpected data.
        """
        file_path = os.path.join(RESOURCE_PATH,
                                 'flord_l_wfp_sio_unexpected_data.dat')

        # Open the file holding the test sample data
        with open(file_path, 'rb') as stream_handle:

            parser = FlordLWfpSioParser(self.config, stream_handle,
                                        self.exception_callback)

            # Attempt to retrieve 1000 particles
            particles = parser.get_records(1000)

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

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

            # We should end up with 0 particles
            self.assertTrue(len(particles) == 0)
Ejemplo n.º 2
0
    def test_parsing_of_input_file_with_decimation_factor(self):
        """
        This test method will process a flord_l_wfp_sio input file that includes a status
        particle with a decimation factor.
        """
        file_path = os.path.join(RESOURCE_PATH, 'node58p1_3.we_wfp.dat')

        # Open the file holding the test sample data
        with open(file_path, 'rb') as stream_handle:

            parser = FlordLWfpSioParser(self.config, stream_handle, self.exception_callback)

            # Attempt to retrieve 1000 particles
            particles = parser.get_records(1000)

            # We should end up with 49 particles
            self.assertTrue(len(particles) == 49)

            self.assert_particles(particles, 'node58p1_3.we_wfp.yml', RESOURCE_PATH)
Ejemplo n.º 3
0
    def test_parsing_of_input_file_with_unexpected_data(self):
        """
        This test method will process a flord_l_wfp_sio input file that includes unexpected data.
        """
        file_path = os.path.join(RESOURCE_PATH, 'flord_l_wfp_sio_unexpected_data.dat')

        # Open the file holding the test sample data
        with open(file_path, 'rb') as stream_handle:

            parser = FlordLWfpSioParser(self.config, stream_handle, self.exception_callback)

            # Attempt to retrieve 1000 particles
            particles = parser.get_records(1000)

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

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

            # We should end up with 0 particles
            self.assertTrue(len(particles) == 0)
Ejemplo n.º 4
0
    def _build_parser(self, stream_handle):

        parser_config = {
            DataSetDriverConfigKeys.PARTICLE_MODULE:
            'mi.dataset.parser.flord_l_wfp_sio',
            DataSetDriverConfigKeys.PARTICLE_CLASS: 'FlordLWfpSioDataParticle'
        }

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

        return parser
Ejemplo n.º 5
0
    def test_parsing_of_input_file_with_decimation_factor(self):
        """
        This test method will process a flord_l_wfp_sio input file that includes a status
        particle with a decimation factor.
        """
        file_path = os.path.join(RESOURCE_PATH, 'node58p1_3.we_wfp.dat')

        # Open the file holding the test sample data
        with open(file_path, 'rb') as stream_handle:

            parser = FlordLWfpSioParser(self.config, stream_handle,
                                        self.exception_callback)

            # Attempt to retrieve 1000 particles
            particles = parser.get_records(1000)

            # We should end up with 49 particles
            self.assertTrue(len(particles) == 49)

            self.assert_particles(particles, 'node58p1_3.we_wfp.yml',
                                  RESOURCE_PATH)