本文整理汇总了Python中mi.dataset.parser.phsen_abcdef.PhsenRecoveredParser.get_records方法的典型用法代码示例。如果您正苦于以下问题:Python PhsenRecoveredParser.get_records方法的具体用法?Python PhsenRecoveredParser.get_records怎么用?Python PhsenRecoveredParser.get_records使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mi.dataset.parser.phsen_abcdef.PhsenRecoveredParser
的用法示例。
在下文中一共展示了PhsenRecoveredParser.get_records方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_invalid_num_fields_special_control
# 需要导入模块: from mi.dataset.parser.phsen_abcdef import PhsenRecoveredParser [as 别名]
# 或者: from mi.dataset.parser.phsen_abcdef.PhsenRecoveredParser import get_records [as 别名]
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)
示例2: test_recover
# 需要导入模块: from mi.dataset.parser.phsen_abcdef import PhsenRecoveredParser [as 别名]
# 或者: from mi.dataset.parser.phsen_abcdef.PhsenRecoveredParser import get_records [as 别名]
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)
示例3: test_unknown_msg_type
# 需要导入模块: from mi.dataset.parser.phsen_abcdef import PhsenRecoveredParser [as 别名]
# 或者: from mi.dataset.parser.phsen_abcdef.PhsenRecoveredParser import get_records [as 别名]
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)
示例4: test_alpha_field
# 需要导入模块: from mi.dataset.parser.phsen_abcdef import PhsenRecoveredParser [as 别名]
# 或者: from mi.dataset.parser.phsen_abcdef.PhsenRecoveredParser import get_records [as 别名]
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)
示例5: test_invalid_num_fields_control
# 需要导入模块: from mi.dataset.parser.phsen_abcdef import PhsenRecoveredParser [as 别名]
# 或者: from mi.dataset.parser.phsen_abcdef.PhsenRecoveredParser import get_records [as 别名]
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()
示例6: test_space_begin
# 需要导入模块: from mi.dataset.parser.phsen_abcdef import PhsenRecoveredParser [as 别名]
# 或者: from mi.dataset.parser.phsen_abcdef.PhsenRecoveredParser import get_records [as 别名]
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()
示例7: test_no_data_tag
# 需要导入模块: from mi.dataset.parser.phsen_abcdef import PhsenRecoveredParser [as 别名]
# 或者: from mi.dataset.parser.phsen_abcdef.PhsenRecoveredParser import get_records [as 别名]
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, [])
示例8: test_integration_control
# 需要导入模块: from mi.dataset.parser.phsen_abcdef import PhsenRecoveredParser [as 别名]
# 或者: from mi.dataset.parser.phsen_abcdef.PhsenRecoveredParser import get_records [as 别名]
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, [])
示例9: test_long
# 需要导入模块: from mi.dataset.parser.phsen_abcdef import PhsenRecoveredParser [as 别名]
# 或者: from mi.dataset.parser.phsen_abcdef.PhsenRecoveredParser import get_records [as 别名]
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, [])
示例10: test_bug_3608
# 需要导入模块: from mi.dataset.parser.phsen_abcdef import PhsenRecoveredParser [as 别名]
# 或者: from mi.dataset.parser.phsen_abcdef.PhsenRecoveredParser import get_records [as 别名]
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)
示例11: test_get_many
# 需要导入模块: from mi.dataset.parser.phsen_abcdef import PhsenRecoveredParser [as 别名]
# 或者: from mi.dataset.parser.phsen_abcdef.PhsenRecoveredParser import get_records [as 别名]
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, [])
示例12: test_simple
# 需要导入模块: from mi.dataset.parser.phsen_abcdef import PhsenRecoveredParser [as 别名]
# 或者: from mi.dataset.parser.phsen_abcdef.PhsenRecoveredParser import get_records [as 别名]
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, [])
示例13: PhsenRecoveredParserUnitTestCase
# 需要导入模块: from mi.dataset.parser.phsen_abcdef import PhsenRecoveredParser [as 别名]
# 或者: from mi.dataset.parser.phsen_abcdef.PhsenRecoveredParser import get_records [as 别名]
#.........这里部分代码省略.........
'2981', '1210', '2502', '2065',
'2981', '1303', '2502', '2129',
'2981', '1382', '2506', '2179',
'2984', '1456', '2508', '2227',
'2982', '1524', '2502', '2269',
'0', '2854', '2373'])
self.particle_128 = PhsenRecoveredMetadataDataParticle(['128', '3456970176', '65', '1', '0', '512'])
self.particle_129 = PhsenRecoveredMetadataDataParticle(['129', '3456975599', '67', '4', '0', '566'])
self.state_callback_value = None
self.publish_callback_value = None
self.exception_callback_value = []
def assert_result(self, result, in_process_data, unprocessed_data, particle):
self.assertEqual(result, [particle])
self.assert_state(in_process_data, unprocessed_data)
self.assert_(isinstance(self.publish_callback_value, list))
self.assertEqual(self.publish_callback_value[0], particle)
def test_simple(self):
"""
Read test data and pull out data particles one at a time.
Assert that the results are those we expected.
"""
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)
result = self.parser.get_records(1)
expected_value = self.particle_128
self.assertEqual(result, [expected_value])
result = self.parser.get_records(1)
expected_value = PhsenRecoveredMetadataDataParticle(['133', '3456974356', '65', '2', '0', '530'])
self.assertEqual(result, [expected_value])
# skipping over second 133 record
self.parser.get_records(1)
result = self.parser.get_records(1)
expected_value = self.particle_129
self.assertEqual(result, [expected_value])
# next record is 191, which we handle but should not get
result = self.parser.get_records(1)
expected_value = PhsenRecoveredMetadataDataParticle(['191', '3456975599', '67', '4', '0', '566', '666'])
self.assertEqual(result, [expected_value])
# next record is 255, which we handle but should not get
result = self.parser.get_records(1)
expected_value = PhsenRecoveredMetadataDataParticle(['255', '3456975599', '67', '4', '0', '566', '777'])
self.assertEqual(result, [expected_value])
result = self.parser.get_records(1)
expected_value = PhsenRecoveredMetadataDataParticle(['192', '3456975599', '67', '4', '0', '566', '888'])
self.assertEqual(result, [expected_value])
result = self.parser.get_records(1)
expected_value = PhsenRecoveredMetadataDataParticle(['193', '3456975599', '67', '4', '0', '566', '999'])
self.assertEqual(result, [expected_value])