[asterisk-commits] twilson: testsuite/asterisk/trunk r3231 - in /asterisk/trunk: ./ configs/ lib...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon May 21 18:01:20 CDT 2012


Author: twilson
Date: Mon May 21 18:01:10 2012
New Revision: 3231

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3231
Log:
Add CEL testing

Review: https://reviewboard.asterisk.org/r/1901/

Added:
    asterisk/trunk/configs/cel.conf   (with props)
    asterisk/trunk/configs/cel_custom.conf   (with props)
    asterisk/trunk/lib/python/asterisk/astcsv.py   (with props)
    asterisk/trunk/lib/python/asterisk/cel.py   (with props)
    asterisk/trunk/lib/python/asterisk/self_test/CELMaster1.csv   (with props)
    asterisk/trunk/lib/python/asterisk/self_test/CELMaster2.csv   (with props)
Modified:
    asterisk/trunk/lib/python/asterisk/cdr.py
    asterisk/trunk/runtests.py
    asterisk/trunk/tests/iax2/basic-call/run-test

Added: asterisk/trunk/configs/cel.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/configs/cel.conf?view=auto&rev=3231
==============================================================================
--- asterisk/trunk/configs/cel.conf (added)
+++ asterisk/trunk/configs/cel.conf Mon May 21 18:01:10 2012
@@ -1,0 +1,4 @@
+[general]
+enable=yes
+apps=dial,park
+events=ALL

Propchange: asterisk/trunk/configs/cel.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/configs/cel.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/configs/cel.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/configs/cel_custom.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/configs/cel_custom.conf?view=auto&rev=3231
==============================================================================
--- asterisk/trunk/configs/cel_custom.conf (added)
+++ asterisk/trunk/configs/cel_custom.conf Mon May 21 18:01:10 2012
@@ -1,0 +1,2 @@
+[mappings]
+Master.csv => ${CSV_QUOTE(${eventtype})},${CSV_QUOTE(${eventtime})},${CSV_QUOTE(${CALLERID(name)})},${CSV_QUOTE(${CALLERID(num)})},${CSV_QUOTE(${CALLERID(ANI)})},${CSV_QUOTE(${CALLERID(RDNIS)})},${CSV_QUOTE(${CALLERID(DNID)})},${CSV_QUOTE(${CHANNEL(exten)})},${CSV_QUOTE(${CHANNEL(context)})},${CSV_QUOTE(${CHANNEL(channame)})},${CSV_QUOTE(${CHANNEL(appname)})},${CSV_QUOTE(${CHANNEL(appdata)})},${CSV_QUOTE(${CHANNEL(amaflags)})},${CSV_QUOTE(${CHANNEL(accountcode)})},${CSV_QUOTE(${CHANNEL(uniqueid)})},${CSV_QUOTE(${CHANNEL(linkedid)})},${CSV_QUOTE(${BRIDGEPEER})},${CSV_QUOTE(${CHANNEL(userfield)})},${CSV_QUOTE(${userdeftype})},${CSV_QUOTE(${eventextra})}

