當前位置: 首頁>>代碼示例>>Python>>正文


Python phsen_abcdef.PhsenRecoveredParser類代碼示例

本文整理匯總了Python中mi.dataset.parser.phsen_abcdef.PhsenRecoveredParser的典型用法代碼示例。如果您正苦於以下問題:Python PhsenRecoveredParser類的具體用法?Python PhsenRecoveredParser怎麽用?Python PhsenRecoveredParser使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了PhsenRecoveredParser類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_unknown_msg_type

 def test_unknown_msg_type(self):
     """
     Test that we handle unsupported msg type
     """
     with open(os.path.join(RESOURCE_PATH, 'SAMI_P0080_180713_unknown_msg_type.txt')) as stream_handle:
         parser = PhsenRecoveredParser(self.config, stream_handle, self.exception_callback)
         parser.get_records(1)
         self.assertIsInstance(self.exception_callback_value[0], SampleException)
開發者ID:danmergens,項目名稱:mi-instrument,代碼行數:8,代碼來源:test_phsen_abcdef.py

示例2: test_invalid_num_fields_special_control

 def test_invalid_num_fields_special_control(self):
     """
     Test that the special control records have correct number of fields
     """
     with open(os.path.join(RESOURCE_PATH, 'SAMI_P0080_180713_invalid_special_control.txt')) as stream_handle:
         parser = PhsenRecoveredParser(self.config,  stream_handle, self.exception_callback)
         parser.get_records(1)
         self.assertIsInstance(self.exception_callback_value[0], SampleException)
開發者ID:danmergens,項目名稱:mi-instrument,代碼行數:8,代碼來源:test_phsen_abcdef.py

示例3: test_recover

 def test_recover(self):
     """
     Test that we can recover after receiving bad record
     """
     with open(os.path.join(RESOURCE_PATH, 'SAMI_P0080_180713_recover.txt')) as stream_handle:
         parser = PhsenRecoveredParser(self.config, stream_handle, self.exception_callback)
         parser.get_records(1)
         self.assertIsInstance(self.exception_callback_value[0], SampleException)
開發者ID:danmergens,項目名稱:mi-instrument,代碼行數:8,代碼來源:test_phsen_abcdef.py

示例4: test_no_data_tag

 def test_no_data_tag(self):
     """
     Test that we do not create a particle if the file does not contain the ':Data' tag
     """
     with open(os.path.join(RESOURCE_PATH, 'SAMI_P0080_180713_no_data_tag.txt')) as stream_handle:
         parser = PhsenRecoveredParser(self.config, stream_handle, self.exception_callback)
         result = parser.get_records(1)
         self.assertEqual(result, [])
開發者ID:danmergens,項目名稱:mi-instrument,代碼行數:8,代碼來源:test_phsen_abcdef.py

示例5: test_alpha_field

 def test_alpha_field(self):
     """
     Test that we handle an alpha field
     """
     with open(os.path.join(RESOURCE_PATH, 'SAMI_P0080_180713_alpha_field.txt')) as stream_handle:
         parser = PhsenRecoveredParser(self.config, stream_handle, self.exception_callback)
         parser.get_records(1)
         print self.exception_callback_value
         self.assertIsInstance(self.exception_callback_value[0], SampleException)
開發者ID:danmergens,項目名稱:mi-instrument,代碼行數:9,代碼來源:test_phsen_abcdef.py

示例6: test_integration_control

 def test_integration_control(self):
     """
     Test with the integration control file
     """
     with open(os.path.join(RESOURCE_PATH, 'SAMI_P0080_180713_integration_control_ph.txt')) as stream_handle:
         parser = PhsenRecoveredParser(self.config, stream_handle, self.exception_callback)
         result = parser.get_records(12)
         self.assert_particles(result, "SAMI_P0080_180713_control_ph.yml", RESOURCE_PATH)
         self.assertEquals(self.exception_callback_value, [])
開發者ID:danmergens,項目名稱:mi-instrument,代碼行數:9,代碼來源:test_phsen_abcdef.py

示例7: test_bug_3608

 def test_bug_3608(self):
     """
     Read test data and pull out data particles one at a time.
     Assert that the results are those we expected.
     """
     with open(os.path.join(RESOURCE_PATH, 'SAMI_P0080_160614_2.txt')) as stream_handle:
         parser = PhsenRecoveredParser(self.config, stream_handle, self.exception_callback)
         particles = parser.get_records(5000)
         self.assertEqual(len(particles), 323)
         self.assertTrue(len(self.exception_callback_value) > 0)
開發者ID:danmergens,項目名稱:mi-instrument,代碼行數:10,代碼來源:test_phsen_abcdef.py

示例8: test_long

 def test_long(self):
     """
     Test with the full original file
     """
     with open(os.path.join(RESOURCE_PATH, 'SAMI_P0080_180713_orig.txt')) as stream_handle:
         parser = PhsenRecoveredParser(self.config, stream_handle, self.exception_callback)
         # request more particles than available, only 29 in file
         result = parser.get_records(32)
         self.assertEquals(len(result), 29)
         self.assertEquals(self.exception_callback_value, [])
