Skip to content

Commit 109e3bb

Browse files
InterLinked1Friendly Automation
authored and
Friendly Automation
committed
func_evalexten: Add tests for EVAL_EXTEN function
Adds tests for the new EVAL_EXTEN function to ensure that it functions correctly. Additionally, this tests the refactoring of some code into pbx_parse_location (new public API) to ensure that parsing is done properly, as this is required by both EVAL_EXTEN and the PBX core. pbx_substitute_variables_helper_full_location is also tested by this test suite. ASTERISK-29486 Change-Id: Ib12fde79e06c3c02b1303ba09fabb21f75b12f5a
1 parent 03a1923 commit 109e3bb

File tree

3 files changed

+115
-0
lines changed

3 files changed

+115
-0
lines changed
+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
2+
[default]
3+
exten => s,1,Answer()
4+
same => n,Set(GLOBAL(evalexten)=isreallycool)
5+
same => n,Set(i=0)
6+
same => n,While($[${INC(i)}<=11])
7+
same => n,Originate(Local/${i}@evalexten,app,Wait,5,,,a)
8+
same => n,EndWhile()
9+
same => n,Hangup()
10+
11+
[nothing]
12+
exten => 0,1,Answer()
13+
same => n,Wait(10)
14+
same => n,Hangup()
15+
16+
[evalexten]
17+
exten => success,1,UserEvent(EvalExtenSuccess,Result: Pass)
18+
same => n,Hangup()
19+
exten => fail,1,UserEvent(EvalExtenFailure,Result: Fail ${RECEIVESFSTATUS} ${digits},Reason: ${digits})
20+
same => n,Hangup()
21+
exten => 1,1,GotoIf($["${EVAL_EXTEN(ee-context-1,${EPOCH},1)}"="4545"]?success,1:fail,1) ; make sure evaluated extension is argument, not current dialplan extension
22+
exten => 2,1,GotoIf($["${EVAL_EXTEN(ee-context-2,${EPOCH},1)}"=""]?success,1:fail,1) ; non-existent evaluation extension
23+
exten => 3,1,GotoIf($[${EVAL_EXTEN(ee-context-3,${EXTEN},1)}>${EPOCH}]?success,1:fail,1) ; ensure variable substitution occurs correctly
24+
exten => 4,1,GotoIf($[${EVAL_EXTEN(ee-context-4,212,1)}=200]?success,1:fail,1) ; ensure pattern matching works correctly
25+
exten => 5,1,GotoIf($[${EVAL_EXTEN(ee-context-4,312,1)}=300]?success,1:fail,1) ; ensure pattern matching works correctly
26+
exten => 6,1,GotoIf($[${EVAL_EXTEN(ee-context-4,332,1)}=330]?success,1:fail,1) ; ensure pattern matching works correctly
27+
exten => 7,1,GotoIf($["${EVAL_EXTEN(ee-context-4,332,2)}"="isreallycool"]?success,1:fail,1) ; ensure non-1 priorities work correctly
28+
exten => 8,1,GotoIf($[${EVAL_EXTEN(100,1)}=50]?success,1:fail,1) ; implicit context
29+
exten => 9,1,GotoIf($[${EVAL_EXTEN(2)}=60]?success,1:fail,1) ; implicit context and extension
30+
same => n,Return(60)
31+
exten => 10,1,GotoIf($["${EVAL_EXTEN(ee-context-5,353,1)}"="353"]?success,1:fail,1) ; EXTEN evaluation
32+
exten => 11,1,GotoIf($["${EVAL_EXTEN(ee-context-5,354,1)}"="1"]?success,1:fail,1) ; EXTEN evaluation
33+
exten => 100,1,Return(50)
34+
35+
[ee-context-1]
36+
exten => 1,1,Return(0)
37+
exten => _X!,1,Return(4545)
38+
39+
[ee-context-2]
40+
exten => 0,1,Return(4545)
41+
42+
[ee-context-3]
43+
exten => 1,1,Return(${EPOCH})
44+
exten => 2,1,Return($[${EPOCH}+1])
45+
exten => 3,1,Return($[${EPOCH}+2])
46+
47+
[ee-context-4]
48+
exten => _2XX,1,Return(200)
49+
exten => _3XX,1,Return(300)
50+
exten => _33X,1,Return(330)
51+
same => n,Return(${evalexten})
52+
53+
[ee-context-5]
54+
exten => 353,1,Return(${EXTEN})
55+
exten => 354,1,Return($["${EXTEN}"="354"])

Diff for: tests/funcs/func_evalexten/test-config.yaml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
testinfo:
2+
summary: 'Ensure that func_evalexten functions correctly.'
3+
description: |
4+
'This tests the EVAL_EXTEN function to ensure it properly
5+
evaluates in different scenarios.'
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: 'EvalExtenSuccess'
42+
requirements:
43+
match:
44+
Result: 'Pass'
45+
count: 11
46+
stop_test:
47+
48+
properties:
49+
tags:
50+
- dial
51+
- funcs
52+
dependencies:
53+
- python: 'twisted'
54+
- python: 'starpy'
55+
- asterisk: 'app_dial'
56+
- asterisk: 'app_userevent'
57+
- asterisk: 'app_originate'
58+
- asterisk: 'func_evalexten'
59+
- asterisk: 'pbx_config'

Diff for: tests/funcs/tests.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ tests:
77
- test: 'func_push'
88
- test: 'func_srv'
99
- test: 'func_talkdetect'
10+
- test: 'func_evalexten'

0 commit comments

Comments
 (0)