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


Python TestEventLogger.logEvents方法代码示例

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


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

示例1: testCompoundNewState

# 需要导入模块: from EventHandlers.tests import TestEventLogger [as 别名]
# 或者: from EventHandlers.tests.TestEventLogger import logEvents [as 别名]
    def testCompoundNewState(self):
        self._log.debug( "\ntestCompoundNewState" )

        self.loader = EventRouterLoader()
        self.loader.loadHandlers( getDictFromXmlString(testConfigCompoundEventNewState) )
        self.loader.start()  # all tasks
        self.router = self.loader.getEventRouter()

        # initial state is all things off.
        self.router.publish( EventAgent("TestCompound"), Events.evtMinute1 )

        TestEventLogger.logEvents()
        self.expectNevents( 1 )

        self.router.publish( EventAgent("TestCompound"), Events.evtMinute2 )
        self.expectNevents( 3 )
        self.assertEqual( TestEventLogger._events[2].getType(), u'internal' )
        self.assertEqual( TestEventLogger._events[2].getSource(), "testState" )
        od = TestEventLogger._events[2].getPayload()
        self.assertEqual( od["idx"], '1' )

        self.router.publish( EventAgent("TestCompound"), Events.evtMinute3 )
        self.expectNevents( 4 )

        self.router.publish( EventAgent("TestCompound"), Events.evtMinute4 )
        self.expectNevents( 6 )
        self.assertEqual( TestEventLogger._events[5].getType(), u'internal' )
        self.assertEqual( TestEventLogger._events[5].getSource(), "testState" )
        od = TestEventLogger._events[5].getPayload()
        self.assertEqual( od["idx"], 3 )  # previous minute
开发者ID:AndyThirtover,项目名称:wb_gateway,代码行数:32,代码来源:TestCompound.py

示例2: testSend

# 需要导入模块: from EventHandlers.tests import TestEventLogger [as 别名]
# 或者: from EventHandlers.tests.TestEventLogger import logEvents [as 别名]
    def testSend(self):
        self._log.debug( "\ntestListen" )
        self.loader = EventRouterLoader()
        self.loader.loadHandlers( getDictFromXmlString(testConfigAsteriskSend) )
        self.loader.start()  # all tasks
        self.router = self.loader.getEventRouter()
        
        skt = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        skt.connect(("localhost", 20998))

        skt.send( " agi_request: dialparties.agi\n" )
        skt.send( " agi_channel: SIP/100-b7a017f8\n" )
        skt.send( " agi_language: en\n" )
        skt.send( " agi_type: SIP\n" )
        skt.send( " agi_uniqueid: 1173178145.6\n" )
        skt.send( " agi_callerid: 100\n" )
        skt.send( " agi_calleridname: SNOM\n" )
        skt.send( " agi_callingpres: 0\n" )
        skt.send( " agi_callingani2: 0\n" )
        skt.send( " agi_callington: 0\n" )
        skt.send( " agi_callingtns: 0\n" )
        skt.send( " agi_dnid: 200\n" )
        skt.send( " agi_rdnis: unknown\n" )
        skt.send( " agi_context: macro-dial\n" )
        skt.send( " agi_extension: s\n" )
        skt.send( " agi_priority: 1\n" )
        skt.send( " agi_enhanced: 0.0\n" )
        skt.send( " agi_accountcode:\n" )
        skt.send( "\n" )

        skt.close()
    
        time.sleep(2)
        TestEventLogger.logEvents()
        self.assert_( len(TestEventLogger._events) >= 1)
开发者ID:AndyThirtover,项目名称:wb_gateway,代码行数:37,代码来源:TestAsterisk.py

示例3: testWebbrickStatusQuery

