コード例 #1
0
ファイル: test_ctdbp_cdef.py プロジェクト: GrimJ/mi-dataset
    def test_verify_record_against_yaml(self):
        """
        Read data from a file and pull out data particles
        one at a time. Verify that the results are those we expected.
        """
        log.debug('===== START YAML TEST =====')

        # test with Endurance data
        with open(os.path.join(RESOURCE_PATH, 'data1_endurance.log'), 'rU') as file_handle:

            parser = CtdbpCdefParser(file_handle,
                                     self.exception_callback)

            # In a single read, get all particles in this file.
            number_expected_results = 143
            result = parser.get_records(number_expected_results)
            self.assert_particles(result, 'data1_endurance.yml', RESOURCE_PATH)

            self.assertListEqual(self.exception_callback_value, [])

        # test with Pioneer data
        with open(os.path.join(RESOURCE_PATH, 'data1_pioneer.log'), 'rU') as file_handle:

            parser = CtdbpCdefParser(file_handle,
                                     self.exception_callback)

            # In a single read, get all particles in this file.
            number_expected_results = 100
            result = parser.get_records(number_expected_results)
            self.assert_particles(result, 'data1_pioneer.yml', RESOURCE_PATH)

            self.assertListEqual(self.exception_callback_value, [])

        log.debug('===== END YAML TEST =====')
コード例 #2
0
ファイル: test_ctdbp_cdef.py プロジェクト: GrimJ/mi-dataset
    def test_no_sensor_data(self):
        """
        Read a file containing no sensor data records
        and verify that no particles are produced.
        """
        log.debug('===== START TEST NO SENSOR DATA RECOVERED =====')

        # test with Endurance data
        with open(os.path.join(RESOURCE_PATH, 'no_sensor_data_endurance.log'), 'rU') as file_handle:
            parser = CtdbpCdefParser(file_handle,
                                     self.exception_callback)

            # Try to get a record and verify that none are produced.
            result = parser.get_records(1)
            self.assertEqual(result, [])

            self.assertListEqual(self.exception_callback_value, [])

        # test with Pioneer data
        with open(os.path.join(RESOURCE_PATH, 'no_sensor_data_pioneer.log'), 'rU') as file_handle:
            parser = CtdbpCdefParser(file_handle,
                                     self.exception_callback)

            # Try to get a record and verify that none are produced.
            result = parser.get_records(1)
            self.assertEqual(result, [])

            self.assertListEqual(self.exception_callback_value, [])

        log.debug('===== END TEST NO SENSOR DATA =====')
コード例 #3
0
ファイル: test_ctdbp_cdef.py プロジェクト: GrimJ/mi-dataset
    def test_invalid_sensor_data_records(self):
        """
        Read data from a file containing invalid sensor data records.
        Verify that no instrument particles are produced
        and the correct number of exceptions are detected.
        """
        log.debug('===== START TEST INVALID SENSOR DATA =====')

        # test with Endurance data
        with open(os.path.join(RESOURCE_PATH, 'invalid_data_endurance.log'), 'rU') as file_handle:
            parser = CtdbpCdefParser(file_handle,
                                     self.exception_callback)

            # Try to get records and verify that none are returned.
            result = parser.get_records(1)
            self.assertEqual(result, [])
            self.assertEqual(len(self.exception_callback_value), 11)

        self.exception_callback_value = []  # reset exceptions

        # test with Pioneer data
        with open(os.path.join(RESOURCE_PATH, 'invalid_data_pioneer.log'), 'rU') as file_handle:
            parser = CtdbpCdefParser(file_handle,
                                     self.exception_callback)

            # Try to get records and verify that none are returned.
            result = parser.get_records(1)
            self.assertEqual(result, [])
            self.assertEqual(len(self.exception_callback_value), 11)

        log.debug('===== END TEST INVALID SENSOR DATA =====')
コード例 #4
0
    def create_flort_ctdbp_yaml(self):
        path = RESOURCE_PATH
        log.info(path)

        with open(os.path.join(RESOURCE_PATH, 'data1_ctdbp_flort_recovered.hex'), 'rU') as file_handle:

            parser = CtdbpCdefParser(file_handle,
                                     self.exception_callback)

            # In a single read, get all particles in this file.
            all_records = 150
            records = parser.get_records(all_records)

            CtdbpCdefParserUnitTestCase.create_yml(records, 'data1_ctdbp_flort_recovered.yml')
