[asterisk-commits] mjordan: testsuite/asterisk/trunk r4707 - in /asterisk/trunk/tests/pbx: ./ as...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Feb 15 22:11:59 CST 2014


Author: mjordan
Date: Sat Feb 15 22:11:57 2014
New Revision: 4707

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=4707
Log:
pbx/ast_db: Add tests for the DB family of functions

This test verifies that the following AstDB functions and variables work as
intended - DB, DB_RESULT, DB_EXISTS, DB_KEYS, DB_DELETE.

The first iteration tests input and output using DB(family/key) as well as
the DB_RESULT variable.

The second iteration tests DB_EXISTS(family/key) with a non-existant and
existant database, and also tests DB_KEYS(family) with a non-existant
database, a family with one key, and a family with multiple keys.

The last iteration tests DB_DELETE(family/key) on a non-existant database
and an existant database. If it is called when there is nothing to delete,
it will return an empty string.

Note that this patch was written by Ben Ford.

Review: https://reviewboard.asterisk.org/r/3220/

(closes issue ASTERISK-23187)


Added:
    asterisk/trunk/tests/pbx/ast_db/
    asterisk/trunk/tests/pbx/ast_db/configs/
    asterisk/trunk/tests/pbx/ast_db/configs/ast1/
    asterisk/trunk/tests/pbx/ast_db/configs/ast1/extensions.conf   (with props)
    asterisk/trunk/tests/pbx/ast_db/test-config.yaml   (with props)
Modified:
    asterisk/trunk/tests/pbx/tests.yaml

Added: asterisk/trunk/tests/pbx/ast_db/configs/ast1/extensions.conf
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/pbx/ast_db/configs/ast1/extensions.conf?view=auto&rev=4707
==============================================================================
--- asterisk/trunk/tests/pbx/ast_db/configs/ast1/extensions.conf (added)
+++ asterisk/trunk/tests/pbx/ast_db/configs/ast1/extensions.conf Sat Feb 15 22:11:57 2014
@@ -1,0 +1,55 @@
+; Tests the AstDB.
+
+[test]
+
+; ----------------------------------------------------------------------
+; Extension s1 tests the DB function and DB_RESULT channel variable.
+; ----------------------------------------------------------------------
+
+exten => s1,1,NoOp()
+    same => n,Answer()
+    same => n,Set(DB(test/count)=100)
+    same => n,ExecIf($[${DB(test/count)}=100&${DB_RESULT}=100]?UserEvent(Test1,result:pass))
+    same => n,Set(DB(test/count2)=200)
+    same => n,ExecIf($[${DB(test/count)}=100&${DB(test/count2)}=200]?UserEvent(Test1,result:pass))
+    same => n,Set(DB(test/count)=300)
+    same => n,ExecIf($[${DB(test/count)}=300]?UserEvent(Test1,result:pass))
+    same => n,Set(DB(othertest/count)=400)
+    same => n,ExecIf($[${DB(test/count)}=300&${DB(othertest/count)}=400]?UserEvent(Test1,result:pass))
+    same => n,Set(COUNT=${DB(notest/count)})
+    same => n,ExecIf($[${LEN(${COUNT})}=0]?UserEvent(Test1,result:pass))
+    same => n,Hangup()
+
+; ----------------------------------------------------------------------
+; Extension s2 tests the DB_EXISTS and DB_KEYS functions.
+; ----------------------------------------------------------------------
+
+exten => s2,1,NoOp()
+    same => n,Answer()
+    same => n,ExecIf($[${DB_EXISTS(thistest/count)}=0]?UserEvent(Test2,result:pass))
+    same => n,Set(KEY_LIST=${DB_KEYS(thistest)})
+    same => n,ExecIf($[${LEN(${KEY_LIST})}=0]?UserEvent(Test2,result:pass))
+    same => n,Set(DB(thistest/count)=100)
+    same => n,ExecIf($[${DB_EXISTS(thistest/count)}=1]?UserEvent(Test2,result:pass))
+    same => n,ExecIf($[${DB_RESULT}=100]?UserEvent(Test2,result:pass))
+    same => n,Set(KEY_LIST=${DB_KEYS(thistest)})
+    same => n,ExecIf($[${KEY_LIST}=count]?UserEvent(Test2,result:pass))
+    same => n,Set(DB(thistest/count2)=200)
+    same => n,Set(KEY_LIST=${DB_KEYS(thistest)})
+    same => n,ExecIf($[${KEY_LIST}=count,count2]?UserEvent(Test2,result:pass))
+    same => n,Hangup()
+
+; ----------------------------------------------------------------------
+; Extension s3 tests the DB_DELETE function.
+; ----------------------------------------------------------------------
+
+exten => s3,1,NoOp()
+    same => n,Answer()
+    same => n,Set(COUNT=${DB_DELETE(sometest/count)})
+    same => n,ExecIf($[${LEN(${COUNT})}=0]?UserEvent(Test3,result:pass))
+    same => n,Set(DB(sometest/count)=100)
+    same => n,Set(COUNT=${DB_DELETE(sometest/count)})
+    same => n,ExecIf($[${COUNT}=100&${DB_RESULT}=100]?UserEvent(Test3,result:pass))
+    same => n,Set(COUNT=${DB(sometest/count)})
+    same => n,ExecIf($[${LEN(${COUNT})}=0]?UserEvent(Test3,result:pass))
+    same => n,Hangup()

