[asterisk-commits] jpeeler: branch jpeeler/event_watcher r262 - /asterisk/team/jpeeler/event_wat...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Apr 28 18:45:23 CDT 2010
Author: jpeeler
Date: Wed Apr 28 18:45:19 2010
New Revision: 262
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=262
Log:
move next_test out of test module
Modified:
asterisk/team/jpeeler/event_watcher/tests/ami-monitor/client.py
asterisk/team/jpeeler/event_watcher/tests/ami-monitor/run-test
Modified: asterisk/team/jpeeler/event_watcher/tests/ami-monitor/client.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/jpeeler/event_watcher/tests/ami-monitor/client.py?view=diff&rev=262&r1=261&r2=262
==============================================================================
--- asterisk/team/jpeeler/event_watcher/tests/ami-monitor/client.py (original)
+++ asterisk/team/jpeeler/event_watcher/tests/ami-monitor/client.py Wed Apr 28 18:45:19 2010
@@ -53,6 +53,9 @@
def next_test(self, cb):
self.next_test = cb
+
+ def set_test_obj(self, testobj):
+ self.testobj = testobj
def set_ordered(self, ordered):
self.ordered = ordered
@@ -101,7 +104,7 @@
#log.critical("JPEELER: Checking dictionaries")
return len(d_subset) == len(set(d_subset.items()) & set(d_set.items()))
- def main(self):
+ def start(self):
utilapplication.UtilApplication.configFiles = (os.getcwd() + '/tests/ami-monitor/starpy.conf', 'starpy.conf')
# Log into AMI
amiDF = utilapplication.UtilApplication().amiSpecifier.login().addCallbacks(self.onAMIConnect, self.onAMIFailure)
@@ -183,6 +186,25 @@
reactor.stop()
self.log.critical("DEBUG: DONE, end_test")
self.stop_asterisk()
+
+ def next_test(self, count, toexec):
+ print "NEXT TEST YAYA ", count
+
+ if not hasattr(self.testobj, toexec):
+ print "DEBUG: no more tests"
+ return -1
+
+ print "DEBUG: next test exists"
+ if self.testobj.callID:
+ self.testobj.callID.cancel()
+ self.testobj.callID = reactor.callLater(5, self.timeout)
+ method = getattr(self.testobj, toexec)
+ method(self)
+ if len(self.eventList) > 0:
+ return 0
+
+ print "DEBUG: returning, no events..."
+ return -1 # exception or something
def loadNextTest(self, ami, firstrun=None):
if not firstrun:
@@ -201,7 +223,7 @@
self.clear_vars()
toexec = "test" + str(self.testcount)
- res = self.next_test(self, self.testcount, toexec)
+ res = self.next_test(self.testcount, toexec)
print "DEBUG: res %s from exec %s" % (res, toexec)
if res == -1:
self.ami = None
@@ -253,7 +275,7 @@
# [{'event' : 'Alarm', 'channel' : '17' }],
# [{'event' : 'Alarm', 'channel' : '19' }, {'event' : 'Alarm', 'channel' : '20'}]])
- reactor.callWhenRunning(watcher.main)
+ reactor.callWhenRunning(watcher.start)
reactor.callLater(15, watcher.timeout)
reactor.run()
Modified: asterisk/team/jpeeler/event_watcher/tests/ami-monitor/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/jpeeler/event_watcher/tests/ami-monitor/run-test?view=diff&rev=262&r1=261&r2=262
==============================================================================
--- asterisk/team/jpeeler/event_watcher/tests/ami-monitor/run-test (original)
+++ asterisk/team/jpeeler/event_watcher/tests/ami-monitor/run-test Wed Apr 28 18:45:19 2010
@@ -46,35 +46,16 @@
#watcher.add_event(event2)
#watcher.add_event(event3)
#watcher.set_ordered(True)
-
- def next_test(self, watcher, count, toexec):
- print "NEXT TEST YAYA ", count
-
- if not hasattr(self, toexec):
- print "DEBUG: no more tests"
- return -1
-
- print "DEBUG: next test exists"
- if self.callID:
- self.callID.cancel()
- self.callID = reactor.callLater(5, watcher.timeout)
- method = getattr(self, toexec)
- method(watcher)
- if len(watcher.eventList) > 0:
- return 0
-
- print "DEBUG: returning, no events..."
- return -1 # exception or something
-
+
def main(self):
logging.basicConfig()
manager.log.setLevel(logging.DEBUG)
watcher = client.EventWatcher()
watcher.log.setLevel(logging.DEBUG)
- watcher.next_test(self.next_test)
+ watcher.set_test_obj(self)
- reactor.callWhenRunning(watcher.main)
+ reactor.callWhenRunning(watcher.start)
self.callID = reactor.callLater(5, watcher.timeout)
reactor.run()
More information about the asterisk-commits
mailing list