# 需要导入模块: from EventHandlers.tests import TestEventLogger [as 别名]
# 或者: from EventHandlers.tests.TestEventLogger import logEvents [as 别名]
    def testWebbrickStatusQuery(self):
        self._log.debug( "\n\ntestWebbrickStatusQuery" )

        self.loader = EventRouterLoader()
        self.loader.loadHandlers( getDictFromXmlString(testConfigWebbrickStatusQuery) )
        self.loader.start()  # all tasks
        self.router = self.loader.getEventRouter()

        self.router.publish( EventAgent("TestWebbrickStatusMonitor"), Events.evtSecond5 )   # so webbrick is in list for recover
        self.router.publish( EventAgent("TestWebbrickStatusMonitor"), Events.evtMinute1 )    # do recover
        waitNSeconds(2)   # recover is async
        self.router.publish( EventAgent("TestWebbrickStatusMonitor"), Events.evtSecond5 )   # do scan
        waitNSeconds(2)   # scan is async

        # We should see lots of events here as initial pass.

        # my test rig only has 1 temp sensors.
        # so:
        # 1 temp sensors
        # 4 analogue in
        # 4 analogue out
        # 12 digital in
        # 8 digital out
        # 8 mimic out
        self.assert_( TestEventLogger.expectAtLeastNevents(36+NUM_TEMP_SENSORS), "expecting %u events" % (36+NUM_TEMP_SENSORS)  )
        oldLen = len(TestEventLogger._events)

        self.router.publish( EventAgent("TestWebbrickStatusMonitor"), Events.evtSecond5 )   # do scan
        waitNSeconds(2)   # scan is async

        TestEventLogger.logEvents()
        self.assert_( oldLen <= len(TestEventLogger._events) )
开发者ID:AndyThirtover,项目名称:wb_gateway,代码行数:34,代码来源:TestWebbrickStatusQuery.py

示例4: testTestEventLogger

# 需要导入模块: from EventHandlers.tests import TestEventLogger [as 别名]
# 或者: from EventHandlers.tests.TestEventLogger import logEvents [as 别名]
    def testTestEventLogger(self):
        """
        Test loading the test event logger
        """
        _log.debug( "\ntestTestEventLogger" )
        self._loader = EventRouterLoader()
        self._loader.loadHandlers( getDictFromXmlString(testConfigTestEventLogger) )

        self._loader.start()  # all tasks

        self._router = self._loader.getEventRouter()

        self._router.publish( EventAgent("TestEventRouterLoad"), Events.evtTD0 )
        self._router.publish( EventAgent("TestEventRouterLoad"), Events.evtTD1 )
        
        if len(TestEventLogger._events) < 2 :
            time.sleep(1)   # allow threading to catch up.

        # now look for correct events requests
        TestEventLogger.logEvents()

        self.assertEqual( len(TestEventLogger._events), 2)
        self.assertEqual( TestEventLogger._events[0].getType(), "http://id.webbrick.co.uk/events/webbrick/TD" )
        self.assertEqual( TestEventLogger._events[0].getSource(), "webbrick/100/TD/0" )
        self.assertEqual( TestEventLogger._events[1].getType(), "http://id.webbrick.co.uk/events/webbrick/TD" )
        self.assertEqual( TestEventLogger._events[1].getSource(), "webbrick/100/TD/1" )
开发者ID:AndyThirtover,项目名称:wb_gateway,代码行数:28,代码来源:TestEventRouterLoad.py

示例5: testFloatCounterSet

# 需要导入模块: from EventHandlers.tests import TestEventLogger [as 别名]
# 或者: from EventHandlers.tests.TestEventLogger import logEvents [as 别名]
    def testFloatCounterSet(self):
        """
        Set Counter to a fixed value 
        """
        _log.debug( "\ntestFloatCounterSet" )
        self.loader = EventRouterLoader()
        errCount = self.loader.loadHandlers( getDictFromXmlString(testConfigFloatCounterSet) )
        self.assertEqual( errCount, 0)

        self.loader.start()  # all tasks
        self.router = self.loader.getEventRouter()

        self.router.publish( EventAgent("testCounters"), makeEvent( 'test/event', 'set/counter', { 'val':'300.45' } ) )

        TestEventLogger.logEvents()
        expectedEvents = { 
                    "test/event" : 
                            [
                                ("set/counter" , 'val', 300.45)
                            ],
                    "test/1" : 
                            [   ("test/entryCount",'val', 300.45)
                            ]
                     }
       
        Utils.expectNevents(self, 2)

        
        haveErr, excessEvents = Utils.verifyEvents2( expectedEvents, TestEventLogger._events )
        _log.debug( "Excess Events %s " % (excessEvents) )

        self.assertEqual( haveErr, False, "Incorrect event set" )
