Ejemplo n.º 1
0
    def test_get_many(self):
        """
        Read test data and pull out multiple data particles at one time.
        Assert that the results are those we expected.
        """
        with open(os.path.join(RESOURCE_PATH,
                               'node59p1_1.status.dat')) as stream_handle:

            parser = SioEngSioParser(self.telem_config, stream_handle,
                                     self.exception_callback)

            # split up getting records, start with 2
            result = parser.get_records(2)
            self.assertEqual(len(result), 2)
            # only 2 remaining, request 3 and make sure we only get 2
            result2 = parser.get_records(3)
            self.assertEqual(len(result2), 2)
            # shouldn't get any more assert this is 0
            result3 = parser.get_records(1)
            self.assertEqual(len(result3), 0)

            # combine result and result2 to get the whole file
            result.extend(result2)
            self.assert_particles(result, 'node59p1_1.yml', RESOURCE_PATH)

        self.assertEqual(self.exception_callback_value, [])
Ejemplo n.º 2
0
    def test_bad_telem(self):
        """
        Test a file that has had a section of the 2nd CS data replaced with "BAD DATA"
        """
        with open(os.path.join(RESOURCE_PATH, 'node59p1_1.bad.status.dat')) as stream_handle:
            parser = SioEngSioParser(self.telem_config, stream_handle, self.exception_callback)

            result = parser.get_records(4)
            # 2nd particle has bad data, only 3 particles left
            self.assertEqual(len(result), 3)

            self.assertEqual(len(self.exception_callback_value), 1)
            self.assert_(isinstance(self.exception_callback_value[0], SampleException))
Ejemplo n.º 3
0
    def test_get_with_extra_data(self):
        """
        Test with a file that includes unexpected data parses correctly and generates an exception
        """
        with open(os.path.join(RESOURCE_PATH, 'node59p1_1.extra.status.dat')) as stream_handle:

            parser = SioEngSioParser(self.telem_config, stream_handle, self.exception_callback)

            result = parser.get_records(4)
            self.assert_particles(result, 'node59p1_1.yml', RESOURCE_PATH)

            self.assertEquals(len(self.exception_callback_value), 1)
            self.assert_(isinstance(self.exception_callback_value[0], UnexpectedDataException))
Ejemplo n.º 4
0
    def test_get_with_other_sio_id(self):
        """
        Test with a file that includes an ID other than the expected sio IDs, which should generate an exception
        """
        with open(os.path.join(RESOURCE_PATH, 'node59p1_1.id.status.dat')) as stream_handle:

            parser = SioEngSioParser(self.telem_config, stream_handle, self.exception_callback)

            result = parser.get_records(4)
            self.assert_particles(result, 'node59p1_1.yml', RESOURCE_PATH)

            self.assertEquals(len(self.exception_callback_value), 1)
            self.assert_(isinstance(self.exception_callback_value[0], UnexpectedDataException))
Ejemplo n.º 5
0
    def test_bad_recov(self):
        """
        Test a file that has has sections of CS data replaced with letters
        """
        with open(os.path.join(RESOURCE_PATH, 'STA15908_BAD.DAT')) as stream_handle:
            parser = SioEngSioParser(self.recov_config, stream_handle, self.exception_callback)

            result = parser.get_records(24)
            # first particle has bad data, only 23 particles left
            self.assertEqual(len(result), 23)

            self.assertEqual(len(self.exception_callback_value), 1)
            self.assert_(isinstance(self.exception_callback_value[0], SampleException))
Ejemplo n.º 6
0
    def test_simple_recov(self):
        """
        Read test data and pull out data particles
        Assert that the results are those we expected.
        This serves as both the simple and long recovered tests, since it uses the full recovered example file
        """
        with open(os.path.join(RESOURCE_PATH, 'STA15908.DAT')) as stream_handle:

            parser = SioEngSioParser(self.recov_config, stream_handle, self.exception_callback)

            result = parser.get_records(24)
            self.assert_particles(result, 'STA15908.yml', RESOURCE_PATH)

        self.assertEqual(self.exception_callback_value, [])
