[asterisk-commits] pabelanger: testsuite/asterisk/trunk r1987 - in /asterisk/trunk/tests/cdr/con...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Aug 26 23:14:01 CDT 2011


Author: pabelanger
Date: Fri Aug 26 23:13:57 2011
New Revision: 1987

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=1987
Log:
TestCase class conversion

Added:
    asterisk/trunk/tests/cdr/console_dial_sip_answer/configs/ast1/manager.general.conf.inc
      - copied unchanged from r1986, asterisk/trunk/tests/manager/login/configs/ast1/manager.general.conf.inc
Removed:
    asterisk/trunk/tests/cdr/console_dial_sip_answer/configs/ast1/manager.conf
Modified:
    asterisk/trunk/tests/cdr/console_dial_sip_answer/run-test
    asterisk/trunk/tests/cdr/console_dial_sip_answer/test-config.yaml

Modified: asterisk/trunk/tests/cdr/console_dial_sip_answer/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/console_dial_sip_answer/run-test?view=diff&rev=1987&r1=1986&r2=1987
==============================================================================
--- asterisk/trunk/tests/cdr/console_dial_sip_answer/run-test (original)
+++ asterisk/trunk/tests/cdr/console_dial_sip_answer/run-test Fri Aug 26 23:13:57 2011
@@ -8,80 +8,72 @@
 '''
 
 import sys
-from time import sleep
 import os
+import logging
+import re
 sys.path.append("lib/python")
 from asterisk.asterisk import Asterisk
 from asterisk.cdr import AsteriskCSVCDR, AsteriskCSVCDRLine
-from asterisk.ami import AMI
+from asterisk.TestCase import TestCase
 from twisted.internet import reactor
-import logging
+
 
 workingdir = "cdr/console_dial_sip_answer"
-testdir = "tests/%s" workingdir
+testdir = "tests/%s" % workingdir
 
-class Test:
+class Test(TestCase):
     def __init__(self):
-        self.passed = False
+        TestCase.__init__(self)
+        self.create_asterisk(2)
 
-        self.ast1 = Asterisk(base=workingdir)
-        self.ast1.install_configs("%s/configs/ast1" % (testdir))
+    def ami_connect(self, ami):
+        TestCase.ami_connect(self, ami)
 
-        self.ast2 = Asterisk(base=workingdir)
-        self.ast2.install_configs("%s/configs/ast2" % (testdir))
-
-        self.ast1.start()
-        self.ast2.start()
-
-        reactor.callLater(30, self.stop_reactor)
-
-        self.ami = AMI(self.start, self.stop_reactor, timeout=20)
-        self.ami.login()
-
-    def start(self, ami):
-        ami.registerEvent('Hangup', self.end)
-        self.ast1.cli_exec("console dial 1 at default")
-
-    def stop_asterisk(self):
-        self.ast1.stop()
-        self.ast2.stop()
-
-    def stop_reactor(self):
-        print "Stopping Reactor ..."
-        if reactor.running:
-            reactor.stop()
-        self.stop_asterisk()
+        if ami.id == 0:
+            self.ami[0].registerEvent('Hangup', self.end)
+            self.ami[0].originate(channel = "Local/1 at default", application = "Echo")
 
     def end(self, ami, event):
-        if event.get("channel").lower() != "console/dsp":
+        if not re.match(".*;1$", event['channel']):
             return
         self.stop_reactor()
 
-        cdr1 = AsteriskCSVCDR(fn="%s/var/log/asterisk/cdr-csv/Master.csv" % (self.ast1.base))
-        cdr2 = AsteriskCSVCDR(fn="%s/var/log/asterisk/cdr-csv/Master.csv" % (self.ast2.base))
+    def results(self):
+        cdr1 = AsteriskCSVCDR(fn="%s/var/log/asterisk/cdr-csv/Master.csv" %
+                (self.ast[0].base))
+        cdr2 = AsteriskCSVCDR(fn="%s/var/log/asterisk/cdr-csv/Master.csv" %
+                (self.ast[1].base))
 
         cdr1_expect = AsteriskCSVCDR(records=[AsteriskCSVCDRLine(accountcode="",
             source="", destination="1", dcontext="default", callerid="",
-            channel="Console/dsp", dchannel="SIP/test-00000000", lastapp="Dial",
+            channel="Local/1 at default-.*", dchannel="SIP/test-00000000", lastapp="Dial",
             lastarg="SIP/1 at test", disposition="ANSWERED",
             amaflags="DOCUMENTATION")])
         cdr2_expect = AsteriskCSVCDR(records=[AsteriskCSVCDRLine(accountcode="",
-            source="asterisk", destination="1", dcontext="default",
-            callerid='"asterisk" <asterisk>', channel="SIP/.*5065-.*",
+            source="Anonymous", destination="1", dcontext="default",
+            callerid='"Anonymous" <Anonymous>', channel="SIP/anonymous.invalid:5065-.*",
             dchannel="", lastapp="Hangup", lastarg="", disposition="ANSWERED",
             amaflags="DOCUMENTATION")])
 
-        if cdr1_expect.match(cdr1) and cdr2_expect.match(cdr2):
+        if cdr1_expect[0].match(cdr1[0]) and cdr2_expect.match(cdr2):
             print "Success"
             self.passed = True
         else:
             print "Failure"
 
+    def run(self):
+        TestCase.run(self)
+        self.create_ami_factory()
+
 def main():
-    logging.basicConfig()
     test = Test()
+    test.start_asterisk()
     reactor.run()
+    test.stop_asterisk()
+    test.results()
     return not test.passed
 
 if __name__ == '__main__':
     sys.exit(main())
+
+# vim:sw=4:ts=4:expandtab:textwidth=79

Modified: asterisk/trunk/tests/cdr/console_dial_sip_answer/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/cdr/console_dial_sip_answer/test-config.yaml?view=diff&rev=1987&r1=1986&r2=1987
==============================================================================
--- asterisk/trunk/tests/cdr/console_dial_sip_answer/test-config.yaml (original)
+++ asterisk/trunk/tests/cdr/console_dial_sip_answer/test-config.yaml Fri Aug 26 23:13:57 2011
@@ -9,4 +9,3 @@
     dependencies:
         - python : 'twisted'
         - python : 'starpy'
-        - custom : 'soundcard'




More information about the asterisk-commits mailing list