Propchange: asterisk/trunk/configs/cel_custom.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/configs/cel_custom.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/configs/cel_custom.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/lib/python/asterisk/astcsv.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/astcsv.py?view=auto&rev=3231
==============================================================================
--- asterisk/trunk/lib/python/asterisk/astcsv.py (added)
+++ asterisk/trunk/lib/python/asterisk/astcsv.py Mon May 21 18:01:10 2012
@@ -1,0 +1,209 @@
+#!/usr/bin/env python
+"""Asterisk CSV-based testing
+
+This module implements the basic CSV testing backend for things like
+CDR and CEL tests.
+
+Copyright (C) 2010, Digium, Inc.
+Terry Wilson<twilson at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+"""
+
+import unittest
+import sys
+import csv
+import re
+import logging
+import time
+
+logger = logging.getLogger(__name__)
+
+class AsteriskCSVLine:
+    "A single Asterisk call detail record"
+
+    def __init__(self, fields, **kwargs):
+        """Construct an Asterisk CSV entry.
+
+        The arguments list definition must be in the same order that the
+        arguments appear in the CSV file. They can, of course, be passed to
+        __init__ in any order. AsteriskCSV will pass the arguments via a
+        **dict.
+        """
+
+        # make all arguments passed available as instance variables
+        self.__dict__.update(kwargs)
+        self.__columns = kwargs
+        self.__fields = fields
+
+    def match(self, other, silent=False, exact=(False, False)):
+        """Matches if the subset of fields that exist in both records match.
+
+        It is important to make sure that if you want to test against an empty
+        field, that it is passed as an empty string and not left out of the
+        initialization or passed as None.
+
+        exact - Whether (self, other) contain exact strings (True) or regexes
+        """
+
+        if exact == (False, False):
+            logger.error("Can't compare two regexes, that's silly")
+            return False
+        elif exact == (False, True):
+            cmp_fn = (lambda x,y: re.match(str(x).lower() + '$', str(y).lower()))
+        elif exact == (True, False):
+            cmp_fn = (lambda x,y: re.match(str(y).lower() + '$', str(x).lower()))
+        else:
+            cmp_fn = (lambda x,y: str(x).lower() == str(y).lower())
+
+        for k, v in self.iteritems():
+            if None not in (v, other.get(k)):
+                if not cmp_fn(v, other.get(k)):
+                    if not silent:
+                        logger.warn("CSV MATCH FAILED, Expected: %s: '%s' Got: %s: '%s'" % (k, v, k, other.get(k)))
+                    return False
+        return True
+
+    def get(self, k):
+        return self.__columns.get(k)
+
+    def iteritems(self):
+        return self.__columns.iteritems()
+
+    def __str__(self):
+        return ",".join(["\"%s\"" % (self.__dict__[x]) for x in self.__fields])
+
+
+class AsteriskCSV:
+    """A representation of an Asterisk CSV file"""
+
+    def __init__(self, fn=None, records=None, fields=None, row_factory=None):
+        """Initialize CSV records from an Asterisk csv file"""
+
+        self.filename = fn
+        self.row_factory = row_factory
+
+        if records:
+            self.__records = records
+            return
+
+        self.__records = []
+
+        csvreader = None
+
+        try:
+            csvreader = csv.DictReader(open(fn, "r"), fields, ",")
+        except IOError as (errno, strerror):
+            logger.debug("IOError %d[%s] while opening file '%s'" % (errno, strerror, fn))
+            raise
+        except:
+            logger.debug("Unexpected error: %s" % (sys.exc_info()[0]))
+            raise
+
+        if not csvreader:
+            logger.error("Unable to open file '%s'" % (fn))
+            return
+
+        for r in csvreader:
+            record = self.row_factory(**r)
+            self.__records.append(record)
+
+    def __len__(self):
+        return len(self.__records)
+
+    def __getitem__(self, key):
+        return self.__records.__getitem__(key)
+
+    def __iter__(self):
+        return self.__records.__iter__()
+
+    def match(self, other, partial=False):
+        """Compares the length of self and other AsteriskCSVs and then compares
+        each record"""
+
+        if not partial and (len(self) != len(other)):
+            logger.warn("CSV MATCH FAILED, different number of records, self=%d and other=%d" % (len(self), len(other)))
+            return False
+
+        def match_order(list_a, list_b, cmp_func):
+            """Utility function that attempts to find out whether list_a and
+            list_b have a single ordering match or if there is more than
+            one.
+
+            >>> f = (lambda x, y: x == y)
+            >>> match_order(['A', 'B', 'C'], ['C', 'B', 'X'], f)
+            ()
+            >>> match_order(['A', 'B', 'C'], ['C', 'B', 'A'], f)
+            ((2, 1, 0),)
+            >>> match_order(['A', 'B', 'C', 'B'], ['C', 'B', 'A', 'B'], f)
+            ((2, 1, 0, 3), (2, 3, 0, 1))
+            """
+            if not partial:
+                assert len(list_a) == len(list_b)
+            size = len(list_a)
+
+            # attempt two orderings: forward and reversed
+            guess_orders = (range(size), list(reversed(range(size)))) # both mutable
+            found_orders = []
+
+            for guess_order in guess_orders:
+                found_order = []
+                for a in range(size):
+                    for b in guess_order:
+                        if cmp_func(list_a[a], list_b[b]):
+                            found_order.append(b)
+                            guess_order.remove(b)
+                            break
+                    else:
+                        # no match at all..
+                        return ()
+                found_orders.append(tuple(found_order))
+
+            if found_orders[0] != found_orders[1]:
+                return tuple(found_orders)
+            return (found_orders[0],)
+
+        # If there is a filename, then we know that the fields are just text,
+        # and not regexes. We need to know this when we are matching individual
+        # rows so we know whether it is self or other that has the text we are
+        # matching against. If both are file-based, then we know not to use
+        # regexes at all and just test equality
+        exactness = (bool(self.filename), bool(other.filename))
+
+        # Use the match_order function to see if there either is (a) no match,
+        # or (b) a single match or (c) several matches. In the latter case, the
+        # regexes should probably be chosen more carefully.
+        matches = match_order(self, other, (lambda x, y: x.match(y,
+            silent=True, exact=exactness)))
+
+        if len(matches) == 0:
+            # Bah.. no match. Loop over the records in the normal order and
+            # have it complain immediately.
+            for i, x in enumerate(self):
+                if not x.match(other[i], exact=exactness):
+                    logger.warn("Failed to match entry %d" % (i,))
+                    return False
+            assert False
+
+        elif len(matches) == 1:
+            pass # joy!
+
+        elif len(matches) > 1:
+            logger.warn("More than one CSV permutation results in success")
+
+        return True
+
+    def __str__(self):
+        return "\n".join([str(x) for x in self.__records])
+
+    def empty(self):
+        try:
+            open(self.filename, "w").close()
+        except:
+            logger.warn("Unable to empty CSV file %s" % (self.filename))
+
+if __name__ == '__main__':
+    unittest.main()
+
+# vim:sw=4:ts=4:expandtab:textwidth=79