开发者ID:AndyThirtover,项目名称:wb_gateway,代码行数:34,代码来源:TestCounters.py

示例6: testDeltaTime2

# 需要导入模块: from EventHandlers.tests import TestEventLogger [as 别名]
# 或者: from EventHandlers.tests.TestEventLogger import logEvents [as 别名]
    def testDeltaTime2(self):
        """
        Test the delta time event generator.
        """
        self._log.debug( "\n\ntestDeltaTime2" )
        self.loader = EventRouterLoader()
        self.loader.loadHandlers( getDictFromXmlString(testConfigDeltaTime2) )
        self.loader.start()  # all tasks
        self.router = self.loader.getEventRouter()

        self.router.publish( EventAgent("TestDelayedEvent"), Events.evtTD0 )    # TD0 0 Off

        # time events are not in the log.
        TestEventLogger.logEvents()
        self.assertEqual( len(TestEventLogger._events), 2)
        self.assertEqual( TestEventLogger._events[0].getType(), "http://id.webbrick.co.uk/events/webbrick/TD" )
        self.assertEqual( TestEventLogger._events[1].getType(), "http://id.webbrick.co.uk/events/time/delta" )

        self.router.publish( EventAgent("TestDelayedEvent"), Events.evtMinute )    # minute
        self.router.publish( EventAgent("TestDelayedEvent"), Events.evtMinute )    # minute
        # delayed event should now be here.
        self.assertEqual( len(TestEventLogger._events), 4)
        self.assertEqual( TestEventLogger._events[2].getType(), "delta/delay" )
        self.assertEqual( TestEventLogger._events[2].getSource(), "delta/delay1" )
        self.assertEqual( TestEventLogger._events[3].getType(), "delta/delay" )
        self.assertEqual( TestEventLogger._events[3].getSource(), "delta/delay2" )
开发者ID:AndyThirtover,项目名称:wb_gateway,代码行数:28,代码来源:TestDelayedEvent.py

示例7: testIntCounterDec2Reset

# 需要导入模块: from EventHandlers.tests import TestEventLogger [as 别名]
# 或者: from EventHandlers.tests.TestEventLogger import logEvents [as 别名]
    def testIntCounterDec2Reset(self):
        _log.debug( "\ntestIntCounterDec2Reset" )
        self.loader = EventRouterLoader()
        errCount = self.loader.loadHandlers( getDictFromXmlString(testConfigDecrement2Reset) )
        self.assertEqual( errCount, 0)

        self.loader.start()  # all tasks
        self.router = self.loader.getEventRouter()

        self.router.publish( EventAgent("testCounters"), Events.evtTD0 )
        self.router.publish( EventAgent("testCounters"), Events.evtTD0 )
        self.router.publish( EventAgent("testCounters"), Events.evtHour03 )

        TestEventLogger.logEvents()

        expectedEvents = { 
                    "http://id.webbrick.co.uk/events/webbrick/TD" : 
                            [
                                ("webbrick/100/TD/0" , None, None),
                                ("webbrick/100/TD/0" , None, None)
                            ],
                    "http://id.webbrick.co.uk/events/time/hour" : 
                            [   ("time/hour",None, None)
                            ],
                    "test/entryCount" : 
                            [   ("test/entryCount",'val', 98)
                            ,   ("test/entryCountTotal",'val', 100)
                            ],
                     }
        Utils.expectNevents(self, 5)

        haveErr, excessEvents = Utils.verifyEvents2( expectedEvents, TestEventLogger._events )
        _log.debug( "Excess Events %s " % (excessEvents) )

        self.assertEqual( haveErr, False, "Incorrect event set" )