Ejemplo n.º 7
0
    def test_simple_recov(self):
        """
        Read test data and pull out data particles
        Assert that the results are those we expected.
        This serves as both the simple and long recovered tests, since it uses the full recovered example file
        """
        with open(os.path.join(RESOURCE_PATH,
                               'STA15908.DAT')) as stream_handle:

            parser = SioEngSioParser(self.recov_config, stream_handle,
                                     self.exception_callback)

            result = parser.get_records(24)
            self.assert_particles(result, 'STA15908.yml', RESOURCE_PATH)

        self.assertEqual(self.exception_callback_value, [])
Ejemplo n.º 8
0
    def test_bad_recov(self):
        """
        Test a file that has has sections of CS data replaced with letters
        """
        with open(os.path.join(RESOURCE_PATH,
                               'STA15908_BAD.DAT')) as stream_handle:
            parser = SioEngSioParser(self.recov_config, stream_handle,
                                     self.exception_callback)

            result = parser.get_records(24)
            # first particle has bad data, only 23 particles left
            self.assertEqual(len(result), 23)

            self.assertEqual(len(self.exception_callback_value), 1)
            self.assert_(
                isinstance(self.exception_callback_value[0], SampleException))
Ejemplo n.º 9
0
    def test_bad_telem(self):
        """
        Test a file that has had a section of the 2nd CS data replaced with "BAD DATA"
        """
        with open(os.path.join(RESOURCE_PATH,
                               'node59p1_1.bad.status.dat')) as stream_handle:
            parser = SioEngSioParser(self.telem_config, stream_handle,
                                     self.exception_callback)

            result = parser.get_records(4)
            # 2nd particle has bad data, only 3 particles left
            self.assertEqual(len(result), 3)

            self.assertEqual(len(self.exception_callback_value), 1)
            self.assert_(
                isinstance(self.exception_callback_value[0], SampleException))
Ejemplo n.º 10
0
    def test_simple(self):
        """
        Read test data and pull out data particles
        Assert that the results are those we expected.
        """
        with open(os.path.join(RESOURCE_PATH, 'node59p1_1.status.dat')) as stream_handle:

            parser = SioEngSioParser(self.telem_config, stream_handle, self.exception_callback)

            # request one more particle than expected
            result = parser.get_records(5)
            self.assert_particles(result, 'node59p1_1.yml', RESOURCE_PATH)

            result = parser.get_records(5)
            log.debug('second get records got back %s records', len(result))

        self.assertEqual(self.exception_callback_value, [])
Ejemplo n.º 11
0
    def test_get_with_other_sio_id(self):
        """
        Test with a file that includes an ID other than the expected sio IDs, which should generate an exception
        """
        with open(os.path.join(RESOURCE_PATH,
                               'node59p1_1.id.status.dat')) as stream_handle:

            parser = SioEngSioParser(self.telem_config, stream_handle,
                                     self.exception_callback)

            result = parser.get_records(4)
            self.assert_particles(result, 'node59p1_1.yml', RESOURCE_PATH)

            self.assertEquals(len(self.exception_callback_value), 1)
            self.assert_(
                isinstance(self.exception_callback_value[0],
                           UnexpectedDataException))
Ejemplo n.º 12
0
    def test_get_with_extra_data(self):
        """
        Test with a file that includes unexpected data parses correctly and generates an exception
        """
        with open(
                os.path.join(RESOURCE_PATH,
                             'node59p1_1.extra.status.dat')) as stream_handle:

            parser = SioEngSioParser(self.telem_config, stream_handle,
                                     self.exception_callback)

            result = parser.get_records(4)
            self.assert_particles(result, 'node59p1_1.yml', RESOURCE_PATH)

            self.assertEquals(len(self.exception_callback_value), 1)
            self.assert_(
                isinstance(self.exception_callback_value[0],
                           UnexpectedDataException))
