本文整理汇总了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'])
示例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"]})
示例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']})