开发者ID:AndyThirtover,项目名称:wb_gateway,代码行数:37,代码来源:TestCounters.py

示例8: testTimeEvent4

# 需要导入模块: from EventHandlers.tests import TestEventLogger [as 别名]
# 或者: from EventHandlers.tests.TestEventLogger import logEvents [as 别名]
    def testTimeEvent4(self):
        """
        Run test with time interval in seconds.
        """
        self._log.debug( "\n\ntestTimeEvent4" )
        loader = EventRouterLoader()
        loader.loadHandlers( getDictFromXmlString(testConfigTime4) )

        loader.start()  # all tasks

        self._router = loader.getEventRouter()

        self.waitNEvents( 1 )
        TestEventLogger.logEvents()

        # first event should be isDark
        self.assert_( len(TestEventLogger._events) > 0)
        self.assertEqual( TestEventLogger._events[0].getType(), u'http://id.webbrick.co.uk/events/time/isDark' )
        self.assertEqual( TestEventLogger._events[0].getSource(), "time/isDark" )

        self.waitNEvents( 5 )
        TestEventLogger.logEvents()
        self.assert_( len(TestEventLogger._events) > 4)
        evt = TestEventLogger._events[1]
        od = evt.getPayload()
        self.assertEqual( len(od["timestr"]),8 )
        self.assertEqual( len(od["datestr"]),10 )
        self.assertEqual( len(od["datetimestr"]),19 )

        loader.stop()  # all tasks
        self.dumpEvents = False
开发者ID:AndyThirtover,项目名称:wb_gateway,代码行数:33,代码来源:TestTimeEventGenerator.py

示例9: testHttpAction2RequestsSpaced

# 需要导入模块: from EventHandlers.tests import TestEventLogger [as 别名]
# 或者: from EventHandlers.tests.TestEventLogger import logEvents [as 别名]
    def testHttpAction2RequestsSpaced(self):
        self._log.debug( "\ntestHttpAction2RequestsSpaced" )

        self.loader = EventRouterLoader()
        self.loader.loadHandlers( getDictFromXmlString(testConfigHttpAction) )
        self.loader.start()  # all tasks
        self.router = self.loader.getEventRouter()
        time.sleep(1)

        self.router.publish( EventAgent("TestHttpAction"), Events.evtTD0 )    # 0 Off

        maxTime = 10
        while (len(self.httpServer.requests()) < 1) and (maxTime > 0):
            maxTime -= 1
            time.sleep(1)

        self.router.publish( EventAgent("TestHttpAction"), Events.evtTD0 )    # 0 Off
        maxTime = 10
        while (len(self.httpServer.requests()) < 2) and (maxTime > 0):
            maxTime -= 1
            time.sleep(1)

        TestEventLogger.logEvents()

        # now look for correct url requests
        self._log.debug( "testHttpAction %s", self.httpServer.requests() )
        self.assertEqual( len(self.httpServer.requests()), 2)
        self.assertEqual( self.httpServer.requests()[0], "/test?medianame=ITunes&mediacmd=volup" )
        self.assertEqual( self.httpServer.requests()[1], "/test?medianame=ITunes&mediacmd=volup" )
开发者ID:AndyThirtover,项目名称:wb_gateway,代码行数:31,代码来源:TestHttpAction.py

示例10: testOnkyo

# 需要导入模块: from EventHandlers.tests import TestEventLogger [as 别名]
# 或者: from EventHandlers.tests.TestEventLogger import logEvents [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()
开发者ID:AndyThirtover,项目名称:wb_gateway,代码行数:29,代码来源:TestSerialDataConvertor.py

示例11: testTimeEvent2

