當前位置: 首頁>>代碼示例>>Python>>正文


Python BaseDataHandler._unlock_new_data_callback方法代碼示例

本文整理匯總了Python中ion.agents.data.handlers.base_data_handler.BaseDataHandler._unlock_new_data_callback方法的典型用法代碼示例。如果您正苦於以下問題:Python BaseDataHandler._unlock_new_data_callback方法的具體用法?Python BaseDataHandler._unlock_new_data_callback怎麽用?Python BaseDataHandler._unlock_new_data_callback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ion.agents.data.handlers.base_data_handler.BaseDataHandler的用法示例。


在下文中一共展示了BaseDataHandler._unlock_new_data_callback方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: TestBaseDataHandlerUnit

# 需要導入模塊: from ion.agents.data.handlers.base_data_handler import BaseDataHandler [as 別名]
# 或者: from ion.agents.data.handlers.base_data_handler.BaseDataHandler import _unlock_new_data_callback [as 別名]

#.........這裏部分代碼省略.........
        self.assertEqual(ret1, ResourceAgentState.COMMAND)
        self.assertIsNone(ret2)
        self.assertFalse(self._bdh._polling)
        self.assertIsNone(self._bdh._polling_glet)

    def test_get_resource_params(self):
        ret = self._bdh.get_resource_params()
        self.assertEqual(ret, ['PATCHABLE_CONFIG_KEYS', 'POLLING_INTERVAL'])

    def test_get_resource_commands(self):
        ret = self._bdh.get_resource_commands()
        self.assertEqual(ret, ['acquire_sample', 'resource', 'start_autosample', 'stop_autosample'])

    def test__init_acquisition_cycle(self):
        config = {}
        with self.assertRaises(NotImplementedException) as cm:
            BaseDataHandler._init_acquisition_cycle(config)
            ex = cm.exception
            # TODO: This is brittle as the message could change - do we need this check, or is getting the exception enough?
            self.assertEqual(ex.message, "ion.agents.data.handlers.base_data_handler.BaseDataHandler must implement '_init_acquisition_cycle'")

    def test__constraints_for_new_request(self):
        config = {}
        self.assertRaises(NotImplementedException, BaseDataHandler._constraints_for_new_request, config)

    def test__constraints_for_historical_request(self):
        config = {}
        self.assertRaises(NotImplementedException, BaseDataHandler._constraints_for_historical_request, config)

    def test__get_data(self):
        config = {}
        self.assertRaises(NotImplementedException, BaseDataHandler._get_data, config)

    def test__unlock_new_data_callback(self):
        self._bdh._semaphore = Mock()
        self._bdh._unlock_new_data_callback(None)
        self._bdh._semaphore.release.assert_called_once()

    def test_get_all(self):
        #TODO: Need to change back to enums instead of strings. Problem with BaseEnum.
        ret = self._bdh.get(['DRIVER_PARAMETER_ALL'])
        self.assertEqual(ret, {
            'POLLING_INTERVAL': 30,
            'PATCHABLE_CONFIG_KEYS': ['stream_id', 'constraints', 'stream_route']
        })

    def test_get_all_with_no_arguments(self):
        ret = self._bdh.get()

        self.assertEqual(ret, {
            'POLLING_INTERVAL': 30,
            'PATCHABLE_CONFIG_KEYS': ['stream_id', 'constraints', 'stream_route']
        })

    def test_get_not_list_or_tuple(self):
        self.assertRaises(InstrumentParameterException, self._bdh.get, 'not_found')

    def test_get_polling_interval(self):
        #TODO: Need to change back to enums instead of strings.
        # Problem with BaseEnum.
        ret = self._bdh.get(['POLLING_INTERVAL'])
        self.assertEqual(ret, {'POLLING_INTERVAL': 30})

    def test_get_patchable_config_keys(self):
        #TODO: Need to change back to enums instead of strings. Problem with BaseEnum.
        ret = self._bdh.get(['PATCHABLE_CONFIG_KEYS'])
開發者ID:Bobfrat,項目名稱:coi-services,代碼行數:70,代碼來源:test_base_data_handler.py

示例2: TestBaseDataHandlerUnit

# 需要導入模塊: from ion.agents.data.handlers.base_data_handler import BaseDataHandler [as 別名]
# 或者: from ion.agents.data.handlers.base_data_handler.BaseDataHandler import _unlock_new_data_callback [as 別名]

