Best Python code snippet using pyatom_python
AIEvent.py
Source:AIEvent.py
1# -*- coding: utf-8 -*-2"""3"""4import KBEngine5from KBEDebug import *6from SrvDef import eEntityEvent7class AIEventDef:8 """9 """10 registerD = {11 eEntityEvent.OnHPChanged : lambda executor, event: executor.registerEvent(event, executor.__class__, "aiEvent_onHPChanged"),12 eEntityEvent.OnReceiveDamage : lambda executor, event: executor.registerEvent(event, executor.__class__, "aiEvent_onReceiveDamage"),13 eEntityEvent.OnKilled : lambda executor, event: executor.registerEvent(event, executor.__class__, "aiEvent_onKilled"),14 eEntityEvent.OnDead : lambda executor, event: executor.registerEvent(event, executor.__class__, "aiEvent_onDead"),15 eEntityEvent.OnEnterFight : lambda executor, event: executor.registerEvent(event, executor.__class__, "aiEvent_onEnterFight"),16 }17 18 deregisterD = {19 eEntityEvent.OnHPChanged : lambda executor, event: executor.deregisterEvent(event, executor.__class__, "aiEvent_onHPChanged"),20 eEntityEvent.OnReceiveDamage : lambda executor, event: executor.deregisterEvent(event, executor.__class__, "aiEvent_onReceiveDamage"),21 eEntityEvent.OnKilled : lambda executor, event: executor.deregisterEvent(event, executor.__class__, "aiEvent_onKilled"),22 eEntityEvent.OnDead : lambda executor, event: executor.deregisterEvent(event, executor.__class__, "aiEvent_onDead"),23 eEntityEvent.OnEnterFight : lambda executor, event: executor.deregisterEvent(event, executor.__class__, "aiEvent_onEnterFight"),24 }25 26 @classmethod27 def register( cls, executor, event ):28 """29 @param executor: æ§è¡AIè¡ä¸ºçentityï¼ä¾å¦ï¼NPCãå® ç©ï¼30 @param event: eEntityEvent.*31 """32 f = cls.registerD.get( event )33 if f:34 f(executor, event)35 @classmethod36 def deregister( cls, executor, event ):37 """38 @param executor: æ§è¡AIè¡ä¸ºçentityï¼ä¾å¦ï¼NPCãå® ç©ï¼39 @param event: eEntityEvent.*40 """41 f = cls.deregisterD.get( event )42 if f:...
AMISendTest.py
Source:AMISendTest.py
1#!/usr/bin/env python2'''3Copyright (C) 2013, Digium, Inc.4Kevin Harwell <kharwell@digium.com>5This program is free software, distributed under the terms of6the GNU General Public License Version 2.7'''8import sys9sys.path.append("lib/python/asterisk")10from test_case import TestCase11ACTION = {12 "Action": "PJSIPShowRegistrationsOutbound",13 "ActionID": "12345",14}15class AMISendTest(TestCase):16 def __init__(self, path=None, config=None):17 super(AMISendTest, self).__init__(path, config)18 self.create_asterisk()19 def run(self):20 super(AMISendTest, self).run()21 self.create_ami_factory()22 def ami_connect(self, ami):23 # wait for asterisk to attempt registration24 ami.registerEvent('Registry', self.__on_registry)25 def __on_registry(self, ami, event):26 # asterisk attempted registration, so check details27 ami.deregisterEvent('Registry', None)28 ami.sendDeferred(ACTION).addCallback(self.__on_response)29 def __on_response(self, result):30 # stop test since done...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!