You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by gi...@apache.org on 2013/11/08 09:13:31 UTC
git commit: updated refs/heads/4.2 to b18e730
Updated Branches:
refs/heads/4.2 e7b6ee10e -> b18e73010
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 <Sa...@citrix.com>
Conflicts:
tools/marvin/marvin/codes.py
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/b18e7301
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/b18e7301
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/b18e7301
Branch: refs/heads/4.2
Commit: b18e730108e6a24e00c372e3c56c655ff51106ba
Parents: e7b6ee1
Author: Santhosh Edukulla <Sa...@citrix.com>
Authored: Fri Nov 1 16:55:07 2013 +0530
Committer: Girish Shilamkar <gi...@clogeny.com>
Committed: Fri Nov 8 13:42:19 2013 +0530
----------------------------------------------------------------------
tools/marvin/marvin/codes.py | 5 +++
tools/marvin/marvin/integration/lib/utils.py | 40 +++++++++++++++++++++++
2 files changed, 45 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b18e7301/tools/marvin/marvin/codes.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/codes.py b/tools/marvin/marvin/codes.py
index ad4f17f..3fe7b74 100644
--- a/tools/marvin/marvin/codes.py
+++ b/tools/marvin/marvin/codes.py
@@ -35,3 +35,8 @@ RECURRING = "RECURRING"
ENABLED = "Enabled"
NETWORK_OFFERING = "network_offering"
ROOT = "ROOT"
+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/b18e7301/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 8a1ebbd..a8d676c 100644
--- a/tools/marvin/marvin/integration/lib/utils.py
+++ b/tools/marvin/marvin/integration/lib/utils.py
@@ -351,3 +351,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]
+
+