[asterisk-commits] pabelanger: branch pabelanger/testClass r1513 - in /asterisk/team/pabelanger/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue May 17 18:35:37 CDT 2011


Author: pabelanger
Date: Tue May 17 18:35:34 2011
New Revision: 1513

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=1513
Log:
Another test converted

Added:
    asterisk/team/pabelanger/testClass/tests/fastagi/database/configs/
      - copied from r1509, asterisk/team/pabelanger/testClass/tests/fastagi/connect/configs/
    asterisk/team/pabelanger/testClass/tests/fastagi/database/configs/ast1/manager.general.conf.inc
      - copied unchanged from r1510, asterisk/team/pabelanger/testClass/tests/fastagi/connect/configs/ast1/manager.general.conf.inc
Removed:
    asterisk/team/pabelanger/testClass/tests/fastagi/database/configs/ast1/manager.conf
Modified:
    asterisk/team/pabelanger/testClass/tests/fastagi/database/run-test

Modified: asterisk/team/pabelanger/testClass/tests/fastagi/database/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/testClass/tests/fastagi/database/run-test?view=diff&rev=1513&r1=1512&r2=1513
==============================================================================
--- asterisk/team/pabelanger/testClass/tests/fastagi/database/run-test (original)
+++ asterisk/team/pabelanger/testClass/tests/fastagi/database/run-test Tue May 17 18:35:34 2011
@@ -8,40 +8,22 @@
 '''
 
 import sys
-import os
-from optparse import OptionParser
 from twisted.internet import reactor
-from starpy import fastagi
 
 sys.path.append("lib/python")
 from asterisk.asterisk import Asterisk
-from asterisk.version import AsteriskVersion
-
-workingdir = "/tmp/asterisk-testsuite/fastagi/database"
-testdir = "tests/fastagi"
+from asterisk.TestCase import TestCase
 
 
-class FastAGIDatabaseTest:
+class FastAGIDatabaseTest(TestCase):
     def __init__(self, argv):
+        TestCase.__init__(self, argv)
         self.passed = {}
-        self.timeout = 30
         self.key = "fastagitest"
         self.overall_result = True
-        self.agi = ""
 
-        parser = OptionParser()
-        parser.add_option("-v", "--version", dest="ast_version",
-                          help="Asterisk version string")
-        (options, args) = parser.parse_args(argv)
-        self.ast_version = AsteriskVersion(options.ast_version)
-
-        # Listen for results from dialplan
-        self.agi_factory = fastagi.FastAGIFactory(self.do_test)
-        reactor.listenTCP(4573, self.agi_factory, self.timeout, '127.0.0.1')
-        reactor.callWhenRunning(self.run)
-
-        self.ast1 = Asterisk(base=workingdir)
-        self.ast1.install_configs("%s/configs/ast1" % (testdir))
+        self.create_asterisk()
+        self.create_fastagi_factory()
 
     def on_del_failure(self, reason):
         print 'Could not delete the data from the database.'
@@ -158,53 +140,30 @@
     # 4. Test for new value
     # 5. Delete that key from the database
     # 6. Test that key was deleted.
-    def do_test(self, agi):
+    def fastagi_connect(self, agi):
         self.agi = agi
         print "Inserting key into database."
         return agi.databaseSet("secret", self.key, "juststarted").addCallback(
             self.get_result_from_put).addErrback(self.on_put_failure)
 
-	# Read test results and dialplan globals
-    def read_result(self):
-        self.agi.finish()
-        self.stop_reactor()
-
-        for test in self.passed:
-            if self.passed[test] is False:
-                self.overall_result = False
-
-        if self.overall_result is True:
-            print "Success"
-	else:
-            print "Failed"
-
-    def stop_reactor(self):
-        print "Stopping Reactor ..."
-        if reactor.running:
-            reactor.stop()
 
     def launch_test(self):
         print "Originating call to begin test."
-        self.ast1.cli_originate("Local/506 at agitest extension echo at agitest")
-
-    def start_asterisk(self):
-        print "Starting Asterisk"
-        self.ast1.start()
-
-    def stop_asterisk(self):
-        print "Stopping Asterisk"
-        self.ast1.stop()
+        self.ast[0].cli_originate("Local/506 at agitest extension echo at agitest")
 
     # Read result before timeout
     def result_changed(self):
         # if self.passed["Put"] is None, not one test has completed yet
         # and we should wait for the timeout.
         if self.passed["Put"] is not None:
-            self.read_result()
+            self.stop_reactor()
+            for test in self.passed:
+                if self.passed[test] is False:
+                    self.overall_result = False
 
     def run(self):
+        TestCase.run(self)
         self.launch_test()
-        reactor.callLater(self.timeout, self.stop_reactor)
 
 
 def main(argv=None):




More information about the asterisk-commits mailing list