[asterisk-commits] tests/cdr/cdr manipulation: Add a test for the CDR dialplan ... (testsuite[master])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jan 21 07:19:46 CST 2016


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

Change subject: tests/cdr/cdr_manipulation: Add a test for the CDR dialplan function
......................................................................


tests/cdr/cdr_manipulation: Add a test for the CDR dialplan function

This patch adds a test that covers the CDR dialplan function. The test
spawns a Local channel, sets some properties on the CDR via the dialplan
function, then hangs up the channel. Logic in the 'h' extension then validates
that the CDR contains the expected attributes.

ASTERISK-25179

Change-Id: I44aacc8ee23524dc8c01e175cc4611ae23388394
---
A tests/cdr/cdr_manipulation/func_cdr/configs/ast1/extensions.conf
A tests/cdr/cdr_manipulation/func_cdr/test-config.yaml
M tests/cdr/cdr_manipulation/tests.yaml
3 files changed, 98 insertions(+), 1 deletion(-)

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



diff --git a/tests/cdr/cdr_manipulation/func_cdr/configs/ast1/extensions.conf b/tests/cdr/cdr_manipulation/func_cdr/configs/ast1/extensions.conf
new file mode 100644
index 0000000..47e3c4e
--- /dev/null
+++ b/tests/cdr/cdr_manipulation/func_cdr/configs/ast1/extensions.conf
@@ -0,0 +1,56 @@
+[default]
+
+exten => validate_cdr_value,1,NoOp()
+ same => n,ExecIf($[${ISNULL(${ARG4})}]?Set(actual=${CDR(${ARG1})}):Set(actual=${CDR(${ARG1},${ARG4})}))
+ same => n,GoSub(default,${ARG3},1(${ARG2},${actual}))
+ same => n,ExecIf($[${GOSUB_RETVAL}=0]?UserEvent(Failure,Field: ${ARG1},Test: ${ARG3},Expected: ${ARG2},Actual: ${actual}))
+ same => n,Return()
+
+exten => test_equals,1,NoOp()
+ same => n,ExecIf($["${ARG1}"="${ARG2}"]?Return(1):Return(0))
+
+exten => test_not_null,1,NoOp()
+ same => n,ExecIf($[${ISNULL(${ARG2})}]?Return(0):Return(1))
+
+exten => test_fp_not_zero,1,NoOp()
+ same => n,Set(integer=${CUT(ARG2,".",1)})
+ same => n,Set(fractional=${CUT(ARG2,".",2)})
+ same => n,ExecIf($["${integer}"="0" || ${ISNULL(${integer})}]?Return(0))
+ same => n,ExecIf($["${fractional}"="000000" || ${ISNULL(${fractional})}]?Return(0))
+ same => n,Return(1)
+
+exten => s,1,NoOp()
+ same => n,Set(CALLERID(name)=Alice)
+ same => n,Set(CALLERID(num)=8005551234)
+ same => n,Set(CDR(foo)=bar)
+ same => n,Set(CDR(userfield)=test)
+ same => n,Wait(1)
+ same => n,Answer()
+ same => n,Wait(1)
+ same => n,Hangup()
+
+exten => h,1,NoOp()
+ same => n,GoSub(default,validate_cdr_value,1(lastdata,,test_equals))
+ same => n,GoSub(default,validate_cdr_value,1(disposition,ANSWERED,test_equals))
+ same => n,GoSub(default,validate_cdr_value,1(src,8005551234,test_equals))
+ same => n,GoSub(default,validate_cdr_value,1(start,,test_not_null))
+ same => n,GoSub(default,validate_cdr_value,1(start,,test_fp_not_zero,u))
+ same => n,GoSub(default,validate_cdr_value,1(dst,s,test_equals))
+ same => n,GoSub(default,validate_cdr_value,1(answer,,test_not_null))
+ same => n,GoSub(default,validate_cdr_value,1(answer,,test_fp_not_zero,u))
+ same => n,GoSub(default,validate_cdr_value,1(dcontext,default,test_equals))
+ same => n,GoSub(default,validate_cdr_value,1(end,,test_not_null))
+ same => n,GoSub(default,validate_cdr_value,1(end,,test_fp_not_zero,u))
+ same => n,GoSub(default,validate_cdr_value,1(uniqueid,,test_not_null))
+ same => n,GoSub(default,validate_cdr_value,1(dstchannel,,test_equals))
+ same => n,GoSub(default,validate_cdr_value,1(duration,,test_not_null))
+ same => n,GoSub(default,validate_cdr_value,1(duration,,test_fp_not_zero,f))
+ same => n,GoSub(default,validate_cdr_value,1(userfield,test,test_equals))
+ same => n,GoSub(default,validate_cdr_value,1(lastapp,Hangup,test_equals))
+ same => n,GoSub(default,validate_cdr_value,1(billsec,,test_not_null))
+ same => n,GoSub(default,validate_cdr_value,1(billsec,,test_fp_not_zero,f))
+ same => n,GoSub(default,validate_cdr_value,1(channel,,test_not_null))
+ same => n,GoSub(default,validate_cdr_value,1(sequence,1,test_equals))
+ same => n,GoSub(default,validate_cdr_value,1(foo,bar,test_equals))
+ same => n,Set(CDR(foo)=not_bar)
+ same => n,GoSub(default,validate_cdr_value,1(foo,not_bar,test_equals))
diff --git a/tests/cdr/cdr_manipulation/func_cdr/test-config.yaml b/tests/cdr/cdr_manipulation/func_cdr/test-config.yaml
new file mode 100644
index 0000000..ee2b4d3
--- /dev/null
+++ b/tests/cdr/cdr_manipulation/func_cdr/test-config.yaml
@@ -0,0 +1,41 @@
+testinfo:
+    summary: 'Test the CDR dialplan function'
+    description: |
+        'This test generates a CDR, and then uses the CDR
+        dialplan function to verify attributes on the CDR.'
+
+test-modules:
+    test-object:
+        config-section: test-object-config
+        typename: 'test_case.SimpleTestCase'
+    modules:
+        -
+            config-section: ami-config
+            typename: 'ami.AMIEventModule'
+
+test-object-config:
+    config-path: 'tests/cdr/configs/basic'
+    spawn-after-hangup: True
+    expected_events: 0
+    test-iterations:
+        -
+            channel: 'Local/s at default'
+            application: 'Echo'
+
+ami-config:
+    -
+        type: 'headermatch'
+        conditions:
+            match:
+                Event: 'UserEvent'
+        count: '0'
+
+properties:
+    minversion: '13.8.0'
+    dependencies:
+        - python: 'twisted'
+        - python: 'starpy'
+        - asterisk: 'app_echo'
+        - asterisk: 'func_cdr'
+    tags:
+        - CDR
diff --git a/tests/cdr/cdr_manipulation/tests.yaml b/tests/cdr/cdr_manipulation/tests.yaml
index 1da5f1d..46a74bd 100644
--- a/tests/cdr/cdr_manipulation/tests.yaml
+++ b/tests/cdr/cdr_manipulation/tests.yaml
@@ -5,4 +5,4 @@
     - test: 'cdr_fork_end_time'
     - test: 'nocdr'
     - test: 'cdr_prop_disable'
-
+    - test: 'func_cdr'

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I44aacc8ee23524dc8c01e175cc4611ae23388394
Gerrit-PatchSet: 1
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>



More information about the asterisk-commits mailing list