当前位置: 首页>>代码示例>>Python>>正文


Python mmp_cds_base.MmpCdsParser类代码示例

本文整理汇总了Python中mi.dataset.parser.mmp_cds_base.MmpCdsParser的典型用法代码示例。如果您正苦于以下问题:Python MmpCdsParser类的具体用法?Python MmpCdsParser怎么用?Python MmpCdsParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MmpCdsParser类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_many

    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)
开发者ID:JeffRoy,项目名称:mi-dataset,代码行数:25,代码来源:test_ctdpf_ckl_mmp_cds.py

示例2: test_bad_data_two

    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))
开发者ID:JeffRoy,项目名称:mi-dataset,代码行数:12,代码来源:test_ctdpf_ckl_mmp_cds.py

示例3: test_simple

    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)
开发者ID:danmergens,项目名称:mi-instrument,代码行数:12,代码来源:test_optaa_ac_mmp_cds.py

示例4: test_bad_data_one

    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))
开发者ID:JeffRoy,项目名称:mi-dataset,代码行数:13,代码来源:test_ctdpf_ckl_mmp_cds.py

示例5: test_simple

    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)
开发者ID:JeffRoy,项目名称:mi-dataset,代码行数:13,代码来源:test_dosta_abcdjm_mmp_cds.py

示例6: test_long_stream

    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)
开发者ID:JeffRoy,项目名称:mi-dataset,代码行数:15,代码来源:test_ctdpf_ckl_mmp_cds.py

示例7: test_verify_with_yml

    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)
开发者ID:danmergens,项目名称:mi-instrument,代码行数:15,代码来源:test_flcdr_x_mmp_cds.py

示例8: test_long_stream

    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)
开发者ID:danmergens,项目名称:mi-instrument,代码行数:16,代码来源:test_optaa_ac_mmp_cds.py

示例9: test_get_many

    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)
开发者ID:danmergens,项目名称:mi-instrument,代码行数:16,代码来源:test_optaa_ac_mmp_cds.py

示例10: test_bad_data_one

    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))
开发者ID:danmergens,项目名称:mi-instrument,代码行数:21,代码来源:test_optaa_ac_mmp_cds.py


注:本文中的mi.dataset.parser.mmp_cds_base.MmpCdsParser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。