示例#1
0
    def test_bad_xml_checksum(self):
        """
        test an exception is raised for a bad number of bytes
        """
        with open(os.path.join(RESOURCE_PATH, 'node59p1_bad_xml_checksum.adcps.dat')) as stream_handle:

            parser = AdcpsJlnSioParser(self.config, stream_handle, self.exception_callback)
            # 2 records in file, first has bad xml checksum which should call exception
            particles = parser.get_records(2)
            self.assertEqual(len(particles), 1)

            self.assertIsInstance(self.exception_callback_value[0], RecoverableSampleException)
示例#2
0
    def test_long_stream(self):
        """
        test a longer file
        """
        with open(os.path.join(RESOURCE_PATH, 'node59p1_0.adcps.dat')) as stream_handle:

            parser = AdcpsJlnSioParser(self.config, stream_handle, self.exception_callback)
            # request more particles than are available, make sure we only get the number in the file
            particles = parser.get_records(150)
            self.assertEqual(len(particles), 130)

            self.assertEqual(self.exception_callback_value, [])
示例#3
0
    def test_long_stream(self):
        """
        test a longer file
        """
        with open(os.path.join(RESOURCE_PATH,
                               'node59p1_0.adcps.dat')) as stream_handle:

            parser = AdcpsJlnSioParser(self.config, stream_handle,
                                       self.exception_callback)
            # request more particles than are available, make sure we only get the number in the file
            particles = parser.get_records(150)
            self.assertEqual(len(particles), 130)

            self.assertEqual(self.exception_callback_value, [])
示例#4
0
    def test_adcps_error(self):
        """
        test an exception is raised for an adcps error message
        """
        with open(os.path.join(RESOURCE_PATH, 'node59p1_error.adcps.dat')) as stream_handle:

            parser = AdcpsJlnSioParser(self.config, stream_handle, self.exception_callback)
            # 2 records with error messages in them
            particles = parser.get_records(2)
            # make sure no particles were returned for the failure messages
            self.assertEqual(len(particles), 0)

            self.assertIsInstance(self.exception_callback_value[0], RecoverableSampleException)
            self.assertIsInstance(self.exception_callback_value[1], RecoverableSampleException)
示例#5
0
    def test_bad_xml_checksum(self):
        """
        test an exception is raised for a bad number of bytes
        """
        with open(
                os.path.join(
                    RESOURCE_PATH,
                    'node59p1_bad_xml_checksum.adcps.dat')) as stream_handle:

            parser = AdcpsJlnSioParser(self.config, stream_handle,
                                       self.exception_callback)
            # 2 records in file, first has bad xml checksum which should call exception
            particles = parser.get_records(2)
            self.assertEqual(len(particles), 1)

            self.assertIsInstance(self.exception_callback_value[0],
                                  RecoverableSampleException)
示例#6
0
    def test_id_named_file(self):
        """
        Test with a new file containing the controller and instrument ID
        """
        with open(os.path.join(RESOURCE_PATH, 'node11p1_0.adcps_1327803.dat')) as stream_handle:

            parser = AdcpsJlnSioParser(self.config, stream_handle, self.exception_callback)
            # request more particles than are available, make sure we only get the number in the file
            particles = parser.get_records(1000)
            self.assertEqual(len(particles), 831)

            self.assertEqual(len(self.exception_callback_value), 52)
            for i in range(0, 52):
                if i in [12, 15, 35, 47]:
                    self.assertIsInstance(self.exception_callback_value[i], UnexpectedDataException)
                else:
                    self.assertIsInstance(self.exception_callback_value[i], RecoverableSampleException)
示例#7
0
    def test_adcps_error(self):
        """
        test an exception is raised for an adcps error message
        """
        with open(os.path.join(RESOURCE_PATH,
                               'node59p1_error.adcps.dat')) as stream_handle:

            parser = AdcpsJlnSioParser(self.config, stream_handle,
                                       self.exception_callback)
            # 2 records with error messages in them
            particles = parser.get_records(2)
            # make sure no particles were returned for the failure messages
            self.assertEqual(len(particles), 0)

            self.assertIsInstance(self.exception_callback_value[0],
                                  RecoverableSampleException)
            self.assertIsInstance(self.exception_callback_value[1],
                                  RecoverableSampleException)
示例#8
0
    def test_simple(self):
        """
        Read test data from 2 files and compare the particles in .yml files.
        """
        with open(os.path.join(RESOURCE_PATH, 'node59p1_1.adcps.dat')) as stream_handle:

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

            particles = parser.get_records(2)
            self.assert_particles(particles, "adcps_telem_1.yml", RESOURCE_PATH)

            self.assertEqual(self.exception_callback_value, [])

        with open(os.path.join(RESOURCE_PATH, 'node59p1_2.adcps.dat')) as stream_handle:
            parser = AdcpsJlnSioParser(self.config, stream_handle, self.exception_callback)

            particles = parser.get_records(3)
            self.assert_particles(particles, "adcps_telem_2.yml", RESOURCE_PATH)

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

        parser_config = {
            DataSetDriverConfigKeys.PARTICLE_MODULE:
            'mi.dataset.parser.adcps_jln_sio',
            DataSetDriverConfigKeys.PARTICLE_CLASS: 'AdcpsJlnSioDataParticle'
        }

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

        return parser
示例#10
0
    def test_simple(self):
        """
        Read test data from 2 files and compare the particles in .yml files.
        """
        with open(os.path.join(RESOURCE_PATH,
                               'node59p1_1.adcps.dat')) as stream_handle:

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

            particles = parser.get_records(2)
            self.assert_particles(particles, "adcps_telem_1.yml",
                                  RESOURCE_PATH)

            self.assertEqual(self.exception_callback_value, [])

        with open(os.path.join(RESOURCE_PATH,
                               'node59p1_2.adcps.dat')) as stream_handle:
            parser = AdcpsJlnSioParser(self.config, stream_handle,
                                       self.exception_callback)

            particles = parser.get_records(3)
            self.assert_particles(particles, "adcps_telem_2.yml",
                                  RESOURCE_PATH)

            self.assertEqual(self.exception_callback_value, [])
示例#11
0
    def test_id_named_file(self):
        """
        Test with a new file containing the controller and instrument ID
        """
        with open(
                os.path.join(RESOURCE_PATH,
                             'node11p1_0.adcps_1327803.dat')) as stream_handle:

            parser = AdcpsJlnSioParser(self.config, stream_handle,
                                       self.exception_callback)
            # request more particles than are available, make sure we only get the number in the file
            particles = parser.get_records(1000)
            self.assertEqual(len(particles), 831)

            self.assertEqual(len(self.exception_callback_value), 52)
            for i in range(0, 52):
                if i in [12, 15, 35, 47]:
                    self.assertIsInstance(self.exception_callback_value[i],
                                          UnexpectedDataException)
                else:
                    self.assertIsInstance(self.exception_callback_value[i],
                                          RecoverableSampleException)