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/4.2 to c76da53
Date Fri, 08 Nov 2013 10:07:58 GMT
Updated Branches:
  refs/heads/4.2 87983e09e -> c76da5312


CLOUDSTACK-5032 Provides custom assert facility to test features

Added assertElementInList to cloudstackTestCase.
Users can use this new custom addition to add
assertions, thus replacing current multiple assertions

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/c76da531
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c76da531
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c76da531

Branch: refs/heads/4.2
Commit: c76da53123f4130ac59bdf112171bc2e39af91d4
Parents: 87983e0
Author: Santhosh Edukulla <Santhosh.Edukulla@citrix.com>
Authored: Tue Nov 5 03:16:24 2013 +0530
Committer: Girish Shilamkar <girish@clogeny.com>
Committed: Fri Nov 8 15:37:26 2013 +0530

----------------------------------------------------------------------
 tools/marvin/marvin/cloudstackTestCase.py    | 14 ++++
 tools/marvin/marvin/integration/lib/utils.py | 80 +++++++++++++----------
 2 files changed, 58 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c76da531/tools/marvin/marvin/cloudstackTestCase.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/cloudstackTestCase.py b/tools/marvin/marvin/cloudstackTestCase.py
index 85ef542..6456bb1 100644
--- a/tools/marvin/marvin/cloudstackTestCase.py
+++ b/tools/marvin/marvin/cloudstackTestCase.py
@@ -16,6 +16,8 @@
 # under the License.
 
 import unittest
+from marvin.integration.lib.utils import verifyElementInList
+from marvin.codes import PASS
 
 
 def user(Name, DomainName, AcctType):
@@ -35,6 +37,18 @@ def user(Name, DomainName, AcctType):
 class cloudstackTestCase(unittest.case.TestCase):
     clstestclient = None
 
+    def assertElementInList(inp, toverify, responsevar=None,  pos=0,
+                            assertmsg="TC Failed for reason"):
+        '''
+        @Name: assertElementInList
+        @desc:Uses the utility function verifyElementInList and
+        asserts based upon PASS\FAIL value of the output.
+        Takes one additional argument of what message to assert with
+        when failed
+        '''
+        out = verifyElementInList(inp, toverify, responsevar,  pos)
+        unittest.TestCase.assertEquals(out[0], PASS, "msg:%s" % out[1])
+
     @classmethod
     def getClsTestClient(cls):
         return cls.clstestclient

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c76da531/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 bd22fa6..cf2dd3c 100644
--- a/tools/marvin/marvin/integration/lib/utils.py
+++ b/tools/marvin/marvin/integration/lib/utils.py
@@ -353,42 +353,50 @@ def validateList(inp):
         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
+def verifyElementInList(inp, toverify, responsevar=None,  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
+             III : variable name in response object to verify 
+                   default to None, if None, we will verify for the complete 
+                   first element EX: state of response object object
+             IV  : 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]
-
+             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 len(inp) > pos:
+        if responsevar is None:
+                if inp[pos] == toverify:
+                    return [PASS, None]
+        else:
+                if responsevar in inp[pos].__dict__ and getattr(inp[pos], responsevar) ==
toverify:
+                    return [PASS, None]
+                else:
+                    return [FAIL, MATCH_NOT_FOUND]
+    else:
+        return [FAIL, MATCH_NOT_FOUND]
 


Mime
View raw message