[asterisk-commits] func_evalexten: Add tests for EVAL_EXTEN function (testsuite[16])
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Apr 28 15:44:21 CDT 2022
Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/testsuite/+/17937 )
Change subject: func_evalexten: Add tests for EVAL_EXTEN function
......................................................................
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
---
A tests/funcs/func_evalexten/configs/ast1/extensions.conf
A tests/funcs/func_evalexten/test-config.yaml
M tests/funcs/tests.yaml
3 files changed, 115 insertions(+), 0 deletions(-)
Approvals:
Joshua Colp: Looks good to me, but someone else must approve
Kevin Harwell: Looks good to me, approved
Benjamin Keith Ford: Looks good to me, but someone else must approve
Friendly Automation: Approved for Submit
diff --git a/tests/funcs/func_evalexten/configs/ast1/extensions.conf b/tests/funcs/func_evalexten/configs/ast1/extensions.conf
new file mode 100644
index 0000000..6f64c4e
--- /dev/null
+++ b/tests/funcs/func_evalexten/configs/ast1/extensions.conf
@@ -0,0 +1,55 @@
+
+[default]
+exten => s,1,Answer()
+ same => n,Set(GLOBAL(evalexten)=isreallycool)
+ same => n,Set(i=0)
+ same => n,While($[${INC(i)}<=11])
+ same => n,Originate(Local/${i}@evalexten,app,Wait,5,,,a)
+ same => n,EndWhile()
+ same => n,Hangup()
+
+[nothing]
+exten => 0,1,Answer()
+ same => n,Wait(10)
+ same => n,Hangup()
+
+[evalexten]
+exten => success,1,UserEvent(EvalExtenSuccess,Result: Pass)
+ same => n,Hangup()
+exten => fail,1,UserEvent(EvalExtenFailure,Result: Fail ${RECEIVESFSTATUS} ${digits},Reason: ${digits})
+ same => n,Hangup()
+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
+exten => 2,1,GotoIf($["${EVAL_EXTEN(ee-context-2,${EPOCH},1)}"=""]?success,1:fail,1) ; non-existent evaluation extension
+exten => 3,1,GotoIf($[${EVAL_EXTEN(ee-context-3,${EXTEN},1)}>${EPOCH}]?success,1:fail,1) ; ensure variable substitution occurs correctly
+exten => 4,1,GotoIf($[${EVAL_EXTEN(ee-context-4,212,1)}=200]?success,1:fail,1) ; ensure pattern matching works correctly
+exten => 5,1,GotoIf($[${EVAL_EXTEN(ee-context-4,312,1)}=300]?success,1:fail,1) ; ensure pattern matching works correctly
+exten => 6,1,GotoIf($[${EVAL_EXTEN(ee-context-4,332,1)}=330]?success,1:fail,1) ; ensure pattern matching works correctly
+exten => 7,1,GotoIf($["${EVAL_EXTEN(ee-context-4,332,2)}"="isreallycool"]?success,1:fail,1) ; ensure non-1 priorities work correctly
+exten => 8,1,GotoIf($[${EVAL_EXTEN(100,1)}=50]?success,1:fail,1) ; implicit context
+exten => 9,1,GotoIf($[${EVAL_EXTEN(2)}=60]?success,1:fail,1) ; implicit context and extension
+ same => n,Return(60)
+exten => 10,1,GotoIf($["${EVAL_EXTEN(ee-context-5,353,1)}"="353"]?success,1:fail,1) ; EXTEN evaluation
+exten => 11,1,GotoIf($["${EVAL_EXTEN(ee-context-5,354,1)}"="1"]?success,1:fail,1) ; EXTEN evaluation
+exten => 100,1,Return(50)
+
+[ee-context-1]
+exten => 1,1,Return(0)
+exten => _X!,1,Return(4545)
+
+[ee-context-2]
+exten => 0,1,Return(4545)
+
+[ee-context-3]
+exten => 1,1,Return(${EPOCH})
+exten => 2,1,Return($[${EPOCH}+1])
+exten => 3,1,Return($[${EPOCH}+2])
+
+[ee-context-4]
+exten => _2XX,1,Return(200)
+exten => _3XX,1,Return(300)
+exten => _33X,1,Return(330)
+ same => n,Return(${evalexten})
+
+[ee-context-5]
+exten => 353,1,Return(${EXTEN})
+exten => 354,1,Return($["${EXTEN}"="354"])
diff --git a/tests/funcs/func_evalexten/test-config.yaml b/tests/funcs/func_evalexten/test-config.yaml
new file mode 100644
index 0000000..db26e2d
--- /dev/null
+++ b/tests/funcs/func_evalexten/test-config.yaml
@@ -0,0 +1,59 @@
+testinfo:
+ summary: 'Ensure that func_evalexten functions correctly.'
+ description: |
+ 'This tests the EVAL_EXTEN function to ensure it properly
+ evaluates in different scenarios.'
+
+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: 'EvalExtenSuccess'
+ requirements:
+ match:
+ Result: 'Pass'
+ count: 11
+ stop_test:
+
+properties:
+ tags:
+ - dial
+ - funcs
+ dependencies:
+ - python: 'twisted'
+ - python: 'starpy'
+ - asterisk: 'app_dial'
+ - asterisk: 'app_userevent'
+ - asterisk: 'app_originate'
+ - asterisk: 'func_evalexten'
+ - asterisk: 'pbx_config'
diff --git a/tests/funcs/tests.yaml b/tests/funcs/tests.yaml
index ff99541..9994168 100644
--- a/tests/funcs/tests.yaml
+++ b/tests/funcs/tests.yaml
@@ -7,3 +7,4 @@
- test: 'func_push'
- test: 'func_srv'
- test: 'func_talkdetect'
+ - test: 'func_evalexten'
--
To view, visit https://gerrit.asterisk.org/c/testsuite/+/17937
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: testsuite
Gerrit-Branch: 16
Gerrit-Change-Id: Ib12fde79e06c3c02b1303ba09fabb21f75b12f5a
Gerrit-Change-Number: 17937
Gerrit-PatchSet: 2
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-commits/attachments/20220428/59443013/attachment.html>
More information about the asterisk-commits
mailing list