#.........這裏部分代碼省略.........
        self.assertIsNone(self._bdh._polling_glet)

    def test_get_resource_params(self):
        ret = self._bdh.get_resource_params()
        self.assertEqual(ret, ["PATCHABLE_CONFIG_KEYS", "POLLING_INTERVAL"])

    def test_get_resource_commands(self):
        ret = self._bdh.get_resource_commands()
        self.assertEqual(ret, ["acquire_data", "start_autosample", "stop_autosample"])

    def test__init_acquisition_cycle(self):
        config = {}
        with self.assertRaises(NotImplementedException) as cm:
            BaseDataHandler._init_acquisition_cycle(config)
            ex = cm.exception
            # TODO: This is brittle as the message could change - do we need this check, or is getting the exception enough?
            self.assertEqual(
                ex.message,
                "ion.agents.data.handlers.base_data_handler.BaseDataHandler must implement '_init_acquisition_cycle'",
            )

    def test__constraints_for_new_request(self):
        config = {}
        self.assertRaises(NotImplementedException, BaseDataHandler._constraints_for_new_request, config)

    def test__constraints_for_historical_request(self):
        config = {}
        self.assertRaises(NotImplementedException, BaseDataHandler._constraints_for_historical_request, config)

    def test__get_data(self):
        config = {}
        self.assertRaises(NotImplementedException, BaseDataHandler._get_data, config)

    def test__unlock_new_data_callback(self):
        self._bdh._semaphore = Mock()
        self._bdh._unlock_new_data_callback(None)
        self._bdh._semaphore.release.assert_called_once()

    def test_get_all(self):
        # TODO: Need to change back to enums instead of strings. Problem with BaseEnum.
        ret = self._bdh.get(["DRIVER_PARAMETER_ALL"])
        self.assertEqual(ret, {"POLLING_INTERVAL": 3600, "PATCHABLE_CONFIG_KEYS": ["stream_id", "constraints"]})

    def test_get_all_with_no_arguments(self):
        ret = self._bdh.get()

        self.assertEqual(ret, {"POLLING_INTERVAL": 3600, "PATCHABLE_CONFIG_KEYS": ["stream_id", "constraints"]})

    def test_get_not_list_or_tuple(self):
        self.assertRaises(InstrumentParameterException, self._bdh.get, "not_found")

    def test_get_polling_interval(self):
        # TODO: Need to change back to enums instead of strings. Problem with BaseEnum.
        ret = self._bdh.get(["POLLING_INTERVAL"])
        self.assertEqual(ret, {"POLLING_INTERVAL": 3600})

    def test_get_patchable_config_keys(self):
        # TODO: Need to change back to enums instead of strings. Problem with BaseEnum.
        ret = self._bdh.get(["PATCHABLE_CONFIG_KEYS"])
        self.assertEqual(ret, {"PATCHABLE_CONFIG_KEYS": ["stream_id", "constraints"]})

    def test_get_polling_and_patchable_config_keys(self):
        # TODO: Need to change back to enums instead of strings. Problem with BaseEnum.
        ret = self._bdh.get(["POLLING_INTERVAL", "PATCHABLE_CONFIG_KEYS"])
        self.assertEqual(ret, {"POLLING_INTERVAL": 3600, "PATCHABLE_CONFIG_KEYS": ["stream_id", "constraints"]})
開發者ID:pombredanne,項目名稱:coi-services,代碼行數:69,代碼來源:test_base_data_handler.py

示例3: TestBaseDataHandlerUnit

# 需要導入模塊: from ion.agents.data.handlers.base_data_handler import BaseDataHandler [as 別名]
# 或者: from ion.agents.data.handlers.base_data_handler.BaseDataHandler import _unlock_new_data_callback [as 別名]

#.........這裏部分代碼省略.........

    def test_get_resource_commands(self):
        ret = self._bdh.get_resource_commands()
        self.assertEqual(ret, ['acquire_data', 'start_autosample', 'stop_autosample'])

    def test__init_acquisition_cycle(self):
        config = {}
        with self.assertRaises(NotImplementedException) as cm:
            BaseDataHandler._init_acquisition_cycle(config)
            ex = cm.exception
            # TODO: This is brittle as the message could change - do we need this check, or is getting the exception enough?
            self.assertEqual(ex.message, "ion.agents.data.handlers.base_data_handler.BaseDataHandler must implement '_init_acquisition_cycle'")

    def test__new_data_constraints(self):
        config = {}
        self.assertRaises(NotImplementedException, BaseDataHandler._new_data_constraints, config)

    def test__get_data(self):
        config = {}
        self.assertRaises(NotImplementedException, BaseDataHandler._get_data, config)

    def test__calc_iter_cnt_even(self):
        total_recs = 100
        max_rec = 10
        ret = BaseDataHandler._calc_iter_cnt(total_recs=total_recs, max_rec=max_rec)
        self.assertEqual(ret, 10)

    def test__calc_iter_cnt_remainder(self):
        total_recs = 101
        max_rec = 10
        ret = BaseDataHandler._calc_iter_cnt(total_recs=total_recs, max_rec=max_rec)
        self.assertEqual(ret, 11)

    def test__unlock_new_data_callback(self):
        self._bdh._semaphore = Mock()
        self._bdh._unlock_new_data_callback(None)
        self._bdh._semaphore.release.assert_called_once()

    def test_get_all(self):
        #TODO: Need to change back to enums instead of strings. Problem with BaseEnum.
        ret = self._bdh.get(['DRIVER_PARAMETER_ALL'])
        self.assertEqual(ret, {
            'POLLING_INTERVAL' : 3600,
            'PATCHABLE_CONFIG_KEYS' : ['stream_id','constraints']
        })

    def test_get_all_with_no_arguments(self):
        ret = self._bdh.get()

        self.assertEqual(ret, {
            'POLLING_INTERVAL' : 3600,
            'PATCHABLE_CONFIG_KEYS' : ['stream_id','constraints']
        })

    def test_get_not_list_or_tuple(self):
        self.assertRaises(InstrumentParameterException, self._bdh.get, 'not_found')

    def test_get_polling_interval(self):
        #TODO: Need to change back to enums instead of strings. Problem with BaseEnum.
        ret = self._bdh.get(['POLLING_INTERVAL'])
        self.assertEqual(ret, {'POLLING_INTERVAL' : 3600})

    def test_get_patchable_config_keys(self):
        #TODO: Need to change back to enums instead of strings. Problem with BaseEnum.
        ret = self._bdh.get(['PATCHABLE_CONFIG_KEYS'])
        self.assertEqual(ret, {'PATCHABLE_CONFIG_KEYS' : ['stream_id','constraints']})
開發者ID:dstuebe,項目名稱:coi-services,代碼行數:70,代碼來源:test_base_data_handler.py


注:本文中的ion.agents.data.handlers.base_data_handler.BaseDataHandler._unlock_new_data_callback方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。