本文整理汇总了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)
示例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)
示例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)
示例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, [])
示例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)
示例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, [])
示例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)
示例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, [])
示例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, [])
示例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, [])
示例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()
示例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()
示例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()
示例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()
示例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()