Ejemplo n.º 13
0
    def test_simple(self):
        """
        Read test data and pull out data particles
        Assert that the results are those we expected.
        """
        with open(os.path.join(RESOURCE_PATH,
                               'node59p1_1.status.dat')) as stream_handle:

            parser = SioEngSioParser(self.telem_config, stream_handle,
                                     self.exception_callback)

            # request one more particle than expected
            result = parser.get_records(5)
            self.assert_particles(result, 'node59p1_1.yml', RESOURCE_PATH)

            result = parser.get_records(5)
            log.debug('second get records got back %s records', len(result))

        self.assertEqual(self.exception_callback_value, [])
Ejemplo n.º 14
0
    def _build_parser(self, stream_handle):

        parser_config = {
            DataSetDriverConfigKeys.PARTICLE_MODULE: 'mi.dataset.parser.sio_eng_sio',
            DataSetDriverConfigKeys.PARTICLE_CLASS: 'SioEngSioTelemeteredDataParticle'
        }

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

        return parser
Ejemplo n.º 15
0
    def test_long_stream(self):
        """
        Test a long stream 
        """
        # test with the flmb file
        with open(os.path.join(RESOURCE_PATH,
                               'node59p1_0.status.dat')) as stream_handle:

            parser = SioEngSioParser(self.telem_config, stream_handle,
                                     self.exception_callback)

            result = parser.get_records(9)
            self.assert_particles(result, 'node59p1_0.yml', RESOURCE_PATH)

            self.assertEqual(self.exception_callback_value, [])

        # test with the hypm file
        with open(os.path.join(RESOURCE_PATH,
                               'node58p1_0.status.dat')) as stream_handle:

            parser = SioEngSioParser(self.telem_config, stream_handle,
                                     self.exception_callback)

            result = parser.get_records(4)
            self.assert_particles(result, 'node58p1_0.yml', RESOURCE_PATH)

            self.assertEqual(self.exception_callback_value, [])
Ejemplo n.º 16
0
    def test_long_stream(self):
        """
        Test a long stream 
        """
        # test with the flmb file
        with open(os.path.join(RESOURCE_PATH, 'node59p1_0.status.dat')) as stream_handle:

            parser = SioEngSioParser(self.telem_config, stream_handle, self.exception_callback)

            result = parser.get_records(9)
            self.assert_particles(result, 'node59p1_0.yml', RESOURCE_PATH)

            self.assertEqual(self.exception_callback_value, [])

        # test with the hypm file
        with open(os.path.join(RESOURCE_PATH, 'node58p1_0.status.dat')) as stream_handle:

            parser = SioEngSioParser(self.telem_config, stream_handle, self.exception_callback)

            result = parser.get_records(4)
            self.assert_particles(result, 'node58p1_0.yml', RESOURCE_PATH)

            self.assertEqual(self.exception_callback_value, [])
Ejemplo n.º 17
0
    def test_get_many(self):
        """
        Read test data and pull out multiple data particles at one time.
        Assert that the results are those we expected.
        """
        with open(os.path.join(RESOURCE_PATH, 'node59p1_1.status.dat')) as stream_handle:

            parser = SioEngSioParser(self.telem_config, stream_handle, self.exception_callback)

            # split up getting records, start with 2
            result = parser.get_records(2)
            self.assertEqual(len(result), 2)
            # only 2 remaining, request 3 and make sure we only get 2
            result2 = parser.get_records(3)
            self.assertEqual(len(result2), 2)
            # shouldn't get any more assert this is 0
            result3 = parser.get_records(1)
            self.assertEqual(len(result3), 0)

            # combine result and result2 to get the whole file
            result.extend(result2)
            self.assert_particles(result, 'node59p1_1.yml', RESOURCE_PATH)

        self.assertEqual(self.exception_callback_value, [])