[asterisk-commits] dlee: branch dlee/ari-bridge-tests r4024 - /asterisk/team/dlee/ari-bridge-tes...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Aug 15 15:34:23 CDT 2013


Author: dlee
Date: Thu Aug 15 15:34:21 2013
New Revision: 4024

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4024
Log:
Working test

Modified:
    asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/unhappy/bridge_unhappy.py

Modified: asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/unhappy/bridge_unhappy.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/unhappy/bridge_unhappy.py?view=diff&rev=4024&r1=4023&r2=4024
==============================================================================
--- asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/unhappy/bridge_unhappy.py (original)
+++ asterisk/team/dlee/ari-bridge-tests/tests/rest_api/bridges/unhappy/bridge_unhappy.py Thu Aug 15 15:34:21 2013
@@ -17,30 +17,34 @@
     def __init__(self):
         self.ami_channel_id = None
         self.stasis_channel_id = None
-        self.ami_channel_ready = False
+        self.ami_ready = False
+        self.stasis_ready = False
 
     def on_start(self, ari, event):
         if not self.ami_channel_id:
             # Send the first channel out of Stasis
             self.ami_channel_id = event['channel']['id']
+            ari.post('channels', self.ami_channel_id, 'answer')
             ari.post('channels', self.ami_channel_id, 'continue')
         elif not self.stasis_channel_id:
             self.stasis_channel_id = event['channel']['id']
+            ari.post('channels', self.stasis_channel_id, 'answer')
+            self.stasis_ready = True
         else:
             assert False, "Too many channels!"
         return True
 
     def on_end(self, ari, event):
         if event['channel']['id'] == self.ami_channel_id:
-            self.ami_channel_ready = True
+            self.ami_ready = True
         elif event['channel']['id'] == self.stasis_channel_id:
             pass
         else:
-            assert False, "Unexpected channel leaving Stasis"
+            assert False, "Unexpected channel %s leaving Stasis" % event['channel']['id']
         return True
 
     def run_test(self, ari):
-        if not (self.ami_channel_id and self.stasis_channel_id and self.ami_channel_ready):
+        if not (self.ami_ready and self.stasis_ready):
             # Not ready to run the test
             return
 
@@ -50,7 +54,9 @@
             assert self.passing
         finally:
             ari.delete('channels', self.ami_channel_id)
+            self.ami_ready = False
             ari.delete('channels', self.stasis_channel_id)
+            self.stasis_ready = False
             ari.set_allow_errors(False)
 
     def __run_test(self, ari):
@@ -62,7 +68,7 @@
             expected_code = requests.codes[expected]
             if expected_code != resp.status_code:
                 self.passing = False
-                LOGGER.error("Expected %d (%s), got %s", expected_code, expected, resp.status_code)
+                LOGGER.error("Expected %d (%s), got %s (%r)", expected_code, expected, resp.status_code, resp.json())
                 # Log current stack frame
                 for line in traceback.format_stack(inspect.currentframe())[-2:-4:-1]:
                     if line:
@@ -88,9 +94,13 @@
         resp = ari.post('bridges', bridge_id, 'removeChannel', channel='i-am-not-a-channel')
         validate('bad_request', resp)
 
+        # Remove a channel that isn't in Stasis
+        resp = ari.post('bridges', bridge_id, 'removeChannel', channel=self.ami_channel_id)
+        validate('unprocessable_entity', resp)
+
         # Remove a Stasis channel that isn't in a bridge at all
         resp = ari.post('bridges', bridge_id, 'removeChannel', channel=self.stasis_channel_id)
-        validate('conflict', resp)
+        validate('unprocessable_entity', resp)
 
         # We need a channel in a bridge for the next few tests
         resp = ari.post('bridges', bridge_id, 'addChannel', channel=self.stasis_channel_id)




More information about the asterisk-commits mailing list