コード例 #5
0
    def create_flort_ctdbp_yaml(self):
        path = RESOURCE_PATH
        log.info(path)

        with open(
                os.path.join(RESOURCE_PATH, 'data1_ctdbp_flort_recovered.hex'),
                'rU') as file_handle:

            parser = CtdbpCdefParser(file_handle, self.exception_callback)

            # In a single read, get all particles in this file.
            all_records = 150
            records = parser.get_records(all_records)

            CtdbpCdefParserUnitTestCase.create_yml(
                records, 'data1_ctdbp_flort_recovered.yml')
コード例 #6
0
    def _build_parser(self, stream_handle):

        # The parser inherits from simple parser - other callbacks not needed here
        parser = CtdbpCdefParser(stream_handle,
                                 self._exception_callback)

        return parser
コード例 #7
0
    def test_simple(self):
        """
        Simple test to verify that records are successfully read and parsed from a data file
        """
        log.debug('===== START SIMPLE TEST =====')

        path = RESOURCE_PATH
        log.info(path)

        # test with Endurance data
        with open(os.path.join(RESOURCE_PATH, 'simple_test_endurance.log'),
                  'rU') as file_handle:

            parser = CtdbpCdefParser(file_handle, self.exception_callback)

            # In a single read, get all particles in this file.
            number_expected_results = 5
            result = parser.get_records(number_expected_results)
            self.assertEqual(len(result), number_expected_results)

            self.assertListEqual(self.exception_callback_value, [])

        # test with Pioneer data
        with open(os.path.join(RESOURCE_PATH, 'simple_test_pioneer.log'),
                  'rU') as file_handle:

            parser = CtdbpCdefParser(file_handle, self.exception_callback)

            # In a single read, get all particles in this file.
            number_expected_results = 5
            result = parser.get_records(number_expected_results)
            self.assertEqual(len(result), number_expected_results)

            self.assertListEqual(self.exception_callback_value, [])

        # Test with combined FLORT/CTDBP data
        with open(
                os.path.join(RESOURCE_PATH,
                             'simple_test_ctdbp_flort_recovered.hex'),
                'rU') as file_handle:

            parser = CtdbpCdefParser(file_handle, self.exception_callback)

            # In a single read, get all particles in this file.
            number_expected_results = 10
            result = parser.get_records(number_expected_results)
            self.assertEqual(len(result), number_expected_results)

            self.assertListEqual(self.exception_callback_value, [])

        log.debug('===== END SIMPLE TEST =====')
コード例 #8
0
    def test_invalid_sensor_data_records(self):
        """
        Read data from a file containing invalid sensor data records.
        Verify that no instrument particles are produced
        and the correct number of exceptions are detected.
        """
        log.debug('===== START TEST INVALID SENSOR DATA =====')

        # test with Endurance data
        with open(os.path.join(RESOURCE_PATH, 'invalid_data_endurance.log'),
                  'rU') as file_handle:
            parser = CtdbpCdefParser(file_handle, self.exception_callback)

            # Try to get records and verify that none are returned.
            result = parser.get_records(1)
            self.assertEqual(result, [])
            self.assertEqual(len(self.exception_callback_value), 11)

        self.exception_callback_value = []  # reset exceptions

        # test with Pioneer data
        with open(os.path.join(RESOURCE_PATH, 'invalid_data_pioneer.log'),
                  'rU') as file_handle:
            parser = CtdbpCdefParser(file_handle, self.exception_callback)

            # Try to get records and verify that none are returned.
            result = parser.get_records(1)
            self.assertEqual(result, [])
            self.assertEqual(len(self.exception_callback_value), 11)

        self.exception_callback_value = []  # reset exceptions

        # Test with combined FLORT/CTDBP data
        with open(
                os.path.join(RESOURCE_PATH,
                             'invalid_sensor_data_ctdbp_flort_recovered.hex'),
                'rU') as file_handle:
            parser = CtdbpCdefParser(file_handle, self.exception_callback)

            # Try to get records and verify that only valid number is returned.
            number_total_records = 20
            number_valid_records = 15
            result = parser.get_records(number_total_records)
            self.assertEqual(len(result), number_valid_records)
            self.assertEqual(len(self.exception_callback_value), 5)

        self.exception_callback_value = []  # reset exceptions

        log.debug('===== END TEST INVALID SENSOR DATA =====')
