Skip to content

Commit 6d70318

Browse files
InterLinked1gtjoseph
authored andcommitted
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
1 parent 4b6370a commit 6d70318

File tree

3 files changed

+119
-0
lines changed

3 files changed

+119
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
2+
[default]
3+
exten => s,1,Answer()
4+
same => n,Set(GLOBAL(senddtmf1)=*123#DB)
5+
same => n,Set(GLOBAL(senddtmf2)=*123A#2#DB)
6+
same => n,Set(GLOBAL(senddtmf3)=**123#DC)
7+
same => n,Set(GLOBAL(senddtmf4)=*1254*123#DD)
8+
same => n,Set(GLOBAL(senddtmf5)=*009)
9+
same => n,Set(GLOBAL(senddtmf6)=*009####)
10+
same => n,Set(GLOBAL(senddtmf7)=1234#56)
11+
same => n,Set(GLOBAL(senddtmf8)=1234#56)
12+
same => n,Set(GLOBAL(senddtmf9)=9876#56)
13+
same => n,Set(i=0)
14+
same => n,While($[${INC(i)}<=9])
15+
same => n,Originate(Local/${i}@send-dtmf,exten,read-dtmf,${i},1,,a)
16+
same => n,EndWhile()
17+
same => n,Hangup()
18+
19+
[nothing]
20+
exten => 0,1,Answer()
21+
same => n,Wait(8)
22+
same => n,Hangup()
23+
24+
[send-dtmf]
25+
exten => _X!,1,Answer(0.5)
26+
same => n,SendDTMF(${senddtmf${EXTEN}})
27+
same => n,Wait(15) ; needed so Read has time to finish.
28+
same => n,Hangup()
29+
30+
[read-dtmf]
31+
exten => _[1-4],1,Answer()
32+
same => n,Set(TIMEOUT(response)=3)
33+
same => n,Read(digits,,,t(D))
34+
same => n,GotoIf($["${digits}"="${senddtmf${EXTEN}:0:-2}"]?success,1:fail,1)
35+
exten => 5,1,Answer()
36+
same => n,Set(TIMEOUT(response)=3)
37+
same => n,Read(digits) ; normal
38+
same => n,GotoIf($["${digits}"="*009"]?success,1:fail,1)
39+
exten => 6,1,Answer()
40+
same => n,Set(TIMEOUT(response)=3)
41+
same => n,Read(digits,,8,t) ; no terminator at all
42+
same => n,GotoIf($["${digits}"="*009####"]?success,1:fail,1)
43+
exten => 7,1,Answer()
44+
same => n,Set(TIMEOUT(response)=3)
45+
same => n,Read(digits,dial,,it(#))
46+
same => n,GotoIf($["${digits}"="${senddtmf${EXTEN}:0:-3}"]?success,1:fail,1)
47+
exten => 8,1,Answer()
48+
same => n,Set(TIMEOUT(response)=3)
49+
same => n,Read(digits,dial,7,it)
50+
same => n,GotoIf($["${digits}"="${senddtmf${EXTEN}}"]?success,1:fail,1)
51+
exten => 9,1,Answer()
52+
same => n,Read(digits,dial,,i)
53+
same => n,GotoIf($["${digits}"="${senddtmf${EXTEN}:0:4}"]?success,1:fail,1)
54+
exten => success,1,Answer(1)
55+
same => n,UserEvent(ReadSuccess,Result: Pass)
56+
same => n,Hangup()
57+
exten => fail,1,Answer(1)
58+
same => n,UserEvent(ReadFailure,Result: Fail ${digits},Reason: ${digits})
59+
same => n,Hangup()

tests/apps/read/test-config.yaml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
testinfo:
2+
summary: 'Ensure that app_read options work correctly.'
3+
description: |
4+
'This tests options in the Read application to
5+
ensure that it functions correctly.'
6+
7+
test-modules:
8+
test-object:
9+
config-section: test-object-config
10+
typename: 'test_case.TestCaseModule'
11+
modules:
12+
-
13+
config-section: caller-originator
14+
typename: 'pluggable_modules.Originator'
15+
-
16+
config-section: hangup-monitor
17+
typename: 'pluggable_modules.HangupMonitor'
18+
-
19+
config-section: ami-config
20+
typename: 'pluggable_modules.EventActionModule'
21+
22+
test-object-config:
23+
connect-ami: True
24+
25+
caller-originator:
26+
channel: 'Local/s@default'
27+
context: 'nothing'
28+
exten: '0'
29+
priority: '1'
30+
trigger: 'ami_connect'
31+
32+
hangup-monitor:
33+
ids: '0'
34+
35+
ami-config:
36+
-
37+
ami-events:
38+
conditions:
39+
match:
40+
Event: 'UserEvent'
41+
UserEvent: 'ReadSuccess'
42+
requirements:
43+
match:
44+
Result: 'Pass'
45+
count: 9
46+
stop_test:
47+
48+
properties:
49+
tags:
50+
- dial
51+
- apps
52+
dependencies:
53+
- python: 'twisted'
54+
- python: 'starpy'
55+
- asterisk: 'app_dial'
56+
- asterisk: 'app_userevent'
57+
- asterisk: 'app_originate'
58+
- asterisk: 'app_read'
59+
- asterisk: 'pbx_config'

tests/apps/tests.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ tests:
2727
- test: 'waitdigit'
2828
- dir: 'sendtext'
2929
- test: 'mf'
30+
- test: 'read'

0 commit comments

Comments
 (0)