Propchange: asterisk/trunk/tests/pbx/ast_db/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/pbx/ast_db/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/pbx/ast_db/configs/ast1/extensions.conf
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: asterisk/trunk/tests/pbx/ast_db/test-config.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/pbx/ast_db/test-config.yaml?view=auto&rev=4707
==============================================================================
--- asterisk/trunk/tests/pbx/ast_db/test-config.yaml (added)
+++ asterisk/trunk/tests/pbx/ast_db/test-config.yaml Sat Feb 15 22:11:57 2014
@@ -1,0 +1,76 @@
+testinfo:
+    summary: 'Tests multiple AstDB functions.'
+    description:
+        This test verifies that the following AstDB functions and variables work
+        as intended - DB, DB_RESULT, DB_EXISTS, DB_KEYS, DB_DELETE.
+        The first iteration tests input and output using DB(family/key) as well
+        as the DB_RESULT variable.
+        The second iteration tests DB_EXISTS(family/key) with a non-existant and
+        existant database, and also tests DB_KEYS(family) with a non-existant
+        database, a family with one key, and a family with multiple keys.
+        The last iteration tests DB_DELETE(family/key) on a non-existant database and
+        an existant database. If it is called when there is nothing to delete, it will
+        return an empty string.
+
+test-modules:
+    test-object:
+        config-section: test-config
+        typename: 'test_case.SimpleTestCase'
+    modules:
+      -
+        config-section: 'ami-config'
+        typename: 'ami.AMIEventModule'
+
+test-config:
+  spawn-after-hangup: True
+  expected_events: 14
+  test-iterations:
+    -
+      channel: 'Local/s1 at test'
+      application: 'Echo'
+    -
+      channel: 'Local/s2 at test'
+      application: 'Echo'
+    -
+      channel: 'Local/s3 at test'
+      application: 'Echo'
+
+ami-config:
+  -
+    type: 'headermatch'
+    conditions:
+        match:
+            Event: 'UserEvent'
+            UserEvent: 'Test1'
+    requirements:
+        match:
+            Result: 'pass'
+    count: '5'
+  -
+    type: 'headermatch'
+    conditions:
+        match:
+            Event: 'UserEvent'
+            UserEvent: 'Test2'
+    requirements:
+        match:
+            Result: 'pass'
+    count: '6'
+  -
+    type: 'headermatch'
+    conditions:
+        match:
+            Event: 'UserEvent'
+            UserEvent: 'Test3'
+    requirements:
+        match:
+            Result: 'pass'
+    count: '3'
+
+properties:
+    minversion: '1.8.0.0'
+    dependencies:
+        - python : 'twisted'
+        - python : 'starpy'
+    tags:
+        - pbx

Propchange: asterisk/trunk/tests/pbx/ast_db/test-config.yaml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: asterisk/trunk/tests/pbx/ast_db/test-config.yaml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: asterisk/trunk/tests/pbx/ast_db/test-config.yaml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: asterisk/trunk/tests/pbx/tests.yaml
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/tests/pbx/tests.yaml?view=diff&rev=4707&r1=4706&r2=4707
==============================================================================
--- asterisk/trunk/tests/pbx/tests.yaml (original)
+++ asterisk/trunk/tests/pbx/tests.yaml Sat Feb 15 22:11:57 2014
@@ -1,5 +1,6 @@
 # Enter tests here in the order they should be considered for execution:
 tests:
+    - test: 'ast_db'
     - test: 'dialplan'
     - test: 'call-files'
     - test: 'callerid_match'




More information about the asterisk-commits mailing list