本文整理匯總了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")