[asterisk-commits] kharwell: testsuite/asterisk/trunk r4758 - /asterisk/trunk/tests/channels/pjs...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Feb 28 09:56:22 CST 2014


Author: kharwell
Date: Fri Feb 28 09:56:16 2014
New Revision: 4758

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4758
Log:
digium_presence: Wait to subscribe until presence is known to have changed

This test would sometimes fail due to timing issues.  It was possible for the
test to subscribe and receive a notify before the presence was actually changed
in the asterisk.  Modified the test so it won't subscribe until it knows for
sure the presence has changed.

Modified:
    asterisk/trunk/tests/channels/pjsip/subscribe/digium_presence/run-test

Modified: asterisk/trunk/tests/channels/pjsip/subscribe/digium_presence/run-test
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/channels/pjsip/subscribe/digium_presence/run-test?view=diff&rev=4758&r1=4757&r2=4758
==============================================================================
--- asterisk/trunk/tests/channels/pjsip/subscribe/digium_presence/run-test (original)
+++ asterisk/trunk/tests/channels/pjsip/subscribe/digium_presence/run-test Fri Feb 28 09:56:16 2014
@@ -26,8 +26,12 @@
 
     def run(self):
         """Test execution method.  Connect to AMI."""
+        super(DigiumPresence, self).run()
+        self.create_ami_factory()
 
-        super(DigiumPresence, self).run()
+    def ami_connect(self, ami):
+        """Wait for the presence state to change then issue a subscribe."""
+
         def _on_scenario_complete(obj):
             """Callback handler for when the sipp scenario runs successfully."""
             # the scenario checks for the appropriate body text
@@ -36,12 +40,17 @@
             self.stop_reactor()
             return obj
 
+        def _subscribe(ami, event):
+            """Presence has changed so subscribe and check for changes
+            in the notify.
+            """
+            sipp = SIPpScenario(self.test_name,
+                                {'scenario':'subscribe.xml', '-p':'5061'})
+            sipp.run(self).addCallback(_on_scenario_complete)
+
+        ami.registerEvent('PresenceStatus', _subscribe)
         # make sure alice is available
         self.ast[0].cli_exec('presencestate change CustomPresence:alice "away,lunch,banana"')
-
-        sipp = SIPpScenario(self.test_name,
-                            {'scenario':'subscribe.xml', '-p':'5061'})
-        sipp.run(self).addCallback(_on_scenario_complete)
 
 def main():
     """Main entry point for test."""




More information about the asterisk-commits mailing list