本文整理汇总了Python中mi.dataset.parser.mmp_cds_base.MmpCdsParser.get_records方法的典型用法代码示例。如果您正苦于以下问题:Python MmpCdsParser.get_records方法的具体用法?Python MmpCdsParser.get_records怎么用?Python MmpCdsParser.get_records使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mi.dataset.parser.mmp_cds_base.MmpCdsParser
的用法示例。
在下文中一共展示了MmpCdsParser.get_records方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_many
# 需要导入模块: from mi.dataset.parser.mmp_cds_base import MmpCdsParser [as 别名]
# 或者: from mi.dataset.parser.mmp_cds_base.MmpCdsParser import get_records [as 别名]
def test_get_many(self):
"""
This test exercises retrieving 20 particles, verifying the 20th particle, then retrieves 30 particles
and verifies the 30th particle.
"""
with open(os.path.join(RESOURCE_PATH, 'ctd_1_20131124T005004_458.mpk'), 'rb') as stream_handle:
parser = MmpCdsParser(self.config, stream_handle, self.exception_callback)
particles = parser.get_records(20)
# Should end up with 20 particles
self.assertTrue(len(particles) == 20)
# the yml file only has particle 19 in it
self.assert_particles(particles[19:20], 'get_many_one.yml', RESOURCE_PATH)
particles = parser.get_records(30)
# Should end up with 30 particles
self.assertTrue(len(particles) == 30)
# the yml file only has particle 29 in it
self.assert_particles(particles[29:30], 'get_many_two.yml', RESOURCE_PATH)
示例2: test_bad_data_two
# 需要导入模块: from mi.dataset.parser.mmp_cds_base import MmpCdsParser [as 别名]
# 或者: from mi.dataset.parser.mmp_cds_base.MmpCdsParser import get_records [as 别名]
def test_bad_data_two(self):
"""
This test verifies that a SampleException is raised when an entire msgpack buffer is not msgpack.
"""
with open(os.path.join(RESOURCE_PATH, 'not-msg-pack.mpk'), 'rb') as stream_handle:
parser = MmpCdsParser(self.config, stream_handle, self.exception_callback)
parser.get_records(1)
self.assertTrue(len(self.exception_callback_value) >= 1)
self.assert_(isinstance(self.exception_callback_value[0], SampleException))
示例3: test_bad_data_one
# 需要导入模块: from mi.dataset.parser.mmp_cds_base import MmpCdsParser [as 别名]
# 或者: from mi.dataset.parser.mmp_cds_base.MmpCdsParser import get_records [as 别名]
def test_bad_data_one(self):
"""
This test verifies that a SampleException is raised when msgpack data is malformed.
"""
with open(os.path.join(RESOURCE_PATH, 'ctd_1_20131124T005004_BAD.mpk'), 'rb') as stream_handle:
parser = MmpCdsParser(self.config, stream_handle, self.exception_callback)
parser.get_records(1)
self.assertEqual(len(self.exception_callback_value), 1)
self.assert_(isinstance(self.exception_callback_value[0], SampleException))
示例4: test_bad_data_one
# 需要导入模块: from mi.dataset.parser.mmp_cds_base import MmpCdsParser [as 别名]
# 或者: from mi.dataset.parser.mmp_cds_base.MmpCdsParser import get_records [as 别名]
def test_bad_data_one(self):
"""
This test verifies that a SampleException is raised when msgpack data is malformed.
"""
with open(os.path.join(RESOURCE_PATH, 'acs_archive.mpk'), 'rb') as stream_handle:
parser = MmpCdsParser(self.config, stream_handle, self.exception_callback)
particles = parser.get_records(100)
self.assertTrue(len(particles) == 40)
with open(os.path.join(RESOURCE_PATH, 'acs_archive_BAD.mpk'), 'rb') as stream_handle:
parser = MmpCdsParser(self.config, stream_handle, self.exception_callback)
parser.get_records(1)
self.assertTrue(len(self.exception_callback_value) >= 1)
self.assert_(isinstance(self.exception_callback_value[0], SampleException))
示例5: test_simple
# 需要导入模块: from mi.dataset.parser.mmp_cds_base import MmpCdsParser [as 别名]
# 或者: from mi.dataset.parser.mmp_cds_base.MmpCdsParser import get_records [as 别名]
def test_simple(self):
"""
This test reads in a small number of particles and verifies the result of one of the particles.
"""
with open(os.path.join(RESOURCE_PATH, 'simple.mpk'), 'rb') as stream_handle:
parser = MmpCdsParser(self.config, stream_handle, self.exception_callback)
particles = parser.get_records(1)
self.assert_particles(particles, 'simple.yml', RESOURCE_PATH)
示例6: test_simple
# 需要导入模块: from mi.dataset.parser.mmp_cds_base import MmpCdsParser [as 别名]
# 或者: from mi.dataset.parser.mmp_cds_base.MmpCdsParser import get_records [as 别名]
def test_simple(self):
"""
This test reads in a small number of particles and verifies the result of one of the particles.
"""
with open(os.path.join(RESOURCE_PATH, 'optode_1_20131124T005004_458.mpk'), 'rb') as stream_handle:
parser = MmpCdsParser(self.config, stream_handle, self.exception_callback)
particles = parser.get_records(6)
# the yml file only has particle 5 in it
self.assert_particles(particles[5:6], 'good.yml', RESOURCE_PATH)
示例7: test_long_stream
# 需要导入模块: from mi.dataset.parser.mmp_cds_base import MmpCdsParser [as 别名]
# 或者: from mi.dataset.parser.mmp_cds_base.MmpCdsParser import get_records [as 别名]
def test_long_stream(self):
"""
This test exercises retrieve approximately 200 particles.
"""
# Using two concatenated msgpack files to simulate two chunks to get more particles.
with open(os.path.join(RESOURCE_PATH, 'ctd_concat.mpk'), 'rb') as stream_handle:
parser = MmpCdsParser(self.config, stream_handle, self.exception_callback)
# Attempt to retrieve 200 particles, but we will retrieve less
particles = parser.get_records(200)
# Should end up with 172 particles
self.assertEqual(len(particles), 172)
示例8: test_verify_with_yml
# 需要导入模块: from mi.dataset.parser.mmp_cds_base import MmpCdsParser [as 别名]
# 或者: from mi.dataset.parser.mmp_cds_base.MmpCdsParser import get_records [as 别名]
def test_verify_with_yml(self):
"""
This test exercises retrieving 4 particles and verifies them using a yml file
"""
with open(os.path.join(RESOURCE_PATH, 'flcdr_1_20131124T005004_459.mpk'), 'rb') as stream_handle:
parser = MmpCdsParser(self.config, stream_handle, self.exception_callback)
particles = parser.get_records(4)
# Should end up with 4 particles
self.assertTrue(len(particles) == 4)
self.assert_particles(particles, 'first_four_cdr.yml', RESOURCE_PATH)
示例9: test_long_stream
# 需要导入模块: from mi.dataset.parser.mmp_cds_base import MmpCdsParser [as 别名]
# 或者: from mi.dataset.parser.mmp_cds_base.MmpCdsParser import get_records [as 别名]
def test_long_stream(self):
"""
This test exercises retrieve approximately 200 particles.
"""
with open(os.path.join(RESOURCE_PATH, 'large_import.mpk'), 'rb') as stream_handle:
parser = MmpCdsParser(self.config, stream_handle, self.exception_callback)
# Attempt to retrieve 1000 particles
particles = parser.get_records(1000)
# Should end up with 1000 particles
self.assertTrue(len(particles) == 1000)
self.assert_particles(particles, 'large_import.yml', RESOURCE_PATH)
示例10: test_get_many
# 需要导入模块: from mi.dataset.parser.mmp_cds_base import MmpCdsParser [as 别名]
# 或者: from mi.dataset.parser.mmp_cds_base.MmpCdsParser import get_records [as 别名]
def test_get_many(self):
"""
This test exercises retrieving 20 particles, verifying the 20th particle, then retrieves 30 particles
and verifies the 30th particle.
"""
with open(os.path.join(RESOURCE_PATH, 'get_many.mpk'), 'rb') as stream_handle:
parser = MmpCdsParser(self.config, stream_handle, self.exception_callback)
particles = parser.get_records(50)
# Should end up with 50 particles
self.assertTrue(len(particles) == 50)
self.assert_particles(particles, 'get_many.yml', RESOURCE_PATH)