[asterisk-commits] mjordan: branch mjordan/python_logging_082811 r1994 - in /asterisk/team/mjord...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sun Aug 28 16:19:05 CDT 2011
Author: mjordan
Date: Sun Aug 28 16:18:58 2011
New Revision: 1994
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=1994
Log:
Added - should be ready per review 1382
Added:
asterisk/team/mjordan/python_logging_082811/ (props changed)
- copied from r1993, asterisk/trunk/
asterisk/team/mjordan/python_logging_082811/logger.conf (with props)
asterisk/team/mjordan/python_logging_082811/logs/
Modified:
asterisk/team/mjordan/python_logging_082811/asttest/asttest.c
asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/TestCase.py
asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/ami.py
asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/asterisk.py
asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/cdr.py
asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/config.py
asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/sipp.py
asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/version.py
asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/voicemail.py
asterisk/team/mjordan/python_logging_082811/lib/python/client.py
asterisk/team/mjordan/python_logging_082811/runtests.py
asterisk/team/mjordan/python_logging_082811/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/extensions.conf
asterisk/team/mjordan/python_logging_082811/tests/apps/voicemail/leave_voicemail_nominal/run-test
asterisk/team/mjordan/python_logging_082811/tests/apps/voicemail/tests.yaml
Propchange: asterisk/team/mjordan/python_logging_082811/
------------------------------------------------------------------------------
reviewboard:url = https://reviewboard.asterisk.org
Propchange: asterisk/team/mjordan/python_logging_082811/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Aug 28 16:18:58 2011
@@ -1,0 +1,2 @@
+asterisk-test-suite-report.xml
+*.pyc
Propchange: asterisk/team/mjordan/python_logging_082811/
------------------------------------------------------------------------------
svn:mergeinfo = /asterisk/trunk:1112
Modified: asterisk/team/mjordan/python_logging_082811/asttest/asttest.c
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/python_logging_082811/asttest/asttest.c?view=diff&rev=1994&r1=1993&r2=1994
==============================================================================
--- asterisk/team/mjordan/python_logging_082811/asttest/asttest.c (original)
+++ asterisk/team/mjordan/python_logging_082811/asttest/asttest.c Sun Aug 28 16:18:58 2011
@@ -82,7 +82,7 @@
opts->asterisk_path = "asterisk";
/* parse options */
- while ((c = getopt(argc, argv, "l:a:s:v:n:wh")) != -1) {
+ while ((c = getopt(argc, argv, "l:a:s:v:wh")) != -1) {
switch (c) {
case 'l':
opts->log_filename = optarg;
Modified: asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/TestCase.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/TestCase.py?view=diff&rev=1994&r1=1993&r2=1994
==============================================================================
--- asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/TestCase.py (original)
+++ asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/TestCase.py Sun Aug 28 16:18:58 2011
@@ -8,14 +8,14 @@
'''
import sys
-import logging
+import logging, logging.config
import os
from twisted.internet import reactor
from starpy import manager, fastagi
from asterisk import Asterisk
-log = logging.getLogger('TestCase')
+logger = logging.getLogger(__name__)
class TestCase(object):
ast = []
@@ -23,11 +23,24 @@
fastagi = []
reactor_timeout = 30
passed = False
+ defaultLogLevel = "WARN"
+ defaultLogFileName = "logger.conf"
def __init__(self):
self.test_name = os.path.dirname(sys.argv[0])
self.base = self.test_name.lstrip("tests/")
+ self.testStateController = None
+
+ """ Set up logging """
+ logConfigFile = os.path.join(os.getcwd(), "%s" % (self.defaultLogFileName))
+ if os.path.exists(logConfigFile):
+ logging.config.fileConfig(logConfigFile, None, False)
+ else:
+ print "WARNING: no logging.conf file found; using default configuration"
+ logging.basicConfig(level=self.defaultLogLevel)
+
+ logger.info("Executing " + self.test_name + "...")
reactor.callWhenRunning(self.run)
def create_asterisk(self, count=1):
@@ -38,7 +51,7 @@
"""
for c in range(count):
- print "Creating Asterisk instance %d ..." % (c + 1)
+ logger.info("Creating Asterisk instance %d ..." % (c + 1))
self.ast.append(Asterisk(base=self.base))
# Copy shared config files
self.ast[c].install_configs("%s/configs" %
@@ -60,7 +73,7 @@
for c in range(count):
host = "127.0.0.%d" % (c + 1)
self.ami.append(None)
- print "Creating AMIFactory %d ..." % (c + 1)
+ logger.info( "Creating AMIFactory %d ..." % (c + 1))
self.ami_factory = manager.AMIFactory(username, secret, c)
self.ami_factory.login(host).addCallbacks(self.ami_connect,
self.ami_login_error)
@@ -70,7 +83,7 @@
for c in range(count):
host = "127.0.0.%d" % (c + 1)
self.fastagi.append(None)
- print "Creating FastAGI Factory %d ..." % (c + 1)
+ logger.info( "Creating FastAGI Factory %d ..." % (c + 1))
self.fastagi_factory = fastagi.FastAGIFactory(self.fastagi_connect)
reactor.listenTCP(4573, self.fastagi_factory,
self.reactor_timeout, host)
@@ -80,7 +93,7 @@
"""
for index, item in enumerate(self.ast):
- print "Starting Asterisk instance %d ..." % (index + 1)
+ logger.info( "Starting Asterisk instance %d ..." % (index + 1))
self.ast[index].start()
def stop_asterisk(self):
@@ -88,14 +101,14 @@
"""
for index, item in enumerate(self.ast):
- print "Stopping Asterisk instance %d ..." % (index + 1)
+ logger.info( "Stopping Asterisk instance %d ..." % (index + 1))
self.ast[index].stop()
def stop_reactor(self):
"""
"""
- print "Stopping Reactor ..."
+ logger.info( "Stopping Reactor ...")
if reactor.running:
reactor.stop()
@@ -106,10 +119,10 @@
reactor.callLater(self.reactor_timeout, self.stop_reactor)
def ami_login_error(self, ami):
- print "Error logging into AMI"
+ logger.error( "Error logging into AMI")
self.stop_reactor()
def ami_connect(self, ami):
- print "AMI Connect instance %s ..." % (ami.id + 1)
+ logger.info( "AMI Connect instance %s ..." % (ami.id + 1))
self.ami[ami.id] = ami
Modified: asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/ami.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/ami.py?view=diff&rev=1994&r1=1993&r2=1994
==============================================================================
--- asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/ami.py (original)
+++ asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/ami.py Sun Aug 28 16:18:58 2011
@@ -2,6 +2,9 @@
from starpy import manager
import datetime
import sys
+import logging
+
+logger = logging.getLogger(__name__)
class AMI:
def __init__(self, on_login, on_error, timeout=60, user="mark", secret="mysecret", host="127.0.0.1", port=5038):
@@ -18,20 +21,20 @@
def login(self):
self.__attempts = self.__attempts + 1
- print "AMI Login attempt #%d" % (self.__attempts)
+ logger.debug("AMI Login attempt #%d" % (self.__attempts))
if not self.__start:
self.__start = datetime.datetime.now()
self.ami_factory.login(self.host, self.port).addCallbacks(self.on_login_success, self.on_login_error)
def on_login_success(self, ami):
self.ami = ami
- print "AMI Login succesful"
+ logger.debug("AMI Login succesful")
return self.on_login(ami)
def on_login_error(self, reason):
runtime = (datetime.datetime.now() - self.__start).seconds
if runtime >= self.login_timeout:
- print "AMI login failed after %d second timeout" % (self.login_timeout)
+ logger.error("AMI login failed after %d second timeout" % (self.login_timeout))
return self.on_error()
delay = 2 ** self.__attempts
if delay + runtime >= self.login_timeout:
Modified: asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/asterisk.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/asterisk.py?view=diff&rev=1994&r1=1993&r2=1994
==============================================================================
--- asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/asterisk.py (original)
+++ asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/asterisk.py Sun Aug 28 16:18:58 2011
@@ -18,10 +18,12 @@
import shutil
import subprocess
import utils
+import logging
from config import ConfigFile
from version import AsteriskVersion
+logger = logging.getLogger(__name__)
class Asterisk:
"""An instance of Asterisk.
@@ -77,7 +79,7 @@
ast_conf = ConfigFile(c)
break
if ast_conf is None:
- print "No asterisk.conf found on the system!"
+ logger.error("No asterisk.conf found on the system!")
return
if base is not None:
@@ -97,7 +99,7 @@
if c.name == "directories":
dir_cat = c
if dir_cat is None:
- print "Unable to discover dir layout from asterisk.conf"
+ logger.error("Unable to discover dir layout from asterisk.conf")
return
self.__gen_ast_conf(ast_conf, dir_cat, ast_conf_options)
for (var, val) in dir_cat.options:
@@ -121,7 +123,7 @@
try:
self.process = subprocess.Popen(cmd)
except OSError:
- print "Failed to execute command: %s" % str(cmd)
+ logger.error("Failed to execute command: %s" % str(cmd))
return False
# Be _really_ sure that Asterisk has started up before returning.
@@ -232,7 +234,7 @@
asterisk.install_config("tests/my-cool-test/configs/manager.conf")
"""
if not os.path.exists(cfg_path):
- print "Config file '%s' does not exist" % cfg_path
+ logger.error("Config file '%s' does not exist" % cfg_path)
return
tmp = "%s/%s/%s" % (os.path.dirname(cfg_path), self.ast_version.branch, os.path.basename(cfg_path))
@@ -244,9 +246,9 @@
try:
shutil.copyfile(cfg_path, target_path)
except shutil.Error:
- print "'%s' and '%s' are the same file" % (cfg_path, target_path)
+ logger.warn("'%s' and '%s' are the same file" % (cfg_path, target_path))
except IOError:
- print "The destination is not writable '%s'" % target_path
+ logger.warn("The destination is not writable '%s'" % target_path)
def cli_originate(self, argstr, blocking=True):
"""Starts a call from the CLI and links it to an application or
@@ -272,13 +274,13 @@
raise_error = False
if len(args) != 3 and len(args) != 4:
raise_error = True
- print "Wrong number of arguments."
+ logger.error("Wrong number of arguments.")
if args[1] != "extension" and args[1] != "application":
raise_error = True
- print '2nd argument must be "extension" or "application"'
+ logger.error('2nd argument must be "extension" or "application"')
if args[0].find("/") == -1:
raise_error = True
- print 'Channel dial string must be in the form "tech/data".'
+ logger.error('Channel dial string must be in the form "tech/data".')
if raise_error is True:
raise Exception, "Cannot originate call!\n\
Argument string must be in one of these forms:\n\
@@ -306,7 +308,7 @@
"-C", "%s" % os.path.join(self.astetcdir, "asterisk.conf"),
"-rx", "%s" % cli_cmd
]
- print "Executing %s ..." % cmd
+ logger.debug("Executing %s ..." % cmd)
if not blocking:
process = subprocess.Popen(cmd)
@@ -316,13 +318,13 @@
process = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
except OSError:
- print "Failed to execute command: %s" % str(cmd)
+ logger.warn("Failed to execute command: %s" % str(cmd))
return ""
output = ""
try:
for l in process.stdout.readlines():
- print l,
+ logger.debug(l),
output += l
except IOError:
pass
@@ -343,10 +345,10 @@
try:
f = open(local_ast_conf_path, "w")
except IOError:
- print "Failed to open %s" % local_ast_conf_path
+ logger.error("Failed to open %s" % local_ast_conf_path)
return
except:
- print "Unexpected error: %s" % sys.exc_info()[0]
+ logger.error("Unexpected error: %s" % sys.exc_info()[0])
return
for c in ast_conf.categories:
Modified: asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/cdr.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/cdr.py?view=diff&rev=1994&r1=1993&r2=1994
==============================================================================
--- asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/cdr.py (original)
+++ asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/cdr.py Sun Aug 28 16:18:58 2011
@@ -14,6 +14,9 @@
import sys
import csv
import re
+import logging
+
+logger = logging.getLogger(__name__)
class AsteriskCSVCDRLine:
"A single Asterisk call detail record"
@@ -46,8 +49,8 @@
for k,v in self.iteritems():
if None not in (v, other.get(k)) and not re.match(
"%s$" % (str(v).lower()), str(other.get(k)).lower()):
- print "CDR MATCH FAILED, Expected: %s:%s Got: %s:%s" % (k, v,
- k, other.get(k))
+ logger.warn("CDR MATCH FAILED, Expected: %s:%s Got: %s:%s" % (k, v,
+ k, other.get(k)))
return False
return True
@@ -86,10 +89,10 @@
try:
cdr = csv.DictReader(open(fn, "r"), AsteriskCSVCDRLine.get_fields(), ",")
except IOError:
- print "Failed to open CDR file '%s'" % (fn)
+ logger.error("Failed to open CDR file '%s'" % (fn))
return
except:
- print "Unexpected error: %s" % (sys.exc_info()[0])
+ logger.error("Unexpected error: %s" % (sys.exc_info()[0]))
return
for r in cdr:
@@ -110,7 +113,7 @@
each record"""
if len(self) != len(other):
- print "CDR MATCH FAILED, different number of records"
+ logger.warn("CDR MATCH FAILED, different number of records")
return False
for i,x in enumerate(self):
if not x.match(other[i]):
@@ -124,7 +127,7 @@
try:
open(self.filename, "w").close()
except:
- print "Unable to empty CDR file %s" % (self.filename)
+ logger.warn("Unable to empty CDR file %s" % (self.filename))
class AsteriskCSVCDRTests(unittest.TestCase):
Modified: asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/config.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/config.py?view=diff&rev=1994&r1=1993&r2=1994
==============================================================================
--- asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/config.py (original)
+++ asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/config.py Sun Aug 28 16:18:58 2011
@@ -19,7 +19,9 @@
import sys
import re
import unittest
+import logging
+logger = logging.getLogger(__name__)
def is_blank_line(line):
return re.match("\s*(?:;.*)?$", line) is not None
@@ -49,7 +51,7 @@
match = self.varval_re.match(line)
if match is None:
if not is_blank_line(line):
- print "Invalid line: '%s'" % line.strip()
+ logger.warn("Invalid line: '%s'" % line.strip())
return
self.options.append((match.group("name"), match.group("value").strip()))
@@ -80,10 +82,10 @@
config_str = f.read()
f.close()
except IOError:
- print "Failed to open config file '%s'" % fn
+ logger.error("Failed to open config file '%s'" % fn)
return
except:
- print "Unexpected error: %s" % sys.exc_info()[0]
+ logger.error("Unexpected error: %s" % sys.exc_info()[0])
return
config_str = self.strip_mline_comments(config_str)
@@ -103,7 +105,7 @@
)
elif len(self.categories) == 0:
if not is_blank_line(line):
- print "Invalid line: '%s'" % line.strip()
+ logger.warn("Invalid line: '%s'" % line.strip())
else:
self.categories[-1].parse_line(line)
@@ -178,9 +180,9 @@
if len(argv) == 2:
conf = ConfigFile(argv[1])
for c in conf.categories:
- print "[%s]" % c.name
+ logger.debug("[%s]" % c.name)
for (var, val) in c.options:
- print "%s = %s" % (var, val)
+ logger.debug("%s = %s" % (var, val))
else:
return unittest.main()
Modified: asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/sipp.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/sipp.py?view=diff&rev=1994&r1=1993&r2=1994
==============================================================================
--- asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/sipp.py (original)
+++ asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/sipp.py Sun Aug 28 16:18:58 2011
@@ -13,9 +13,11 @@
import sys
import os
import subprocess
+import logging
from asterisk import Asterisk
+logger = logging.getLogger(__name__)
class SIPpTest:
"""
@@ -90,8 +92,8 @@
for (key, val) in default_args.items():
sipp_args.extend([ key, val ])
- print "Executing SIPp scenario: %s" % scenario['scenario']
- print sipp_args
+ logger.debug("Executing SIPp scenario: %s" % scenario['scenario'])
+ logger.debug(sipp_args)
return subprocess.Popen(sipp_args,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@@ -115,13 +117,13 @@
self.stderr.append(err)
self.result.append(self.sipp[i].wait())
if self.result[i]:
- print "SIPp scenario #%d FAILED" % i
+ logger.warn("SIPp scenario #%d FAILED" % i)
else:
- print "SIPp scenario #%d PASSED" % i
+ logger.info("SIPp scenario #%d PASSED" % i)
if self.result[i]:
passed = False
#print self.stdout[i]
- print self.stderr[i]
+ logger.warn(self.stderr[i])
self.ast1.stop()
Modified: asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/version.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/version.py?view=diff&rev=1994&r1=1993&r2=1994
==============================================================================
--- asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/version.py (original)
+++ asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/version.py Sun Aug 28 16:18:58 2011
@@ -14,6 +14,9 @@
import sys
import re
import unittest
+import logging
+
+logger = logging.getLogger(__name__)
class AsteriskVersion:
"""An Asterisk Version.
@@ -146,10 +149,10 @@
v = match.group(1)
f.close()
except IOError:
- print "I/O Error getting Asterisk version from %s" % path
+ logger.error("I/O Error getting Asterisk version from %s" % path)
except:
- print "Unexpected error getting version from %s: %s" % (path,
- sys.exc_info()[0])
+ logger.error("Unexpected error getting version from %s: %s" % (path,
+ sys.exc_info()[0]))
return v
Modified: asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/voicemail.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/voicemail.py?view=diff&rev=1994&r1=1993&r2=1994
==============================================================================
--- asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/voicemail.py (original)
+++ asterisk/team/mjordan/python_logging_082811/lib/python/asterisk/voicemail.py Sun Aug 28 16:18:58 2011
@@ -12,12 +12,21 @@
import os
import glob
import shutil
-
+import datetime
+import logging
+
+from datetime import datetime
from asterisk import Asterisk
from config import Category
from config import ConfigFile
+from TestCase import TestCase
+from TestState import TestState
+from TestState import TestStateController
sys.path.append("lib/python")
+
+logger = logging.getLogger(__name__)
+
"""
Class that manages creation of, verification of, and teardown of Asterisk mailboxes on the local filesystem
@@ -71,7 +80,7 @@
def __init__(self, ast):
self.__ast = ast
self.voicemailDirectory = self.__ast.directories['astspooldir'] + '/voicemail'
-
+ logger = logging.getLogger("TestCase.VoiceMailMailboxManagement")
"""
Creates the basic set of folders needed for a mailbox on the file system
@@ -116,7 +125,7 @@
except IOError as e:
if e.errno == errno.EACCESS:
- print "You do not have sufficient permissions to perform the necessary directory manipulations"
+ logger.error( "You do not have sufficient permissions to perform the necessary directory manipulations")
return False
return True
@@ -154,14 +163,15 @@
f.write('rdnis=unknown\n')
f.write('priority=2\n')
f.write('callerchan=SIP/ast1-00000000\n')
- f.write('callerid=\"Anonymous\"<ast1>\n')
+ f.write('callerid=\"Anonymous\"<555-5555>\n')
f.write('origdate=Tue Aug 9 10:05:13 PM UTC 2011\n')
f.write('origtime=1312927513\n')
if (folder == self.urgentFolderName):
f.write('flag=Urgent\n')
else:
f.write('flag=\n')
- f.write('duration=1\n')
+ f.write('category=tt-monkeys\n')
+ f.write('duration=6\n')
f.close()
for format in formats:
@@ -215,6 +225,24 @@
"""
fileName = msgName + ".txt"
retVal = retVal & self.checkVoiceFileExists(context, mailbox, fileName, folder)
+
+ return retVal
+
+ """
+ Check if a voicemail greeting exists on the filesystem
+ context The context of the mailbox
+ mailbox The mailbox
+ msgname The name of the greeting to find
+ lstFormats The formats we expect to be recorded for us
+
+ true if the greeting exists, false otherwise
+ """
+ def checkGreetingExists(self, context, mailbox, msgname, lstFormats):
+ retVal = True
+
+ for format in lstFormats:
+ fileName = msgname + "." + format
+ retVal = retVal & self.checkVoiceFileExists(context, mailbox, fileName, "")
return retVal
@@ -248,6 +276,53 @@
return False
"""
+ An object that holds voicemail user information
+ """
+ class UserObject(object):
+ def __init__(self):
+ self.password = ""
+ self.fullname = ""
+ self.emailaddress = ""
+ self.pageraddress = ""
+
+ """
+ Gets user information from the voicemail configuration file
+
+ context The context of the mailbox
+ mailbox The mailbox
+ sourceFile The file containing the user information to pull from. Defaults
+ to voicemail.conf
+
+ returns A VoiceMailMailboxManagement.UserObject object, populated with the user's values,
+ or an empty object
+ """
+ def getUserObject(self, context, mailbox, sourceFile="voicemail.conf"):
+
+ filePath = self.__ast.baseDirectory + self.__ast.directories['astetcdir'] + "/" + sourceFile
+
+ configFile = ConfigFile(filePath)
+ userObject = VoiceMailMailboxManagement.UserObject()
+ for cat in configFile.categories:
+ if cat.name == context:
+ for kvp in cat.options:
+ if kvp[0] == mailbox:
+ tokens = kvp[1].split(',')
+ i = 0
+ for token in tokens:
+ if i == 0:
+ userObject.password = token
+ elif i == 1:
+ userObject.fullname = token
+ elif i == 2:
+ userObject.emailaddress = token
+ elif i == 3:
+ userObject.pageraddress = token
+ i += 1
+ return userObject
+
+ return userObject
+
+ """
Checks if a file exists under the voicemail file structure
context The context of the mailbox
mailbox The mailbox
@@ -266,7 +341,6 @@
return True
else:
return False
-
def __removeItemsFromFolder__(self, mailboxPath, folder):
folderPath = os.path.join(self.__ast.baseDirectory, "%(mp)s/%(f)s" % {'mp':mailboxPath, 'f':folder})
Modified: asterisk/team/mjordan/python_logging_082811/lib/python/client.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/python_logging_082811/lib/python/client.py?view=diff&rev=1994&r1=1993&r2=1994
==============================================================================
--- asterisk/team/mjordan/python_logging_082811/lib/python/client.py (original)
+++ asterisk/team/mjordan/python_logging_082811/lib/python/client.py Sun Aug 28 16:18:58 2011
@@ -106,8 +106,7 @@
self.ordered = False
def __init__(self, myargv, myasterisk, mytester, mytimeout = 5):
- self.log = logging.getLogger('TestAMI')
- self.log.setLevel(logging.INFO)
+ self.log = logging.getLogger(__name__)
self.ami = None
self.testcount = 0
self.passed = True
Added: asterisk/team/mjordan/python_logging_082811/logger.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/python_logging_082811/logger.conf?view=auto&rev=1994
==============================================================================
--- asterisk/team/mjordan/python_logging_082811/logger.conf (added)
+++ asterisk/team/mjordan/python_logging_082811/logger.conf Sun Aug 28 16:18:58 2011
@@ -1,0 +1,59 @@
+#
+# Logger configuration for python tests
+#
+
+[loggers]
+keys=root,AMI,asterisk,TestCase
+
+[handlers]
+keys=stdout,normalFile,verboseFile
+
+[formatters]
+keys=default
+
+# Logger definitions. If additional logging handlers are desired,
+# they can be configured below this section.
+[logger_root]
+level=NOTSET
+handlers=stdout,normalFile,verboseFile
+
+[logger_AMI]
+level=NOTSET
+propagate=0
+handlers=stdout,normalFile,verboseFile
+qualname=AMI
+
+[logger_asterisk]
+level=NOTSET
+propagate=0
+handlers=stdout,normalFile,verboseFile
+qualname=asterisk
+
+[logger_TestCase]
+level=NOTSET
+propagate=0
+handlers=stdout,normalFile,verboseFile
+qualname=asterisk.TestCase
+
+[handler_stdout]
+class=StreamHandler
+level=WARN
+formatter=default
+args=(sys.stdout,)
+
+[handler_normalFile]
+class=handlers.RotatingFileHandler
+level=INFO
+formatter=default
+args=('./logs/messages.log', 'a', 67108864, 5)
+
+[handler_verboseFile]
+class=handlers.RotatingFileHandler
+level=DEBUG
+formatter=default
+args=('./logs/full.log', 'a', 67108864, 10)
+
+# Formatter definitions for handlers defined in this configuration file
+[formatter_default]
+format='%(levelname)s %(asctime)s %(name)s::%(funcName)s[%(lineno)d]: %(message)s'
+class=logging.Formatter
Propchange: asterisk/team/mjordan/python_logging_082811/logger.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: asterisk/team/mjordan/python_logging_082811/logger.conf
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: asterisk/team/mjordan/python_logging_082811/logger.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: asterisk/team/mjordan/python_logging_082811/runtests.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/python_logging_082811/runtests.py?view=diff&rev=1994&r1=1993&r2=1994
==============================================================================
--- asterisk/team/mjordan/python_logging_082811/runtests.py (original)
+++ asterisk/team/mjordan/python_logging_082811/runtests.py Sun Aug 28 16:18:58 2011
@@ -158,23 +158,17 @@
cmd = [
"%s/run-test" % self.test_name,
]
+
if os.path.exists(cmd[0]) and os.access(cmd[0], os.X_OK):
print "Running %s ..." % cmd
- try:
- f = open("%s/test-output.txt" % self.test_name, "w")
- except IOError:
- print "FAILURE: Failed to open file for test output"
- return
p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
try:
for l in p.stdout.readlines():
- f.write(l)
print l,
except IOError:
pass
p.wait()
- f.close()
self.passed = (p.returncode == 0 and self.expectPass) or (p.returncode and not self.expectPass)
else:
Modified: asterisk/team/mjordan/python_logging_082811/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/python_logging_082811/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/extensions.conf?view=diff&rev=1994&r1=1993&r2=1994
==============================================================================
--- asterisk/team/mjordan/python_logging_082811/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/extensions.conf (original)
+++ asterisk/team/mjordan/python_logging_082811/tests/apps/voicemail/leave_voicemail_nominal/configs/ast2/extensions.conf Sun Aug 28 16:18:58 2011
@@ -29,4 +29,3 @@
same => n,SendDTMF(#)
same => n,Wait(1)
same => n,Hangup()
-
Modified: asterisk/team/mjordan/python_logging_082811/tests/apps/voicemail/leave_voicemail_nominal/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/python_logging_082811/tests/apps/voicemail/leave_voicemail_nominal/run-test?view=diff&rev=1994&r1=1993&r2=1994
==============================================================================
--- asterisk/team/mjordan/python_logging_082811/tests/apps/voicemail/leave_voicemail_nominal/run-test (original)
+++ asterisk/team/mjordan/python_logging_082811/tests/apps/voicemail/leave_voicemail_nominal/run-test Sun Aug 28 16:18:58 2011
@@ -11,6 +11,7 @@
import sys
import os
import datetime
+import logging
from datetime import datetime
from twisted.internet import reactor
@@ -22,6 +23,7 @@
from asterisk.TestCase import TestCase
from asterisk.voicemail import VoiceMailMailboxManagement
+logger = logging.getLogger(__name__)
class LeaveVoicemailNominal(TestCase):
@@ -35,7 +37,7 @@
self.create_asterisk(2)
def ami_connect(self, ami):
- print str(datetime.now()) + " Got AMI Connect for instance " + str(ami.id)
+ logger.info("Got AMI Connect for instance " + str(ami.id))
TestCase.ami_connect(self, ami)
self.audioFile = os.path.join(os.getcwd(), "%s/sounds/talking" % (self.testParentDir))
@@ -47,16 +49,18 @@
extensions = [1234,1234,5678,5678,9000]
for extension in extensions:
- print str(datetime.now()) + " Originating call to sip/ast1/" + str(extension)
+ logger.debug("Originating call to sip/ast1/" + str(extension))
df = ami.originate("sip/ast1/" + str(extension), "sendvoicemail", str(extension), 1, None, "CallId-" + str(extension), None, None, None, {}, True )
df.addErrback(self.handleOriginateFailure)
+
def handleOriginateFailure(self, reason):
- print str(datetime.now()) + " error sending originate:"
- print reason.getTraceback()
+ logger.error("Error sending originate:")
+ logger.error(reason.getTraceback())
self.stop_reactor()
return reason
+
def user_event(self, ami, event):
if event['userevent'] != 'TestResult':
@@ -64,11 +68,11 @@
if event['result'] == "pass":
self.passed = True
- print str(datetime.now()) + " VoiceMail successfully exited"
+ logger.info("VoiceMail successfully exited")
else:
- print str(datetime.now()) + " VoiceMail did not successfully exit:"
- print str(datetime.now()) + " result: %s" % (event['result'],)
- print str(datetime.now()) + " error: %s" % (event['error'],)
+ logger.warn("VoiceMail did not successfully exit:")
+ logger.warn("result: %s" % (event['result'],))
+ logger.warn("error: %s" % (event['error'],))
self.stop_reactor()
@@ -98,23 +102,23 @@
if test.passed:
formats = ["ulaw","wav","WAV"]
if not voicemailManager.checkVoicemailExists("default","1234",0,formats):
- print str(datetime.now()) + " Failed to find voicemail 0 for default/1234"
+ logger.warn("Failed to find voicemail 0 for default/1234")
test.passed = 0
if not voicemailManager.checkVoicemailExists("default","1234",1,formats):
- print str(datetime.now()) + " Failed to find voicemail 1 for default/1234"
+ logger.warn("Failed to find voicemail 1 for default/1234")
test.passed = 0
if not voicemailManager.checkVoicemailExists("default","5678",0,formats):
- print str(datetime.now()) + " Failed to find voicemail 0 for default/5678"
+ logger.warn("Failed to find voicemail 0 for default/5678")
test.passed = 0
if not voicemailManager.checkVoicemailExists("default","5678",1,formats):
- print str(datetime.now()) + " Failed to find voicemail 0 for default/5678"
+ logger.warn("Failed to find voicemail 0 for default/5678")
test.passed = 0
if not voicemailManager.checkVoicemailExists("notdefault","1234",0,formats):
- print str(datetime.now()) + " Failed to find voicemail 0 for notdefault/1234"
+ logger.warn("Failed to find voicemail 0 for notdefault/1234")
test.passed = 0
if not test.passed:
Modified: asterisk/team/mjordan/python_logging_082811/tests/apps/voicemail/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mjordan/python_logging_082811/tests/apps/voicemail/tests.yaml?view=diff&rev=1994&r1=1993&r2=1994
==============================================================================
--- asterisk/team/mjordan/python_logging_082811/tests/apps/voicemail/tests.yaml (original)
+++ asterisk/team/mjordan/python_logging_082811/tests/apps/voicemail/tests.yaml Sun Aug 28 16:18:58 2011
@@ -10,4 +10,21 @@
# - test: 'authenticate_nominal'
# - test: 'authenticate_invalid_mailbox'
# - test: 'authenticate_invalid_password'
-# - test: 'authenticate_extensions'
+# - test: 'authenticate_extensions'
+# - test: 'check_voicemail_nominal'
+# - test: 'check_voicemail_envelope'
+# - test: 'check_voicemail_delete'
+# - test: 'check_voicemail_new_user'
+# - test: 'check_voicemail_new_user_hangup'
+# - test: 'check_voicemail_options_record_busy'
+# - test: 'check_voicemail_options_record_unavail'
+# - test: 'check_voicemail_options_record_name'
+# - test: 'check_voicemail_options_record_temp'
+# - test: 'check_voicemail_options_change_password'
+# - test: 'check_voicemail_forward'
+# - test: 'check_voicemail_forward_hangup'
+# - test: 'check_voicemail_forward_with_prepend'
+# - test: 'check_voicemail_callback'
+# - test: 'check_voicemail_dialout'
+# - test: 'check_voicemail_reply'
+# - test: 'check_voicemail_while_leaving_msg'
More information about the asterisk-commits
mailing list