[Asterisk-code-review] app_read: Add tests for Read application (testsuite[16])

Friendly Automation asteriskteam at digium.com
Wed Dec 15 12:42:30 CST 2021


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/testsuite/+/17697 )

Change subject: app_read: Add tests for Read application
......................................................................

app_read: Add tests for Read application

Adds tests for the Read application to ensure
proper behavior and option functionality.

ASTERISK-29705

Change-Id: I0c1e7c3b4f136ae673d955fd5ef7f848b88101f6
---
A tests/apps/read/configs/ast1/extensions.conf
A tests/apps/read/test-config.yaml
M tests/apps/tests.yaml
3 files changed, 122 insertions(+), 0 deletions(-)

Approvals:
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/tests/apps/read/configs/ast1/extensions.conf b/tests/apps/read/configs/ast1/extensions.conf
new file mode 100644
index 0000000..7fd4b53
--- /dev/null
+++ b/tests/apps/read/configs/ast1/extensions.conf
@@ -0,0 +1,59 @@
+
+[default]
+exten => s,1,Answer()
+	same => n,Set(GLOBAL(senddtmf1)=*123#DB)
+	same => n,Set(GLOBAL(senddtmf2)=*123A#2#DB)
+	same => n,Set(GLOBAL(senddtmf3)=**123#DC)
+	same => n,Set(GLOBAL(senddtmf4)=*1254*123#DD)
+	same => n,Set(GLOBAL(senddtmf5)=*009)
+	same => n,Set(GLOBAL(senddtmf6)=*009####)
+	same => n,Set(GLOBAL(senddtmf7)=1234#56)
+	same => n,Set(GLOBAL(senddtmf8)=1234#56)
+	same => n,Set(GLOBAL(senddtmf9)=9876#56)
+	same => n,Set(i=0)
+	same => n,While($[${INC(i)}<=9])
+	same => n,Originate(Local/${i}@send-dtmf,exten,read-dtmf,${i},1,,a)
+	same => n,EndWhile()
+	same => n,Hangup()
+
+[nothing]
+exten => 0,1,Answer()
+	same => n,Wait(8)
+	same => n,Hangup()
+
+[send-dtmf]
+exten => _X!,1,Answer(0.5)
+	same => n,SendDTMF(${senddtmf${EXTEN}})
+	same => n,Wait(15) ; needed so Read has time to finish.
+	same => n,Hangup()
+
+[read-dtmf]
+exten => _[1-4],1,Answer()
+	same => n,Set(TIMEOUT(response)=3)
+	same => n,Read(digits,,,t(D))
+	same => n,GotoIf($["${digits}"="${senddtmf${EXTEN}:0:-2}"]?success,1:fail,1)
+exten => 5,1,Answer()
+	same => n,Set(TIMEOUT(response)=3)
+	same => n,Read(digits) ; normal
+	same => n,GotoIf($["${digits}"="*009"]?success,1:fail,1)
+exten => 6,1,Answer()
+	same => n,Set(TIMEOUT(response)=3)
+	same => n,Read(digits,,8,t) ; no terminator at all
+	same => n,GotoIf($["${digits}"="*009####"]?success,1:fail,1)
+exten => 7,1,Answer()
+	same => n,Set(TIMEOUT(response)=3)
+	same => n,Read(digits,dial,,it(#))
+	same => n,GotoIf($["${digits}"="${senddtmf${EXTEN}:0:-3}"]?success,1:fail,1)
+exten => 8,1,Answer()
+	same => n,Set(TIMEOUT(response)=3)
+	same => n,Read(digits,dial,7,it)
+	same => n,GotoIf($["${digits}"="${senddtmf${EXTEN}}"]?success,1:fail,1)
+exten => 9,1,Answer()
+	same => n,Read(digits,dial,,i)
+	same => n,GotoIf($["${digits}"="${senddtmf${EXTEN}:0:4}"]?success,1:fail,1)
+exten => success,1,Answer(1)
+	same => n,UserEvent(ReadSuccess,Result: Pass)
+	same => n,Hangup()
+exten => fail,1,Answer(1)
+	same => n,UserEvent(ReadFailure,Result: Fail ${digits},Reason: ${digits})
+	same => n,Hangup()
diff --git a/tests/apps/read/test-config.yaml b/tests/apps/read/test-config.yaml
new file mode 100644
index 0000000..6dba4ee
--- /dev/null
+++ b/tests/apps/read/test-config.yaml
@@ -0,0 +1,59 @@
+testinfo:
+    summary: 'Ensure that app_read options work correctly.'
+    description: |
+        'This tests options in the Read application to
+        ensure that it functions correctly.'
+
+test-modules:
+    test-object:
+        config-section: test-object-config
+        typename: 'test_case.TestCaseModule'
+    modules:
+        -
+            config-section: caller-originator
+            typename: 'pluggable_modules.Originator'
+        -
+            config-section: hangup-monitor
+            typename: 'pluggable_modules.HangupMonitor'
+        -
+            config-section: ami-config
+            typename: 'pluggable_modules.EventActionModule'
+
+test-object-config:
+    connect-ami: True
+
+caller-originator:
+    channel: 'Local/s at default'
+    context: 'nothing'
+    exten: '0'
+    priority: '1'
+    trigger: 'ami_connect'
+
+hangup-monitor:
+    ids: '0'
+
+ami-config:
+    -
+        ami-events:
+            conditions:
+                match:
+                    Event: 'UserEvent'
+                    UserEvent: 'ReadSuccess'
+            requirements:
+                match:
+                    Result: 'Pass'
+            count: 9
+        stop_test:
+
+properties:
+    tags:
+        - dial
+        - apps
+    dependencies:
+        - python: 'twisted'
+        - python: 'starpy'
+        - asterisk: 'app_dial'
+        - asterisk: 'app_userevent'
+        - asterisk: 'app_originate'
+        - asterisk: 'app_read'
+        - asterisk: 'pbx_config'
diff --git a/tests/apps/tests.yaml b/tests/apps/tests.yaml
index 4f15191..92eb23f 100644
--- a/tests/apps/tests.yaml
+++ b/tests/apps/tests.yaml
@@ -26,4 +26,8 @@
     - dir: 'statsd'
     - test: 'waitdigit'
     - dir: 'sendtext'
+<<<<<<< HEAD   (e79e33 app_mf: Add tests for app_mf module)
     - test: 'mf'
+=======
+    - test: 'read'
+>>>>>>> CHANGE (5626f0 app_read: Add tests for Read application)

-- 
To view, visit https://gerrit.asterisk.org/c/testsuite/+/17697
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: testsuite
Gerrit-Branch: 16
Gerrit-Change-Id: I0c1e7c3b4f136ae673d955fd5ef7f848b88101f6
Gerrit-Change-Number: 17697
Gerrit-PatchSet: 1
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20211215/8588a654/attachment.html>


More information about the asterisk-code-review mailing list