當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。