# 需要导入模块: from EventHandlers.tests import TestEventLogger [as 别名]
# 或者: from EventHandlers.tests.TestEventLogger import logEvents [as 别名]
    def testTimeEvent2(self):
        """
        Run test with time interval in seconds.
        """
        self._log.debug( "\ntestTimeEvent2" )
        loader = EventRouterLoader()
        loader.loadHandlers( getDictFromXmlString(testConfigTime2) )

        loader.start()  # all tasks

        self.waitNEvents( 5, 70 )

        # now look for correct url requests
        TestEventLogger.logEvents()
        self.assertEqual( len(TestEventLogger._events), 5)

        # the requests could be in either order.
        seenOne = 0
        seenTwo = 0
        for evnt in TestEventLogger._events:
            if ( evnt.getSource() == "local/BoilerOn" ):
                seenOne += 1
            elif ( evnt.getSource() == "local/HwOn" ):
                seenTwo += 1
            else:
                pass    # error
        self.assertEqual( seenOne, 1 )
        self.assertEqual( seenTwo, 4 )

        loader.stop()  # all tasks
        self.dumpEvents = False
开发者ID:AndyThirtover,项目名称:wb_gateway,代码行数:33,代码来源:TestTimeEventGenerator.py

示例12: testSetDOOff

# 需要导入模块: from EventHandlers.tests import TestEventLogger [as 别名]
# 或者: from EventHandlers.tests.TestEventLogger import logEvents [as 别名]
 def testSetDOOff(self):
     self._log.debug( "\n\ntestSetDOOff" )
     self.timeout = time.time() + 5
     do = DigitalOutput('do/type','do/source',self.router,'10.100.100.100','2')
     do.turnOff()
     time.sleep(0.2)
     TestEventLogger.logEvents()
     assert TestEventLogger._events[0].getType() == 'do/type'
     assert TestEventLogger._events[0].getSource() == 'do/source/off'
开发者ID:AndyThirtover,项目名称:wb_gateway,代码行数:11,代码来源:hvac_digitalout_test.py

示例13: expectNevents

# 需要导入模块: from EventHandlers.tests import TestEventLogger [as 别名]
# 或者: from EventHandlers.tests.TestEventLogger import logEvents [as 别名]
    def expectNevents(self, cnt):
        idx = 2000
        while (len(TestEventLogger._events) < cnt) and (idx > 0):
            time.sleep(0.05)
            idx = idx - 1

        if len(TestEventLogger._events) != cnt:
            TestEventLogger.logEvents()

        self.assertEqual(len(TestEventLogger._events), cnt)
开发者ID:LawrenceK,项目名称:wb_gateway,代码行数:12,代码来源:TestPersistDatabase.py

示例14: testSetDODwellFinish

# 需要导入模块: from EventHandlers.tests import TestEventLogger [as 别名]
# 或者: from EventHandlers.tests.TestEventLogger import logEvents [as 别名]
 def testSetDODwellFinish(self):
     self._log.debug( "\n\ntestSetDOOn" )
     self.timeout = time.time() + 15
     do = DigitalOutput('do/type','do/source',self.router,'10.100.100.100','2')
     do.turnOn()
     #let eventrouter catch up
     time.sleep(0.2)
     TestEventLogger.logEvents()
     assert TestEventLogger._events[0].getType() == 'do/type'
     assert TestEventLogger._events[0].getSource() == 'do/source/on'
开发者ID:AndyThirtover,项目名称:wb_gateway,代码行数:12,代码来源:hvac_digitalout_test.py

示例15: testSetDOOnDwell

# 需要导入模块: from EventHandlers.tests import TestEventLogger [as 别名]
# 或者: from EventHandlers.tests.TestEventLogger import logEvents [as 别名]
 def testSetDOOnDwell(self):
     self._log.debug( "\n\ntestSetDOOn" )
     self.timeout = time.time() + 15
     do = DigitalOutput('do/type','do/source',self.router,'10.100.100.100','2')
     do.turnOn(100)
     #let eventrouter catch up
     time.sleep(0.2)
     assert TestEventLogger._events[0].getType() == 'do/type'
     assert TestEventLogger._events[0].getSource() == 'do/source/dwell'
     assert TestEventLogger._events[0].getPayload()['val'] == '100'
     TestEventLogger.logEvents()
开发者ID:AndyThirtover,项目名称:wb_gateway,代码行数:13,代码来源:hvac_digitalout_test.py


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