当前位置: 首页>>代码示例>>Python>>正文


Python TestEventLogger.clearEvents方法代码示例

本文整理汇总了Python中EventHandlers.tests.TestEventLogger.clearEvents方法的典型用法代码示例。如果您正苦于以下问题:Python TestEventLogger.clearEvents方法的具体用法?Python TestEventLogger.clearEvents怎么用?Python TestEventLogger.clearEvents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EventHandlers.tests.TestEventLogger的用法示例。


在下文中一共展示了TestEventLogger.clearEvents方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testDoTTurn

# 需要导入模块: from EventHandlers.tests import TestEventLogger [as 别名]
# 或者: from EventHandlers.tests.TestEventLogger import clearEvents [as 别名]
 def testDoTTurn(self):
     valveCfg = getDictFromXmlString(digitalTimedCfg)
     self.valve = Valve(valveCfg['valve'],self.router)
     
     #turn the valve all the way to hot
     self.valve.doTurn("TS" , 100)
     time.sleep(0.2)
     TestEventLogger.logEvents()
     assert TestEventLogger._events[0].getType() == 'internal/hvac/digitalout'
     assert TestEventLogger._events[0].getSource() == 'hvac/valve/tv1/2/off'
     assert TestEventLogger._events[1].getType()  == 'internal/hvac/digitalout'
     assert TestEventLogger._events[1].getSource() == 'hvac/valve/tv1/1/dwell'
     assert TestEventLogger._events[1].getPayload()['val'] == '100'        
     TestEventLogger.clearEvents()
     
     #turn the valve all the way to cold
     self.valve.doTurn("CS" , 100)        
     time.sleep(0.2)
     TestEventLogger.logEvents()
     assert TestEventLogger._events[0].getType()  == 'internal/hvac/digitalout'
     assert TestEventLogger._events[0].getSource() == 'hvac/valve/tv1/1/off'
     assert TestEventLogger._events[1].getType()  == 'internal/hvac/digitalout'
     assert TestEventLogger._events[1].getSource() == 'hvac/valve/tv1/2/dwell'
     assert TestEventLogger._events[1].getPayload()['val'] == '200'        
     TestEventLogger.clearEvents()
     
     #turn the valve halfway to hot
     self.valve.doTurn("TS" , 50)
     time.sleep(0.2)
     TestEventLogger.logEvents()
     assert TestEventLogger._events[0].getType()  == 'internal/hvac/digitalout'
     assert TestEventLogger._events[0].getSource() == 'hvac/valve/tv1/2/off'  
     
     assert TestEventLogger._events[1].getType()  == 'internal/hvac/digitalout'
     assert TestEventLogger._events[1].getSource() == 'hvac/valve/tv1/1/dwell'
     assert TestEventLogger._events[1].getPayload()['val'] == '50'        
     TestEventLogger.clearEvents()
     
     #turn the valve 25% further to hot, should end up getting rounded to 22
     self.valve.doTurn("TS" , 25)
     time.sleep(0.2)
     TestEventLogger.logEvents()
     assert TestEventLogger._events[0].getType()  == 'internal/hvac/digitalout'
     assert TestEventLogger._events[0].getSource() == 'hvac/valve/tv1/2/off'  
     
     assert TestEventLogger._events[1].getType()  == 'internal/hvac/digitalout'
     assert TestEventLogger._events[1].getSource() == 'hvac/valve/tv1/1/dwell'
     assert TestEventLogger._events[1].getPayload()['val'] == '25'        
     TestEventLogger.clearEvents()
开发者ID:AndyThirtover,项目名称:wb_gateway,代码行数:51,代码来源:hvac_valve_test.py

示例2: testAoTurn

# 需要导入模块: from EventHandlers.tests import TestEventLogger [as 别名]
# 或者: from EventHandlers.tests.TestEventLogger import clearEvents [as 别名]
 def testAoTurn(self):
     """
         Test to make sure the correct events are being sent out when we request valvage
         We fake the return webbrick event to avoid having to set up a live webbrick
         The outgoing http request also never gets sent as we dont initialize twisted
     """            
     valveCfg = getDictFromXmlString(aCfg)
     self.valve = Valve(valveCfg['valve'],self.router)
     
     #turn the valve all the way to hot
     self.valve.doTurn("TS" , 100)
     time.sleep(0.2)
     TestEventLogger.logEvents()
     assert TestEventLogger._events[0].getType()  == 'internal/hvac/analogoutput'
     assert TestEventLogger._events[0].getSource() == 'hvac/valve/tv1/3'
     assert TestEventLogger._events[0].getPayload()['val'] == '30'
     TestEventLogger.clearEvents()
     
     #turn the valve all the way to cold
     self.valve.doTurn("CS" , 100)        
     time.sleep(0.2)
     TestEventLogger.logEvents()
     assert TestEventLogger._events[0].getType()  == 'internal/hvac/analogoutput'
     assert TestEventLogger._events[0].getSource() == 'hvac/valve/tv1/3'
     assert TestEventLogger._events[0].getPayload()['val'] == '0'        
     TestEventLogger.clearEvents()
     
     #turn the valve halfway to hot
     self.valve.doTurn("TS" , 50)
     time.sleep(0.2)
     TestEventLogger.logEvents()
     assert TestEventLogger._events[0].getType()  == 'internal/hvac/analogoutput'
     assert TestEventLogger._events[0].getSource() == 'hvac/valve/tv1/3'
     assert TestEventLogger._events[0].getPayload()['val'] == '15'        
     TestEventLogger.clearEvents()
     
     #turn the valve 25% further to hot, should end up getting rounded to 22
     self.valve.doTurn("TS" , 25)
     time.sleep(0.2)
     TestEventLogger.logEvents()
     assert TestEventLogger._events[0].getType()  == 'internal/hvac/analogoutput'
     assert TestEventLogger._events[0].getSource() == 'hvac/valve/tv1/3'
     assert TestEventLogger._events[0].getPayload()['val'] == '22'        
     TestEventLogger.clearEvents()
