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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Dec 8 12:44:35 CST 2010


Author: pabelanger
Date: Wed Dec  8 12:44:31 2010
New Revision: 1108

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=1108
Log:
First version of AsteriskTest class

Added:
    asterisk/team/pabelanger/testClass/lib/python/asterisk/AsteriskTest.py   (with props)
Modified:
    asterisk/team/pabelanger/testClass/tests/manager/login/run-test

Added: asterisk/team/pabelanger/testClass/lib/python/asterisk/AsteriskTest.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/testClass/lib/python/asterisk/AsteriskTest.py?view=auto&rev=1108
==============================================================================
--- asterisk/team/pabelanger/testClass/lib/python/asterisk/AsteriskTest.py (added)
+++ asterisk/team/pabelanger/testClass/lib/python/asterisk/AsteriskTest.py Wed Dec  8 12:44:31 2010
@@ -1,0 +1,38 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2010, Digium, Inc.
+Paul Belanger <pabelanger at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+
+import sys
+
+from asterisk import Asterisk
+
+class AsteriskTest(object):
+    __asterisk_class = []
+    base_dir = ""
+    test_dir = ""
+
+    def create_asterisk(self, count=1):
+        for c in range(count):
+            print "Creating Asterisk instance %d..." % (c + 1)
+            self.__asterisk_class.append(Asterisk(base=self.base_dir))
+            # Copy shared config files
+            self.__asterisk_class[c].install_configs("%s/configs" % (self.test_dir))
+            # Copy test specific config files
+            self.__asterisk_class[c].install_configs("%s/configs/ast%d" %
+                    (self.test_dir, c + 1))
+
+    def start_asterisk(self):
+        for index, item in enumerate(self.__asterisk_class):
+            print "Starting Asterisk instance %d..." % (index + 1)
+            self.__asterisk_class[index].start()
+
+    def stop_asterisk(self):
+        for index, item in enumerate(self.__asterisk_class):
+            print "Stopping Asterisk instance %d..." % (index + 1)
+            self.__asterisk_class[index].stop()
+

Propchange: asterisk/team/pabelanger/testClass/lib/python/asterisk/AsteriskTest.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/team/pabelanger/testClass/lib/python/asterisk/AsteriskTest.py
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/team/pabelanger/testClass/lib/python/asterisk/AsteriskTest.py
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: asterisk/team/pabelanger/testClass/tests/manager/login/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/pabelanger/testClass/tests/manager/login/run-test?view=diff&rev=1108&r1=1107&r2=1108
==============================================================================
--- asterisk/team/pabelanger/testClass/tests/manager/login/run-test (original)
+++ asterisk/team/pabelanger/testClass/tests/manager/login/run-test Wed Dec  8 12:44:31 2010
@@ -17,34 +17,28 @@
 
 sys.path.append("lib/python")
 from asterisk.asterisk import Asterisk
+from asterisk.AsteriskTest import AsteriskTest
 
 workingdir = "/tmp/asterisk-testsuite/manager/login"
 testdir = "tests/manager/login"
 
-
-class AMILoginTest:
+class AMILoginTest(AsteriskTest):
     def __init__(self):
+        AsteriskTest.__init__(self)
+        self.base_dir = workingdir
+        self.test_dir = testdir
         self.passed = False
         self.last_step = ""
         self.ami = None
 
         reactor.callWhenRunning(self.run)
 
-        print "Creating Asterisk instance ..."
-        self.ast1 = Asterisk(base=workingdir)
-        self.ast1.install_configs("%s/configs/ast1" % (testdir))
+        self.create_asterisk()
 
     def stop_reactor(self):
         print "Stopping Reactor ..."
         if reactor.running:
             reactor.stop()
-
-    def start_asterisk(self):
-        self.log_last_step("Starting Asterisk")
-        self.ast1.start()
-
-    def stop_asterisk(self):
-        self.ast1.stop()
 
     def log_last_step(self, step):
         print step
@@ -66,8 +60,6 @@
         self.log_last_step("Logging off")
 
     def run(self):
-        self.start_asterisk()
-
         # A timeout in case things hang and fail
         reactor.callLater(20, self.stop_reactor)
 
@@ -76,9 +68,9 @@
         self.ami_factory.login('127.0.0.1', 5038).addCallbacks(self.on_connect,
                                                                self.on_error)
 
-
 def main():
     test = AMILoginTest()
+    test.start_asterisk()
     reactor.run()
     test.stop_asterisk()
     if test.passed:




More information about the asterisk-commits mailing list