本文整理汇总了Python中pypeman.channels.BaseChannel.case方法的典型用法代码示例。如果您正苦于以下问题:Python BaseChannel.case方法的具体用法?Python BaseChannel.case怎么用?Python BaseChannel.case使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pypeman.channels.BaseChannel
的用法示例。
在下文中一共展示了BaseChannel.case方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_case_channel
# 需要导入模块: from pypeman.channels import BaseChannel [as 别名]
# 或者: from pypeman.channels.BaseChannel import case [as 别名]
def test_case_channel(self):
""" Whether Conditionnal channel is working """
chan = BaseChannel(name="test_channel6", loop=self.loop)
n1 = TestNode(name="main")
n2 = TestNode(name="end_main")
not_processed = TestNode(name="cond_notproc")
processed = TestNode(name="cond_proc")
not_processed2 = TestNode(name="cond_proc2")
msg = generate_msg()
chan.add(n1)
cond1, cond2, cond3 = chan.case(lambda x: False, True, True, names=['first', 'second', 'third'])
chan.add(n2)
cond1.add(not_processed)
cond2.add(processed)
cond3.add(not_processed2)
# Launch channel processing
self.start_channels()
self.loop.run_until_complete(chan.handle(msg))
self.assertFalse(not_processed.processed, "Case Channel when condition == False not working")
self.assertFalse(not_processed2.processed, "Case Channel when condition == False not working")
self.assertTrue(processed.processed, "Case Channel when condition == True not working")
self.assertTrue(n2.processed, "Cond Channel don't became the main path")
self.assertEqual(cond1.name, "test_channel6.first", "Casechannel name is incorrect")
self.assertEqual(cond2.name, "test_channel6.second", "Casechannel name is incorrect")
self.assertEqual(cond3.name, "test_channel6.third", "Casechannel name is incorrect")