開發者ID:danmergens,項目名稱:mi-instrument,代碼行數:10,代碼來源:test_phsen_abcdef.py

示例9: test_simple

    def test_simple(self):
        """
        Read test data and pull out data particles one at a time.
        Assert that the results are those we expected.
        """

        with open(os.path.join(RESOURCE_PATH, 'SAMI_P0080_180713_simple.txt')) as stream_handle:
            parser = PhsenRecoveredParser(self.config, stream_handle, self.exception_callback)
            particles = parser.get_records(20)
            self.assert_particles(particles, "SAMI_P0080_180713_simple.yml", RESOURCE_PATH)
            self.assertEquals(self.exception_callback_value, [])
開發者ID:danmergens,項目名稱:mi-instrument,代碼行數:11,代碼來源:test_phsen_abcdef.py

示例10: test_get_many

    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, 'SAMI_P0080_180713_multiple.txt')) as stream_handle:
            parser = PhsenRecoveredParser(self.config, stream_handle, self.exception_callback)
            result = parser.get_records(3)
            self.assert_particles(result, 'SAMI_P0080_180713_multiple.yml', RESOURCE_PATH)
            self.assertEquals(self.exception_callback_value, [])
開發者ID:danmergens,項目名稱:mi-instrument,代碼行數:11,代碼來源:test_phsen_abcdef.py

示例11: test_invalid_num_fields_control

    def test_invalid_num_fields_control(self):
        """
        Test that the generic control records have correct number of fields
        """
        stream_handle = open(os.path.join(RESOURCE_PATH, 'SAMI_P0080_180713_invalid_control.txt'))
        parser = PhsenRecoveredParser(self.config, stream_handle, self.exception_callback)

        parser.get_records(1)

        self.assert_(isinstance(self.exception_callback_value[0], SampleException))

        stream_handle.close()
開發者ID:GrimJ,項目名稱:mi-dataset,代碼行數:12,代碼來源:test_phsen_abcdef.py

示例12: test_space_begin

    def test_space_begin(self):
        """
        Test that we handle record that begin with a space
        """
        stream_handle = open(os.path.join(RESOURCE_PATH, 'SAMI_P0080_180713_space_begin.txt'))
        parser = PhsenRecoveredParser(self.config, stream_handle, self.exception_callback)

        parser.get_records(1)

        self.assert_(isinstance(self.exception_callback_value[0], SampleException))

        stream_handle.close()
開發者ID:GrimJ,項目名稱:mi-dataset,代碼行數:12,代碼來源:test_phsen_abcdef.py

示例13: test_set_state

    def test_set_state(self):
        """
        Test changing to a new state after initializing the parser and
        reading data, as if new data has been found and the state has
        changed
        """

        stream_handle = open(os.path.join(RESOURCE_PATH, 'SAMI_P0080_180713_simple.txt'))
        self.parser = PhsenRecoveredParser(self.config, None, stream_handle,
                                           self.state_callback, self.pub_callback, self.exception_callback)
        # there should only be 4 records, make sure we stop there
        result = self.parser.get_records(1)
        expected_value = self.particle_128
        self.assertEqual(result, [expected_value])

        new_state = {StateKey.POSITION: 0x6db, StateKey.START_OF_DATA: True}

        self.parser.set_state(new_state)
        result = self.parser.get_records(1)

        expected_value = self.particle_a

        self.assertEqual(result, [expected_value])

        stream_handle.close()
開發者ID:NickAlmonte,項目名稱:mi-dataset,代碼行數:25,代碼來源:test_phsen_abcdef.py

示例14: test_recover

    def test_recover(self):
        """
        Test that we can recover after receiving bad record
        """
        stream_handle = open(os.path.join(RESOURCE_PATH, 'SAMI_P0080_180713_recover.txt'))
        self.parser = PhsenRecoveredParser(self.config, None, stream_handle, self.state_callback,
                                           self.pub_callback, self.exception_callback)
        self.parser.get_records(1)

        self.assert_(isinstance(self.exception_callback_value[0], SampleException))

        stream_handle.close()
開發者ID:NickAlmonte,項目名稱:mi-dataset,代碼行數:12,代碼來源:test_phsen_abcdef.py

示例15: test_unknown_msg_type

    def test_unknown_msg_type(self):
        """
        Test that we handle unsupported msg type
        """
        stream_handle = open(os.path.join(RESOURCE_PATH, 'SAMI_P0080_180713_unknown_msg_type.txt'))
        self.parser = PhsenRecoveredParser(self.config, None, stream_handle, self.state_callback,
                                           self.pub_callback, self.exception_callback)

        self.parser.get_records(1)

        self.assert_(isinstance(self.exception_callback_value[0], SampleException))

        stream_handle.close()
開發者ID:NickAlmonte,項目名稱:mi-dataset,代碼行數:13,代碼來源:test_phsen_abcdef.py


注:本文中的mi.dataset.parser.phsen_abcdef.PhsenRecoveredParser類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。