コード例 #1
0
    def test_simple(self):
        """
        Read test data and pull out data particles.
        Assert that the results are those we expected.
        Expect the first input record to be skipped due to invalid timestamp
        """

        with open(os.path.join(RESOURCE_PATH, 'subset2_reduced.csv'), 'rU') as stream_handle:

            parser = NutnrNAuvParser(stream_handle,
                                     self.exception_callback)

            particles = parser.get_records(25)  # ask for 25 should get 23

            self.assert_particles(particles, 'nutnr_n_auv_telem_23.yml', RESOURCE_PATH)

            self.assertEqual(self.exception_callback_value, [])
コード例 #2
0
    def test_long_stream(self):
        """
        Read test data and pull out data particles.
        Assert the expected number of particles is captured and there are no exceptions
        """

        stream_handle = open(os.path.join(RESOURCE_PATH, 'subset2.csv'), 'rU')

        parser = NutnrNAuvParser(stream_handle, self.exception_callback)

        particles = parser.get_records(10000)

        self.assertEqual(len(particles), 6823)

        self.assertEqual(self.exception_callback_value, [])

        stream_handle.close()
コード例 #3
0
    def test_long_stream(self):
        """
        Read test data and pull out data particles.
        Assert the expected number of particles is captured and there are no exceptions
        """

        stream_handle = open(os.path.join(RESOURCE_PATH, 'subset2.csv'), 'rU')

        parser = NutnrNAuvParser(stream_handle,
                                 self.exception_callback)

        particles = parser.get_records(10000)

        self.assertEqual(len(particles), 6823)

        self.assertEqual(self.exception_callback_value, [])

        stream_handle.close()
コード例 #4
0
    def test_simple(self):
        """
        Read test data and pull out data particles.
        Assert that the results are those we expected.
        Expect the first input record to be skipped due to invalid timestamp
        """

        with open(os.path.join(RESOURCE_PATH, 'subset2_reduced.csv'),
                  'rU') as stream_handle:

            parser = NutnrNAuvParser(stream_handle, self.exception_callback)

            particles = parser.get_records(25)  # ask for 25 should get 23

            self.assert_particles(particles, 'nutnr_n_auv_telem_23.yml',
                                  RESOURCE_PATH)

            self.assertEqual(self.exception_callback_value, [])
コード例 #5
0
    def test_bad_data(self):
        """
        Read test data and pull out data particles.
        Assert that the results are those we expected.
        Expect 2 sample encoding errors
        """

        with open(os.path.join(RESOURCE_PATH, 'nutnr_n_auv_bad_data.csv'), 'rU') as stream_handle:

            parser = NutnrNAuvParser(stream_handle,
                                     self.exception_callback)

            particles = parser.get_records(8)  # ask for 8 should get 7

            self.assert_particles(particles, 'nutnr_n_auv_bad_data_7.yml', RESOURCE_PATH)

            self.assertEqual(len(self.exception_callback_value), 2)
            self.assertIsInstance(self.exception_callback_value[0], SampleEncodingException)
            self.assertIsInstance(self.exception_callback_value[1], SampleEncodingException)
コード例 #6
0
    def test_bad_data(self):
        """
        Read test data and pull out data particles.
        Assert that the results are those we expected.
        Expect 2 sample encoding errors
        """

        with open(os.path.join(RESOURCE_PATH, 'nutnr_n_auv_bad_data.csv'),
                  'rU') as stream_handle:

            parser = NutnrNAuvParser(stream_handle, self.exception_callback)

            particles = parser.get_records(8)  # ask for 8 should get 7

            self.assert_particles(particles, 'nutnr_n_auv_bad_data_7.yml',
                                  RESOURCE_PATH)

            self.assertEqual(len(self.exception_callback_value), 2)
            self.assertIsInstance(self.exception_callback_value[0],
                                  SampleEncodingException)
            self.assertIsInstance(self.exception_callback_value[1],
                                  SampleEncodingException)