Propchange: asterisk/trunk/lib/python/asterisk/astcsv.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/lib/python/asterisk/astcsv.py
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/lib/python/asterisk/astcsv.py
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: asterisk/trunk/lib/python/asterisk/cdr.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/cdr.py?view=diff&rev=3231&r1=3230&r2=3231
==============================================================================
--- asterisk/trunk/lib/python/asterisk/cdr.py (original)
+++ asterisk/trunk/lib/python/asterisk/cdr.py Mon May 21 18:01:10 2012
@@ -13,14 +13,19 @@
 import unittest
 import sys
 import csv
+import astcsv
 import re
 import logging
 import time
 
 logger = logging.getLogger(__name__)
 
-class AsteriskCSVCDRLine:
+class AsteriskCSVCDRLine(astcsv.AsteriskCSVLine):
     "A single Asterisk call detail record"
+
+    fields = ['accountcode', 'source', 'destination', 'dcontext', 'callerid',
+    'channel', 'dchannel', 'lastapp', 'lastarg', 'start', 'answer', 'end',
+    'duration', 'billsec', 'disposition', 'amaflags', 'uniqueid', 'userfield']
 
     def __init__(self, accountcode=None, source=None, destination=None,
             dcontext=None, callerid=None, channel=None, dchannel=None,
@@ -35,167 +40,33 @@
         **dict.
         """
 
-        # make all arguments passed available as instance variables
-        self.__dict__.update(locals())
-        del self.__dict__['self']
-
-    def match(self, other, silent=False):
-        """Matches if the subset of fields that exist in both records match.
-
-        It is important to make sure that if you want to test against an empty
-        field, that it is passed as an empty string and not left out of the
-        initialization or passed as None.
-        """
-
-        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()):
-                if not silent:
-                    logger.warn("CDR MATCH FAILED, Expected: %s:%s Got: %s:%s" %
-                            (k, v, k, other.get(k)))
-                return False
-        return True
-
-    def get(self, k):
-        return self.__dict__.get(k)
-
-    def iteritems(self):
-        return self.__dict__.iteritems()
-
-    __fields = __init__.func_code.co_varnames[1:]
-
-    @classmethod
-    def get_fields(self):
-        return self.__fields
-
-    @classmethod
-    def get_field(self, i):
-        return self.__fields[i]
-
-    def __str__(self):
-        return ",".join(["\"%s\"" % (self.__dict__[x]) for x in AsteriskCSVCDRLine.get_fields()])
+        return astcsv.AsteriskCSVLine.__init__(self,
+            AsteriskCSVCDRLine.fields, accountcode=accountcode,
+            source=source, destination=destination,
+            dcontext=dcontext, callerid=callerid, channel=channel,
+            dchannel=dchannel, lastapp=lastapp, lastarg=lastarg, start=start, answer=answer,
+            end=end, duration=duration, billsec=billsec, disposition=disposition,
+            amaflags=amaflags, uniqueid=uniqueid, userfield=userfield)
 
 
-class AsteriskCSVCDR:
+class AsteriskCSVCDR(astcsv.AsteriskCSV):
     """A representation of an Asterisk CSV CDR file"""
 
     def __init__(self, fn=None, records=None):
         """Initialize CDR records from an Asterisk cdr-csv file"""
 
-        self.filename = fn
-        if records:
-            self.__records = records
-            return
-
-        self.__records = []
-
-        cdr = None
-        try:
-            cdr = csv.DictReader(open(fn, "r"), AsteriskCSVCDRLine.get_fields(), ",")
-        except IOError as (errno, strerror):
-            logger.debug("IOError %d[%s] while opening CDR file '%s'" % (errno, strerror, fn))
-        except:
-            logger.debug("Unexpected error: %s" % (sys.exc_info()[0]))
-
-        if not cdr:
-            logger.error("Unable to open CDR file '%s'" % (fn))
-            return
-
-        for r in cdr:
-            record = AsteriskCSVCDRLine(**r)
-            self.__records.append(record)
-
-    def __len__(self):
-        return len(self.__records)
-
-    def __getitem__(self, key):
-        return self.__records.__getitem__(key)
-
-    def __iter__(self):
-        return self.__records.__iter__()
-
-    def match(self, other):
-        """Compares the length of self and other AsteriskCSVCDRs and then compares
-        each record"""
-
-        if len(self) != len(other):
-            logger.warn("CDR MATCH FAILED, different number of records")
-            return False
-
-        def match_order(list_a, list_b, cmp_func):
-            """Utility function that attempts to find out whether list_a and
-            list_b have a single ordering match or if there is more than
-            one.
-
-            >>> f = (lambda x, y: x == y)
-            >>> match_order(['A', 'B', 'C'], ['C', 'B', 'X'], f)
-            ()
-            >>> match_order(['A', 'B', 'C'], ['C', 'B', 'A'], f)
-            ((2, 1, 0),)
-            >>> match_order(['A', 'B', 'C', 'B'], ['C', 'B', 'A', 'B'], f)
-            ((2, 1, 0, 3), (2, 3, 0, 1))
-            """
-            assert len(list_a) == len(list_b)
-            size = len(list_a)
-
-            # attempt two orderings: forward and reversed
-            guess_orders = (range(size), list(reversed(range(size)))) # both mutable
-            found_orders = []
-
-            for guess_order in guess_orders:
-                found_order = []
-                for a in range(size):
-                    for b in guess_order:
-                        if cmp_func(list_a[a], list_b[b]):
-                            found_order.append(b)
-                            guess_order.remove(b)
-                            break
-                    else:
-                        # no match at all..
-                        return ()
-                found_orders.append(tuple(found_order))
-
-            if found_orders[0] != found_orders[1]:
-                return tuple(found_orders)
-            return (found_orders[0],)
-
-        # Use the match_order function to see if there either is (a) no match,
-        # or (b) a single match or (c) several matches. In the latter case, the
-        # regexes should probably be chosen more carefully.
-        matches = match_order(self, other, (lambda x, y: x.match(y, silent=True)))
-
-        if len(matches) == 0:
-            # Bah.. no match. Loop over the records in the normal order and
-            # have it complain immediately.
-            for i, x in enumerate(self):
-                if not x.match(other[i]):
-                    return False
-            assert False
-
-        elif len(matches) == 1:
-            pass # joy!
-
-        elif len(matches) > 1:
-            logger.warn("More than one CDR permutation results in success")
-
-        return True
-
-    def __str__(self):
-        return "\n".join([str(x) for x in self.__records])
-
-    def empty(self):
-        try:
-            open(self.filename, "w").close()
-        except:
-            logger.warn("Unable to empty CDR file %s" % (self.filename))
+        return astcsv.AsteriskCSV.__init__(self, fn, records,
+                AsteriskCSVCDRLine.fields, AsteriskCSVCDRLine)
 
 
 class AsteriskCSVCDRTests(unittest.TestCase):
     def test_cdr(self):
         c = AsteriskCSVCDR("self_test/Master.csv")
         self.assertEqual(len(c), 2)
-        self.assertTrue(AsteriskCSVCDRLine(duration=7,lastapp="hangup").match(c[0]))
-        self.assertTrue(c[0].match(AsteriskCSVCDRLine(duration=7,lastapp="hangup")))
+        self.assertTrue(AsteriskCSVCDRLine(duration=7,lastapp="hangup").match(c[0],
+            exact=(True, True)))
+        self.assertTrue(c[0].match(AsteriskCSVCDRLine(duration=7,lastapp="hangup"),
+            exact=(True, True)))
 
         self.assertFalse(c[1].match(c[0]))
         self.assertFalse(c[0].match(c[1]))

Added: asterisk/trunk/lib/python/asterisk/cel.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/cel.py?view=auto&rev=3231
==============================================================================
--- asterisk/trunk/lib/python/asterisk/cel.py (added)
+++ asterisk/trunk/lib/python/asterisk/cel.py Mon May 21 18:01:10 2012
@@ -1,0 +1,84 @@
+#!/usr/bin/env python
+"""Asterisk call detail record testing
+
+This module implements an Asterisk CEL parser.
+
+Copyright (C) 2010, Digium, Inc.
+Terry Wilson<twilson at digium.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+"""
+
+import unittest
+import sys
+import csv
+import astcsv
+import re
+import logging
+import time
+
+logger = logging.getLogger(__name__)
+
+class AsteriskCSVCELLine(astcsv.AsteriskCSVLine):
+    "A single Asterisk Call Event Log record"
+
+    fields = ['eventtype', 'eventtime', 'cidname', 'cidnum', 'ani', 'rdnis',
+    'dnid', 'exten', 'context', 'channel', 'app', 'appdata', 'amaflags',
+    'accountcode', 'uniqueid', 'linkedid', 'bridgepeer', 'userfield',
+    'userdeftype', 'eventextra']
+
+    def __init__(self, eventtype=None, eventtime=None, cidname=None, cidnum=None,
+    ani=None, rdnis=None, dnid=None, exten=None, context=None, channel=None,
+    app=None, appdata=None, amaflags=None, accountcode=None, uniqueid=None,
+    linkedid=None, bridgepeer=None, userfield=None, userdeftype=None,
+    eventextra=None):
+        """Construct an Asterisk CSV CEL.
+
+        The arguments list definition must be in the same order that the
+        arguments appear in the CSV file. They can, of course, be passed to
+        __init__ in any order. AsteriskCSVCEL will pass the arguments via a
+        **dict.
+        """
+
+        return astcsv.AsteriskCSVLine.__init__(self, AsteriskCSVCELLine.fields,
+        eventtype=eventtype, eventtime=eventtime, cidname=cidname,
+        cidnum=cidnum, ani=ani, rdnis=rdnis, dnid=dnid, exten=exten,
+        context=context, channel=channel, app=app, appdata=appdata,
+        amaflags=amaflags, accountcode=accountcode, uniqueid=uniqueid,
+        linkedid=linkedid, bridgepeer=bridgepeer, userfield=userfield,
+        userdeftype=userdeftype, eventextra=eventextra)
+
+class AsteriskCSVCEL(astcsv.AsteriskCSV):
+    """A representation of an Asterisk CSV CEL file"""
+
+    def __init__(self, fn=None, records=None):
+        """Initialize CEL records from an Asterisk cel-csv file"""
+
+        return astcsv.AsteriskCSV.__init__(self, fn, records,
+                AsteriskCSVCELLine.fields, AsteriskCSVCELLine)
+
+
+class AsteriskCSVCELTests(unittest.TestCase):
+    def test_cel(self):
+        c = AsteriskCSVCEL("self_test/CELMaster1.csv")
+        self.assertEqual(len(c), 16)
+        self.assertTrue(AsteriskCSVCELLine(eventtype="LINKEDID_END",channel="TinCan/string").match(c[-1],
+            silent=True, exact=(True, True)))
+        self.assertTrue(c[-1].match(AsteriskCSVCELLine(eventtype="LINKEDID_END",channel="TinCan/string"),
+            silent=True, exact=(True, True)))
+
+        self.assertFalse(c[1].match(c[0], silent=True))
+        self.assertFalse(c[0].match(c[1], silent=True))
+        self.assertEqual(c[-1].channel, "TinCan/string")
+
+        self.assertTrue(c.match(c))
+        c2 = AsteriskCSVCEL("self_test/CELMaster2.csv")
+        self.assertFalse(c.match(c2))
+
+
+if __name__ == '__main__':
+    logging.basicConfig()
+    unittest.main()
+
+# vim:sw=4:ts=4:expandtab:textwidth=79

Propchange: asterisk/trunk/lib/python/asterisk/cel.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/lib/python/asterisk/cel.py
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/lib/python/asterisk/cel.py
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/lib/python/asterisk/self_test/CELMaster1.csv
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/self_test/CELMaster1.csv?view=auto&rev=3231
==============================================================================
--- asterisk/trunk/lib/python/asterisk/self_test/CELMaster1.csv (added)
+++ asterisk/trunk/lib/python/asterisk/self_test/CELMaster1.csv Mon May 21 18:01:10 2012
@@ -1,0 +1,16 @@
+"CHAN_START","1335310195.513823","","","","","","s","default","TinCan/string","","","3","","1335310195.0","1335310195.0","","","",""
+"CHAN_START","1335310195.520220","","","","","","x","default","Local/x at default-1545;1","","","3","","1335310195.1","1335310195.0","","","",""
+"CHAN_START","1335310195.521063","","","","","","x","default","Local/x at default-1545;2","","","3","","1335310195.2","1335310195.0","","","",""
+"ANSWER","1335310195.526390","","","","","","x","default","Local/x at default-1545;2","Answer","","3","","1335310195.2","1335310195.0","","","",""
+"ANSWER","1335310195.526544","","s","","","","s","default","Local/x at default-1545;1","AppDial","(Outgoing Line)","3","","1335310195.1","1335310195.0","","","",""
+"ANSWER","1335310195.530613","","","","","s","s","default","TinCan/string","Dial","Local/x at default","3","","1335310195.0","1335310195.0","","","",""
+"BRIDGE_START","1335310195.531291","","","","","s","s","default","TinCan/string","Dial","Local/x at default","3","","1335310195.0","1335310195.0","Local/x at default-1545;1","","",""
+"ANSWER","1335310196.032009","","","","","","x","default","Local/x at default-1545;2","Playback","tt-monkeys","3","","1335310195.2","1335310195.0","","","",""
+"HANGUP","1335310212.719577","","","","","","x","default","Local/x at default-1545;2","","","3","","1335310195.2","1335310195.0","","","","16,dialplan/builtin,"
+"BRIDGE_END","1335310212.721349","","","","","s","s","default","TinCan/string","Dial","Local/x at default","3","","1335310195.0","1335310195.0","Local/x at default-1545;1","","",""
+"CHAN_END","1335310212.942353","","","","","","x","default","Local/x at default-1545;2","","","3","","1335310195.2","1335310195.0","","","",""
+"HANGUP","1335310213.621056","","s","","","","","default","Local/x at default-1545;1","AppDial","(Outgoing Line)","3","","1335310195.1","1335310195.0","","","","16,,"
+"CHAN_END","1335310213.621738","","s","","","","","default","Local/x at default-1545;1","AppDial","(Outgoing Line)","3","","1335310195.1","1335310195.0","","","",""
+"HANGUP","1335310213.624898","","","","","s","s","default","TinCan/string","","","3","","1335310195.0","1335310195.0","","","","16,,ANSWER"
+"CHAN_END","1335310213.625193","","","","","s","s","default","TinCan/string","","","3","","1335310195.0","1335310195.0","","","",""
+"LINKEDID_END","1335310213.625295","","","","","s","s","default","TinCan/string","","","3","","1335310195.0","1335310195.0","","","",""

Propchange: asterisk/trunk/lib/python/asterisk/self_test/CELMaster1.csv
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/lib/python/asterisk/self_test/CELMaster1.csv
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/lib/python/asterisk/self_test/CELMaster1.csv
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/lib/python/asterisk/self_test/CELMaster2.csv
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/self_test/CELMaster2.csv?view=auto&rev=3231
==============================================================================
--- asterisk/trunk/lib/python/asterisk/self_test/CELMaster2.csv (added)
+++ asterisk/trunk/lib/python/asterisk/self_test/CELMaster2.csv Mon May 21 18:01:10 2012
@@ -1,0 +1,14 @@
+"CHAN_START","1335310697.630407","","","","","","s","default","TinCan/string","","","3","","1335310697.0","1335310697.0","","","",""
+"CHAN_START","1335310697.637730","","","","","","x","default","Local/x at default-e315;1","","","3","","1335310697.1","1335310697.0","","","",""
+"CHAN_START","1335310697.638531","","","","","","x","default","Local/x at default-e315;2","","","3","","1335310697.2","1335310697.0","","","",""
+"ANSWER","1335310697.648867","","","","","","x","default","Local/x at default-e315;2","Answer","","3","","1335310697.2","1335310697.0","","","",""
+"ANSWER","1335310697.651704","","","","","s","s","default","TinCan/string","Dial","Local/x at default","3","","1335310697.0","1335310697.0","","","",""
+"BRIDGE_START","1335310697.652597","","","","","s","s","default","TinCan/string","Dial","Local/x at default","3","","1335310697.0","1335310697.0","Local/x at default-e315;1","","",""
+"ANSWER","1335310698.152908","","","","","","x","default","Local/x at default-e315;2","Playback","tt-monkeys","3","","1335310697.2","1335310697.0","","","",""
+"HANGUP","1335310714.842104","","","","","","x","default","Local/x at default-e315;2","","","3","","1335310697.2","1335310697.0","","","","16,dialplan/builtin,"
+"BRIDGE_END","1335310714.843959","","","","","s","s","default","TinCan/string","Dial","Local/x at default","3","","1335310697.0","1335310697.0","Local/x at default-e315;1","","",""
+"CHAN_END","1335310715.105915","","","","","","x","default","Local/x at default-e315;2","","","3","","1335310697.2","1335310697.0","","","",""
+"HANGUP","1335310715.224567","","s","","","","","default","Local/x at default-e315;1","AppDial","(Outgoing Line)","3","","1335310697.1","1335310697.0","","","","16,,"
+"CHAN_END","1335310715.225315","","s","","","","","default","Local/x at default-e315;1","AppDial","(Outgoing Line)","3","","1335310697.1","1335310697.0","","","",""
+"HANGUP","1335310715.229089","","","","","s","s","default","TinCan/string","","","3","","1335310697.0","1335310697.0","","","","16,,ANSWER"
+"LINKEDID_END","1335310715.229955","","","","","s","s","default","TinCan/string","","","3","","1335310697.0","1335310697.0","","","",""

Propchange: asterisk/trunk/lib/python/asterisk/self_test/CELMaster2.csv
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/lib/python/asterisk/self_test/CELMaster2.csv
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/lib/python/asterisk/self_test/CELMaster2.csv
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: asterisk/trunk/runtests.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/runtests.py?view=diff&rev=3231&r1=3230&r2=3231
==============================================================================
--- asterisk/trunk/runtests.py (original)
+++ asterisk/trunk/runtests.py Mon May 21 18:01:10 2012
@@ -428,6 +428,7 @@
                 print "FAILED"
 
     print "\n"
+    return test_suite.total_failures
 
 
 def hardlink_or_copy(source, destination):

Modified: asterisk/trunk/tests/iax2/basic-call/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/iax2/basic-call/run-test?view=diff&rev=3231&r1=3230&r2=3231
==============================================================================
--- asterisk/trunk/tests/iax2/basic-call/run-test (original)
+++ asterisk/trunk/tests/iax2/basic-call/run-test Mon May 21 18:01:10 2012
@@ -19,13 +19,14 @@
 from asterisk.asterisk import Asterisk
 from asterisk.TestCase import TestCase
 from asterisk.cdr import AsteriskCSVCDR, AsteriskCSVCDRLine
+from asterisk.cel import AsteriskCSVCEL, AsteriskCSVCELLine
 
 logger = logging.getLogger(__name__)
 
 class IAXCallTest(TestCase):
     def __init__(self):
         super(IAXCallTest, self).__init__()
-        self.channel1_events = { 'Created': False, 'Hangup': False }
+        self.channel1_events = { 'Created': False, 'Hangup': False, 'CEL' : False }
         self.channel2_events = { 'Created': False, 'Hangup': False, 'CSV': False}
         self.create_asterisk(2)
 
@@ -72,6 +73,22 @@
         if cdr_test.match(cdr):
             self.channel2_events['CSV'] = True
 
+    def check_cels(self):
+        cel = AsteriskCSVCEL(fn="%s/var/log/asterisk/cel-custom/Master.csv" %
+                self.ast[0].base)
+
+        cel_test = AsteriskCSVCEL(
+                records = [
+                    AsteriskCSVCELLine(accountcode="", eventtime="[0-9.]+", linkedid="[0-9.]+", uniqueid="[0-9.]+", appdata="", bridgepeer="", eventtype="CHAN_START", cidname="", eventextra="", ani="", dnid="", amaflags="3", cidnum="", rdnis="", context="default", exten="s", userfield="", app="", channel="IAX2/.*", userdeftype=""),
+                    AsteriskCSVCELLine(accountcode="", eventtime="[0-9.]+", linkedid="[0-9.]+", uniqueid="[0-9.]+", appdata="", bridgepeer="", eventtype="ANSWER", cidname="", eventextra="", ani="", dnid="", amaflags="3", cidnum="", rdnis="", context="", exten="s", userfield="", app="", channel="IAX2/.*", userdeftype=""),
+                    AsteriskCSVCELLine(accountcode="", eventtime="[0-9.]+", linkedid="[0-9.]+", uniqueid="[0-9.]+", appdata="", bridgepeer="", eventtype="HANGUP", cidname="", eventextra="16,dialplan/builtin,", ani="", dnid="", amaflags="3", cidnum="", rdnis="", context="iaxtest", exten="1000", userfield="", app="", channel="IAX2/.*", userdeftype=""),
+                    AsteriskCSVCELLine(accountcode="", eventtime="[0-9.]+", linkedid="[0-9.]+", uniqueid="[0-9.]+", appdata="", bridgepeer="", eventtype="CHAN_END", cidname="", eventextra="", ani="", dnid="", amaflags="3", cidnum="", rdnis="", context="iaxtest", exten="1000", userfield="", app="", channel="IAX2/.*", userdeftype=""),
+                    AsteriskCSVCELLine(accountcode="", eventtime="[0-9.]+", linkedid="[0-9.]+", uniqueid="[0-9.]+", appdata="", bridgepeer="", eventtype="LINKEDID_END", cidname="", eventextra="", ani="", dnid="", amaflags="3", cidnum="", rdnis="", context="iaxtest", exten="1000", userfield="", app="", channel="IAX2/.*", userdeftype="")
+                ]
+        )
+        if cel_test.match(cel):
+            self.channel1_events['CEL'] = True
+
     def check_results(self):
         self.passed = True
         for k, v in self.channel1_events.items():
@@ -87,6 +104,7 @@
     test = IAXCallTest()
     reactor.run()
     test.check_cdrs()
+    test.check_cels()
     test.check_results()
 
     if not test.passed:




More information about the asterisk-commits mailing list