[asterisk-commits] mjordan: testsuite/asterisk/trunk r3684 - /asterisk/trunk/lib/python/asterisk/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Mar 30 15:26:57 CDT 2013


Author: mjordan
Date: Sat Mar 30 15:26:52 2013
New Revision: 3684

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=3684
Log:
Make application tests more tolerant to different event ordering

The apptest tests use a Local channel (which is a pair of channels) to drive
the logic within a complex Asterisk application. When a test starts, the
apptest module must determine which half of the Local channel is in the
application under test, and which half is in a set of extensions that drive
input into the application.

Prior to some Asterisk refactoring of AMI events on Stasis-Core, the test
would always receive the Newchannel events for the Local channel halves
prior to receiving the Varset event notifying it that the Local channel is
the channel the test explicitly spawned. Now, however, that ordering does not
always occur - in fact, it was never guaranteed to happen (it just did!)
This patch makes the apptest tests more tolerant to the Varset event
occurring before or after the second Newchannel event.


Modified:
    asterisk/trunk/lib/python/asterisk/apptest.py

Modified: asterisk/trunk/lib/python/asterisk/apptest.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/lib/python/asterisk/apptest.py?view=diff&rev=3684&r1=3683&r2=3684
==============================================================================
--- asterisk/trunk/lib/python/asterisk/apptest.py (original)
+++ asterisk/trunk/lib/python/asterisk/apptest.py Sat Mar 30 15:26:52 2013
@@ -265,6 +265,7 @@
         self._previous_sound_file = ''
         self._test_observers = []
         self._hangup_observers = []
+        self._candidate_prefix = ''
         self._unique_id = str(uuid.uuid1())
         if 'start-on-create' in channel_def and channel_def['start-on-create']:
             self.spawn_call(delay)
@@ -467,10 +468,21 @@
         return self.__audio_dtmf_deferred
 
 
+    def __evaluate_candidates(self):
+        ''' Determine if we know who our candidate channel is '''
+        if len(self._candidate_prefix) == 0:
+            return
+        for channel in self._all_channels:
+            if self._candidate_prefix in channel:
+                LOGGER.debug('Adding candidate channel %s' % channel)
+                self._candidate_channels.append(channel)
+
+
     def __new_channel_handler(self, ami, event):
         ''' Handler for the Newchannel event '''
         if event['channel'] not in self._all_channels:
             self._all_channels.append(event['channel'])
+            self.__evaluate_candidates()
 
 
     def __hangup_event_handler(self, ami, event):
@@ -507,8 +519,9 @@
             return
         channel_name = event['channel'][:len(event['channel'])-2]
         LOGGER.debug('Detected channel %s' % channel_name)
-        self._candidate_channels = [channel for channel in self._all_channels
-                                    if channel_name in channel]
+        self._candidate_prefix = channel_name
+        self.__evaluate_candidates()
+
 
     def __test_event_handler(self, ami, event):
         ''' Handler for test events '''




More information about the asterisk-commits mailing list