cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gir...@apache.org
Subject git commit: updated refs/heads/master to 58cd71f
Date Fri, 01 Nov 2013 11:25:48 GMT
Updated Branches:
  refs/heads/master 47641637f -> 58cd71f5c


Added a verifyElementInList utility function

The purpose is to verify a given element in list
at a given position with few error checks like
list type,empty list and position
Returns appropriate codes based upon the inputs.
Can be used under tests instead of multiple asserts

Signed-off-by: Santhosh Edukulla <Santhosh.Edukulla@citrix.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/58cd71f5
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/58cd71f5
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/58cd71f5

Branch: refs/heads/master
Commit: 58cd71f5c1ff3962827e166e8e0a5aca5a928818
Parents: 4764163
Author: Santhosh Edukulla <Santhosh.Edukulla@citrix.com>
Authored: Fri Nov 1 16:55:07 2013 +0530
Committer: Girish Shilamkar <girish@clogeny.com>
Committed: Fri Nov 1 16:55:07 2013 +0530

----------------------------------------------------------------------
 tools/marvin/marvin/codes.py                 |  1 +
 tools/marvin/marvin/integration/lib/utils.py | 40 +++++++++++++++++++++++
 2 files changed, 41 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/58cd71f5/tools/marvin/marvin/codes.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/codes.py b/tools/marvin/marvin/codes.py
index bd01ad3..b6580d0 100644
--- a/tools/marvin/marvin/codes.py
+++ b/tools/marvin/marvin/codes.py
@@ -39,3 +39,4 @@ INVALID_INPUT = "INVALID INPUT"
 EMPTY_LIST = "EMPTY_LIST"
 FAIL = 0
 PASS = 1
+MATCH_NOT_FOUND = "ELEMENT NOT FOUND IN THE INPUT"

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/58cd71f5/tools/marvin/marvin/integration/lib/utils.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/utils.py b/tools/marvin/marvin/integration/lib/utils.py
index b6e38ec..d53c1ae 100644
--- a/tools/marvin/marvin/integration/lib/utils.py
+++ b/tools/marvin/marvin/integration/lib/utils.py
@@ -353,3 +353,43 @@ def validateList(inp):
             ret[2] = EMPTY_LIST
             return ret
         return [PASS, inp[0], None]
+
+def verifyElementInList(inp, toverify, pos = 0):
+       '''
+       @name: verifyElementInList
+       @Description: 
+              1. A utility function to validate
+                 whether the input passed is a list.
+                 The list is empty or not.
+                 If it is list and not empty, verify
+                 whether a given element is there in that list or not
+                 at a given pos  
+       @Input: 
+              I  : Input to be verified whether its a list or not
+             II  : Element to verify whether it exists in the list 
+             III : Position in the list at which the input element to verify
+                    default to 0
+       @output: List, containing [ Result,Reason ]
+                Ist Argument('Result') : FAIL : If it is not a list
+                                          If it is list but empty
+                                          PASS : If it is list and not empty
+                                              and matching element was found
+                IIrd Argument( 'Reason' ): Reason for failure ( FAIL ),
+                                            default to None.
+                                            INVALID_INPUT
+                                            EMPTY_LIST
+                                            MATCH_NOT_FOUND
+       '''
+       if toverify is None or toverify == '' \
+           or pos is None or pos < -1 or pos == '':
+           return [FAIL, INVALID_INPUT]
+       out = validateList(inp)
+       if out[0] == FAIL:
+           return [FAIL, out[2]]
+       if out[0] == PASS:
+           if len(inp) > pos and inp[pos] == toverify:
+               return [PASS, None]
+           else:
+               return [FAIL, MATCH_NOT_FOUND]
+
+


Mime
View raw message