本文整理汇总了Python中EventHandlers.tests.TestEventLogger.expectNevents方法的典型用法代码示例。如果您正苦于以下问题:Python TestEventLogger.expectNevents方法的具体用法?Python TestEventLogger.expectNevents怎么用?Python TestEventLogger.expectNevents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventHandlers.tests.TestEventLogger
的用法示例。
在下文中一共展示了TestEventLogger.expectNevents方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testOnkyo
# 需要导入模块: from EventHandlers.tests import TestEventLogger [as 别名]
# 或者: from EventHandlers.tests.TestEventLogger import expectNevents [as 别名]
def testOnkyo(self):
self._log.debug( "\ntestOnkyo" )
self.loader = EventRouterLoader()
self.loader.loadHandlers( getDictFromXmlString(testConfigOnkyo) )
self.loader.start() # all tasks
self.router = self.loader.getEventRouter()
self.router.publish( EventAgent("testVolume"), evtOnkyoVolume0 )
# time events are not in the log.
self.assert_(TestEventLogger.expectNevents(2))
self.assertEqual( TestEventLogger._events[0].getSource(), "webbrick/1/100" )
evt = TestEventLogger._events[1]
self.assertEqual( evt.getType(), "avamplifier/volume/current" )
self.assertEqual( evt.getSource(), "avamplifier/1/volume/main/current" )
evtod = evt.getPayload()
self.assert_( evtod.has_key("val") )
self.assertEqual( evtod["val"], 0 )
self.router.publish( EventAgent("testVolume"), evtOnkyoVolume50 )
self.assert_(TestEventLogger.expectNevents(4))
self.router.publish( EventAgent("testVolume"), evtOnkyoVolume100 )
self.assert_(TestEventLogger.expectNevents(6))
TestEventLogger.logEvents()
示例2: testReadLogFile2
# 需要导入模块: from EventHandlers.tests import TestEventLogger [as 别名]
# 或者: from EventHandlers.tests.TestEventLogger import expectNevents [as 别名]
def testReadLogFile2(self):
self.loader = EventRouterLoader()
self.loader.loadHandlers( getDictFromXmlString(testConfig) )
self.loader.start() # all tasks
self.router = self.loader.getEventRouter()
ReadLogFileSendEvents( "resources/EventLog.log", self.router )
TestEventLogger.expectNevents(9)
self.assertEqual( TestEventLogger._events[0].getSource(), "temperature/outside" )
self.assertEqual( TestEventLogger._events[1].getSource(), "webbrick/3/1" )
self.assertEqual( TestEventLogger._events[2].getSource(), "webbrick/3/1" )
self.assertEqual( TestEventLogger._events[3].getSource(), "webbrick/6" )
self.assertEqual( TestEventLogger._events[4].getSource(), "webbrick/2" )
self.assertEqual( TestEventLogger._events[5].getSource(), "webbrick/7" )
self.assertEqual( TestEventLogger._events[6].getSource(), "webbrick/4" )
self.assertEqual( TestEventLogger._events[7].getSource(), "webbrick/9/CT/3" )
self.assertEqual( TestEventLogger._events[8].getSource(), "webbrick/9/AI/0" )
示例3: testDataset
# 需要导入模块: from EventHandlers.tests import TestEventLogger [as 别名]
# 或者: from EventHandlers.tests.TestEventLogger import expectNevents [as 别名]
def testDataset(self):
"""
Test the data set creator
"""
self._log.debug( "\ntestDataset" )
logHandler = testLogHandler()
addTestLogHandler(logHandler,"Dataset")
self.loader = EventRouterLoader()
self.loader.loadHandlers( getDictFromXmlString(testConfigDataset) )
self.loader.start() # all tasks
self.router = self.loader.getEventRouter()
self.router.publish( EventAgent("TestLogEvent"), Events.evtAI_1_50 )
self.router.publish( EventAgent("TestLogEvent"), Events.evtCT_1_25 )
self.router.publish( EventAgent("TestLogEvent"), Events.evtMinute1 )
time.sleep(1.0)
self.assertEqual( logHandler.count(), 2 )
TestEventLogger.expectNevents(4)
TestEventLogger.logEvents()
removeTestLogHandler(logHandler,"Dataset")
示例4: testStartupAtHome
# 需要导入模块: from EventHandlers.tests import TestEventLogger [as 别名]
# 或者: from EventHandlers.tests.TestEventLogger import expectNevents [as 别名]
def testStartupAtHome(self):
self._log.debug( "\ntestStartupAtHome" )
self.loader = EventRouterLoader()
self.loader.loadHandlers( getDictFromXmlString(testCalendarConfig) )
self.loader.start() # all tasks
self.router = self.loader.getEventRouter()
self.router.publish( EventAgent("TestCalendarEvent"), evtMinuteAtHome )
self.assert_( TestEventLogger.expectNevents(2), "Expected 2 events only seen %s" % (len(TestEventLogger._events)) )
# first is subscribe event
self.assertEqual( TestEventLogger._events[0].getSource(), "time/minute" )
self.assertEqual( TestEventLogger._events[1].getSource(), "occupants/home" )
self.assertEqual( TestEventLogger._events[1].getPayload()["val"], 1 )
示例5: test8BitChecksum
# 需要导入模块: from EventHandlers.tests import TestEventLogger [as 别名]
# 或者: from EventHandlers.tests.TestEventLogger import expectNevents [as 别名]
def test8BitChecksum(self):
self._log.debug( "\ntest8BitChecksum" )
self.loader = EventRouterLoader()
self.loader.loadHandlers( getDictFromXmlString(test8bitchecksum) )
self.loader.start() # all tasks
self.router = self.loader.getEventRouter()
self.router.publish( EventAgent("testVolume"), evt8bitchecksum )
# time events are not in the log.
self.assert_(TestEventLogger.expectNevents(2))
self.assertEqual( TestEventLogger._events[0].getSource(), "webbrick/1/100" )
evt = TestEventLogger._events[1]
self.assertEqual( evt.getType(), "avamplifier/volume/current" )
self.assertEqual( evt.getSource(), "avamplifier/1/volume/main/current" )
evtod = evt.getPayload()
self.assert_( evtod.has_key("val") )
self.assertEqual( evtod["val"], '20;20;84;55;55;50;2;227:' )
TestEventLogger.logEvents()