コード例 #9
0
    def test_verify_record_against_yaml(self):
        """
        Read data from a file and pull out data particles
        one at a time. Verify that the results are those we expected.
        """
        log.debug('===== START YAML TEST =====')

        # test with Endurance data
        with open(os.path.join(RESOURCE_PATH, 'data1_endurance.log'),
                  'rU') as file_handle:

            parser = CtdbpCdefParser(file_handle, self.exception_callback)

            # In a single read, get all particles in this file.
            number_expected_results = 143
            result = parser.get_records(number_expected_results)
            self.assert_particles(result, 'data1_endurance.yml', RESOURCE_PATH)

            self.assertListEqual(self.exception_callback_value, [])

        # test with Pioneer data
        with open(os.path.join(RESOURCE_PATH, 'data1_pioneer.log'),
                  'rU') as file_handle:

            parser = CtdbpCdefParser(file_handle, self.exception_callback)

            # In a single read, get all particles in this file.
            number_expected_results = 100
            result = parser.get_records(number_expected_results)
            self.assert_particles(result, 'data1_pioneer.yml', RESOURCE_PATH)

            self.assertListEqual(self.exception_callback_value, [])

        # Test with combined FLORT/CTDBP data
        with open(
                os.path.join(RESOURCE_PATH, 'data1_ctdbp_flort_recovered.hex'),
                'rU') as file_handle:

            parser = CtdbpCdefParser(file_handle, self.exception_callback)

            # In a single read, get all particles in this file.
            number_expected_results = 150
            result = parser.get_records(number_expected_results)
            self.assert_particles(result, 'data1_ctdbp_flort_recovered.yml',
                                  RESOURCE_PATH)

            self.assertListEqual(self.exception_callback_value, [])

        log.debug('===== END YAML TEST =====')
コード例 #10
0
    def test_no_sensor_data(self):
        """
        Read a file containing no sensor data records
        and verify that no particles are produced.
        """
        log.debug('===== START TEST NO SENSOR DATA RECOVERED =====')

        # test with Endurance data
        with open(os.path.join(RESOURCE_PATH, 'no_sensor_data_endurance.log'),
                  'rU') as file_handle:
            parser = CtdbpCdefParser(file_handle, self.exception_callback)

            # Try to get a record and verify that none are produced.
            result = parser.get_records(1)
            self.assertEqual(result, [])

            self.assertListEqual(self.exception_callback_value, [])

        # test with Pioneer data
        with open(os.path.join(RESOURCE_PATH, 'no_sensor_data_pioneer.log'),
                  'rU') as file_handle:
            parser = CtdbpCdefParser(file_handle, self.exception_callback)

            # Try to get a record and verify that none are produced.
            result = parser.get_records(1)
            self.assertEqual(result, [])

            self.assertListEqual(self.exception_callback_value, [])

        log.debug('===== END TEST NO SENSOR DATA =====')
コード例 #11
0
ファイル: test_ctdbp_cdef.py プロジェクト: GrimJ/mi-dataset
    def test_simple(self):
        """
        Simple test to verify that records are successfully read and parsed from a data file
        """
        log.debug('===== START SIMPLE TEST =====')

        path = RESOURCE_PATH
        log.info(path)

        # test with Endurance data
        with open(os.path.join(RESOURCE_PATH, 'simple_test_endurance.log'), 'rU') as file_handle:

            parser = CtdbpCdefParser(file_handle,
                                     self.exception_callback)

            # In a single read, get all particles in this file.
            number_expected_results = 5
            result = parser.get_records(number_expected_results)
            self.assertEqual(len(result), number_expected_results)

            self.assertListEqual(self.exception_callback_value, [])

        # test with Pioneer data
        with open(os.path.join(RESOURCE_PATH, 'simple_test_pioneer.log'), 'rU') as file_handle:

            parser = CtdbpCdefParser(file_handle,
                                     self.exception_callback)

            # In a single read, get all particles in this file.
            number_expected_results = 5
            result = parser.get_records(number_expected_results)
            self.assertEqual(len(result), number_expected_results)

            self.assertListEqual(self.exception_callback_value, [])

        log.debug('===== END SIMPLE TEST =====')