开发者ID:AndyThirtover,项目名称:wb_gateway,代码行数:46,代码来源:hvac_valve_test.py

示例3: testDoTurn

# 需要导入模块: from EventHandlers.tests import TestEventLogger [as 别名]
# 或者: from EventHandlers.tests.TestEventLogger import clearEvents [as 别名]
 def testDoTurn(self):
     valveCfg = getDictFromXmlString(digitalCfg)
     self.valve = Valve(valveCfg['valve'],self.router)
     
     #because of the way the digital valves work, any turn its 100% in either direction
     #turn the valve all the way to hot
     self.valve.doTurn("TS" , 100)
     time.sleep(0.2)
     TestEventLogger.logEvents()
     assert TestEventLogger._events[0].getType()  == 'internal/hvac/digitaloutput'
     assert TestEventLogger._events[0].getSource() == 'hvac/valve/tv1/1/on'
     TestEventLogger.clearEvents()
     
     #turn the valve all the way to cold
     self.valve.doTurn("CS" , 100)        
     time.sleep(0.2)
     TestEventLogger.logEvents()
     assert TestEventLogger._events[0].getType()  == 'internal/hvac/digitaloutput'
     assert TestEventLogger._events[0].getSource() == 'hvac/valve/tv1/1/off'
     TestEventLogger.clearEvents()
     
     #turn the valve halfway to hot 
     self.valve.doTurn("TS" , 50)
     time.sleep(0.2)
     TestEventLogger.logEvents()
     assert TestEventLogger._events[0].getType()  == 'internal/hvac/digitaloutput'
     assert TestEventLogger._events[0].getSource() == 'hvac/valve/tv1/1/on'
     TestEventLogger.clearEvents()
     
     #turn the valve 25% further to hot
     self.valve.doTurn("TS" , 25)
     time.sleep(0.2)
     TestEventLogger.logEvents()
     assert TestEventLogger._events[0].getType()  == 'internal/hvac/digitaloutput'
     assert TestEventLogger._events[0].getSource() == 'hvac/valve/tv1/1/on'     
     TestEventLogger.clearEvents()
开发者ID:AndyThirtover,项目名称:wb_gateway,代码行数:38,代码来源:hvac_valve_test.py

示例4: testRun

# 需要导入模块: from EventHandlers.tests import TestEventLogger [as 别名]
# 或者: from EventHandlers.tests.TestEventLogger import clearEvents [as 别名]
    def testRun(self):
        self._log.debug( "\ntestRun" )
        self.loader = EventRouterLoader()
        self.loader.loadHandlers( getDictFromXmlString(testConfig1) )
        self.loader.start()  # all tasks
        self.router = self.loader.getEventRouter()
        time.sleep(0.1)

        # We should see lots of events here as initial pass.
        TestEventLogger.logEvents()
        oldLen = len(TestEventLogger._events)
        self.assertEqual( oldLen, 11 )  # twice sent.
        TestEventLogger.clearEvents()
        
        # send midnight
        # no new events, just me
        self.router.publish( EventAgent("TestScheduleProcessor"), evtMidnightMon )
        time.sleep(0.1)
        oldLen = len(TestEventLogger._events)
        TestEventLogger.logEvents()
        self.assertEqual( oldLen, 1 )
        self.assertEqual( TestEventLogger._events[0].getSource(), "time/minute" )

        # first event time
        self.router.publish( EventAgent("TestScheduleProcessor"), evt0530 )
        time.sleep(0.2)
        # time and two actions
        oldLen = len(TestEventLogger._events)
        TestEventLogger.logEvents()
        self.assertEqual( oldLen, 4 )
        self.assertEqual( TestEventLogger._events[1].getSource(), "time/minute" )
        self.assertEqual( TestEventLogger._events[2].getSource(), "zone1/set" )
        self.assertEqual( TestEventLogger._events[3].getSource(), "boiler/On" )

        # second event time
        self.router.publish( EventAgent("TestScheduleProcessor"), evt0800 )
        time.sleep(0.1)
        # time and one actions
        oldLen = len(TestEventLogger._events)
        TestEventLogger.logEvents()
        self.assertEqual( oldLen, 6 )
        self.assertEqual( TestEventLogger._events[4].getSource(), "time/minute" )
        self.assertEqual( TestEventLogger._events[5].getSource(), "zone1/set" )

        # third event time
        self.router.publish( EventAgent("TestScheduleProcessor"), evt1600 )
        time.sleep(0.1)
        # time and one actions
        oldLen = len(TestEventLogger._events)
        TestEventLogger.logEvents()
        self.assertEqual( oldLen, 8 )
        self.assertEqual( TestEventLogger._events[6].getSource(), "time/minute" )
        self.assertEqual( TestEventLogger._events[7].getSource(), "boiler/Off" )

        # fourth event time
        self.router.publish( EventAgent("TestScheduleProcessor"), evt2200 )
        time.sleep(0.1)
        # time and two actions
        oldLen = len(TestEventLogger._events)
        TestEventLogger.logEvents()
        self.assertEqual( oldLen, 11 )
        self.assertEqual( TestEventLogger._events[8].getSource(), "time/minute" )
        self.assertEqual( TestEventLogger._events[9].getSource(), "zone1/set" )
        self.assertEqual( TestEventLogger._events[10].getSource(), "boiler/On" )
开发者ID:AndyThirtover,项目名称:wb_gateway,代码行数:66,代码来源:TestScheduleProcessor.py


注:本文中的EventHandlers.tests.TestEventLogger.clearEvents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。