[asterisk-commits] tests/apps/queues/reason pause ami: Add 'PausedReason' field... (testsuite[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jan 5 05:56:39 CST 2016


Anonymous Coward #1000019 has submitted this change and it was merged.

Change subject: tests/apps/queues/reason_pause_ami: Add 'PausedReason' field test AMI
......................................................................


tests/apps/queues/reason_pause_ami: Add 'PausedReason' field test AMI

This test verified PausedReason field of event QueueMember when a member is
paused with a reason.

ASTERISK-25480

Change-Id: I04ad41f7a39a319f58cf40abeb9434fc02b6d767
---
A tests/apps/queues/reason_pause_ami/configs/ast1/queues.conf
A tests/apps/queues/reason_pause_ami/run-test
A tests/apps/queues/reason_pause_ami/test-config.yaml
M tests/apps/queues/tests.yaml
4 files changed, 90 insertions(+), 0 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved



diff --git a/tests/apps/queues/reason_pause_ami/configs/ast1/queues.conf b/tests/apps/queues/reason_pause_ami/configs/ast1/queues.conf
new file mode 100644
index 0000000..33d875b
--- /dev/null
+++ b/tests/apps/queues/reason_pause_ami/configs/ast1/queues.conf
@@ -0,0 +1,2 @@
+[queue_test]
+member => Local/agent at default
diff --git a/tests/apps/queues/reason_pause_ami/run-test b/tests/apps/queues/reason_pause_ami/run-test
new file mode 100755
index 0000000..da421b6
--- /dev/null
+++ b/tests/apps/queues/reason_pause_ami/run-test
@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+'''
+Copyright (C) 2015, BoxTub SpA.
+Rodrigo Ramírez Norambuena <a at rodrigoramirez.com>
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+'''
+import sys
+import logging
+from twisted.internet import reactor
+
+sys.path.append("lib/python")
+from asterisk.asterisk import Asterisk
+from asterisk.test_case import TestCase
+from asterisk.version import AsteriskVersion
+from twisted.internet import reactor, defer
+from starpy import manager
+
+logger = logging.getLogger(__name__)
+
+class QueueReasonPauseTest(TestCase):
+    def __init__(self):
+        TestCase.__init__(self)
+        self.create_asterisk()
+        self.pause_reason = 'Break'
+        self.passed = False
+
+
+    def ami_connect(self, ami):
+        message = {'Action': 'QueuePause', 'Interface': 'Local/agent at default',
+                   'Paused': True, 'Reason': self.pause_reason}
+        logger.info( "Pausing member with reason")
+        ami.sendMessage(message, responseCallback = self.paused_finished)
+
+    def paused_finished(self, received):
+        message = {'action': 'QueueStatus'}
+        self.ami[0].registerEvent("QueueMember", self.queue_member_event)
+        self.ami[0].sendMessage(message)
+
+        return 0
+
+    def queue_member_event(self, ami, event):
+        reason = event.get("pausedreason")
+        if reason !=  self.pause_reason:
+            logger.error("Received a QueueMember event with no reason setted.")
+            self.passed = False
+            self.stop_reactor()
+            return
+
+        self.passed = True
+
+    # create and connect ami.
+    def run(self):
+        TestCase.run(self)
+        self.create_ami_factory()
+
+def main():
+
+    test = QueueReasonPauseTest()
+    test.start_asterisk()
+    reactor.run()
+    test.stop_asterisk()
+    if test.passed:
+        return 0
+    return 1
+
+
+if __name__ == "__main__":
+    sys.exit(main() or 0)
+
+
+# vim:sw=4:ts=4:expandtab:textwidth=79
diff --git a/tests/apps/queues/reason_pause_ami/test-config.yaml b/tests/apps/queues/reason_pause_ami/test-config.yaml
new file mode 100644
index 0000000..e968d89
--- /dev/null
+++ b/tests/apps/queues/reason_pause_ami/test-config.yaml
@@ -0,0 +1,14 @@
+testinfo:
+    summary: 'Test field PausedReason  AMI event QueueMember'
+    description: |
+        Tests the AMI event QueueMember for check the field PausedReason when a
+        member on queue is paused and the reason was set.
+
+properties:
+    minversion: '13.8.0'
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'
+        - asterisk : 'app_queue'
+    tags:
+        - queues
diff --git a/tests/apps/queues/tests.yaml b/tests/apps/queues/tests.yaml
index b645417..5de2a02 100644
--- a/tests/apps/queues/tests.yaml
+++ b/tests/apps/queues/tests.yaml
@@ -13,3 +13,4 @@
     - test: 'macro_gosub_test'
     - test: 'ringinuse_and_pause'
     - test: 'wrapup_time'
+    - test: 'reason_pause_ami'

-- 
To view, visit https://gerrit.asterisk.org/1848
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I04ad41f7a39a319f58cf40abeb9434fc02b6d767
Gerrit-PatchSet: 2
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Rodrigo Ramirez Norambuena <a at rodrigoramirez.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Rodrigo Ramirez Norambuena <a at rodrigoramirez.com>



More information about the asterisk-commits mailing list