本文整理汇总了Python中pyon.util.containers.DotDict.target['constraints']方法的典型用法代码示例。如果您正苦于以下问题:Python DotDict.target['constraints']方法的具体用法?Python DotDict.target['constraints']怎么用?Python DotDict.target['constraints']使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyon.util.containers.DotDict
的用法示例。
在下文中一共展示了DotDict.target['constraints']方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_schedule
# 需要导入模块: from pyon.util.containers import DotDict [as 别名]
# 或者: from pyon.util.containers.DotDict import target['constraints'] [as 别名]
def test_create_schedule(self):
proc_def = DotDict()
proc_def['name'] = "someprocess"
proc_def['executable'] = {'module': 'my_module', 'class': 'class', 'url': 'myurl'}
mock_read_definition = Mock()
mock_read_definition.return_value = proc_def
self.pd_service.backend.read_definition = mock_read_definition
pid = self.pd_service.create_process("fake-process-def-id")
proc_schedule = DotDict()
proc_schedule['target'] = DotDict()
proc_schedule.target['constraints'] = {"hats": 4}
proc_schedule.target['node_exclusive'] = None
proc_schedule.target['execution_engine_id'] = None
configuration = {"some": "value"}
pid2 = self.pd_service.schedule_process("fake-process-def-id",
proc_schedule, configuration, pid)
self.assertTrue(pid.startswith(proc_def.name) and pid != proc_def.name)
self.assertEqual(pid, pid2)
self.assertTrue(pid.startswith(proc_def.name) and pid != proc_def.name)
self.assertEqual(self.mock_core.schedule_process.call_count, 1)
示例2: test_bridge_create_schedule
# 需要导入模块: from pyon.util.containers import DotDict [as 别名]
# 或者: from pyon.util.containers.DotDict import target['constraints'] [as 别名]
def test_bridge_create_schedule(self):
pdcfg = dict(uri="amqp://hello", topic="pd", exchange="123")
self.pd_service.CFG = DotDict()
self.pd_service.CFG['process_dispatcher_bridge'] = pdcfg
self.pd_service.init()
self.assertIsInstance(self.pd_service.backend, PDBridgeBackend)
event_pub = Mock()
self.pd_service.backend.event_pub = event_pub
# sneak in and replace dashi connection method
mock_dashi = Mock()
mock_dashi.consume.return_value = lambda : None
self.pd_service.backend._init_dashi = lambda : mock_dashi
self.pd_service.start()
self.assertEqual(mock_dashi.handle.call_count, 1)
proc_def = DotDict()
proc_def['name'] = "someprocess"
proc_def['executable'] = {'module':'my_module', 'class':'class'}
self.mock_rr_read.return_value = proc_def
pid = self.pd_service.create_process("fake-process-def-id")
proc_schedule = DotDict()
proc_schedule['target'] = DotDict()
proc_schedule.target['constraints'] = {"hats" : 4}
configuration = {"some": "value"}
pid2 = self.pd_service.schedule_process("fake-process-def-id",
proc_schedule, configuration, pid)
self.assertTrue(pid.startswith(proc_def.name) and pid != proc_def.name)
self.assertEqual(pid, pid2)
self.assertTrue(pid.startswith(proc_def.name) and pid != proc_def.name)
self.assertEqual(mock_dashi.call.call_count, 1)
call_args, call_kwargs = mock_dashi.call.call_args
self.assertEqual(set(call_kwargs),
set(['upid', 'spec', 'subscribers', 'constraints']))
self.assertEqual(call_kwargs['constraints'],
proc_schedule.target['constraints'])
self.assertEqual(call_kwargs['subscribers'],
self.pd_service.backend.pd_process_subscribers)
self.assertEqual(call_args, ("pd", "dispatch_process"))
self.assertEqual(event_pub.publish_event.call_count, 0)
# trigger some fake async state updates from dashi. first
# should not trigger an event
self.pd_service.backend._process_state(dict(upid=pid,
state="400-PENDING"))
self.assertEqual(event_pub.publish_event.call_count, 0)
self.pd_service.backend._process_state(dict(upid=pid,
state="500-RUNNING"))
self.assertEqual(event_pub.publish_event.call_count, 1)
示例3: test_bridge_schedule
# 需要导入模块: from pyon.util.containers import DotDict [as 别名]
# 或者: from pyon.util.containers.DotDict import target['constraints'] [as 别名]
def test_bridge_schedule(self):
pdcfg = dict(uri="amqp://hello", topic="pd", exchange="123")
self.pd_service.CFG = DotDict()
self.pd_service.CFG['process_dispatcher_bridge'] = pdcfg
self.pd_service.init()
self.assertIsInstance(self.pd_service.backend, PDBridgeBackend)
# sneak in and replace dashi connection method
mock_dashi = Mock()
self.pd_service.backend._init_dashi = lambda : mock_dashi
self.pd_service.start()
proc_def = DotDict()
proc_def['name'] = "someprocess"
proc_def['executable'] = {'module':'my_module', 'class':'class'}
self.mock_rr_read.return_value = proc_def
proc_schedule = DotDict()
proc_schedule['target'] = DotDict()
proc_schedule.target['constraints'] = {"hats" : 4}
configuration = {"some": "value"}
pid = self.pd_service.schedule_process("fake-process-def-id",
proc_schedule, configuration)
self.mock_rr_read.assert_called_once_with("fake-process-def-id", "")
self.assertTrue(pid.startswith(proc_def.name) and pid != proc_def.name)
self.assertEqual(mock_dashi.call.call_count, 1)
call_args, call_kwargs = mock_dashi.call.call_args
self.assertEqual(set(call_kwargs),
set(['upid', 'spec', 'subscribers', 'constraints']))
self.assertEqual(call_kwargs['constraints'],
proc_schedule.target['constraints'])
self.assertEqual(call_args, ("pd", "dispatch_process"))