@@ -353,42 +353,50 @@ def validateList(inp):
353353 return ret
354354 return [PASS , inp [0 ], None ]
355355
356- def verifyElementInList (inp , toverify , pos = 0 ):
357- '''
358- @name: verifyElementInList
359- @Description:
360- 1. A utility function to validate
361- whether the input passed is a list.
362- The list is empty or not.
363- If it is list and not empty, verify
364- whether a given element is there in that list or not
365- at a given pos
366- @Input:
367- I : Input to be verified whether its a list or not
356+ def verifyElementInList (inp , toverify , responsevar = None , pos = 0 ):
357+ '''
358+ @name: verifyElementInList
359+ @Description:
360+ 1. A utility function to validate
361+ whether the input passed is a list.
362+ The list is empty or not.
363+ If it is list and not empty, verify
364+ whether a given element is there in that list or not
365+ at a given pos
366+ @Input:
367+ I : Input to be verified whether its a list or not
368368 II : Element to verify whether it exists in the list
369- III : Position in the list at which the input element to verify
370- default to 0
371- @output: List, containing [ Result,Reason ]
372- Ist Argument('Result') : FAIL : If it is not a list
373- If it is list but empty
374- PASS : If it is list and not empty
369+ III : variable name in response object to verify
370+ default to None, if None, we will verify for the complete
371+ first element EX: state of response object object
372+ IV : Position in the list at which the input element to verify
373+ default to 0
374+ @output: List, containing [ Result,Reason ]
375+ Ist Argument('Result') : FAIL : If it is not a list
376+ If it is list but empty
377+ PASS : If it is list and not empty
375378 and matching element was found
376- IIrd Argument( 'Reason' ): Reason for failure ( FAIL ),
377- default to None.
378- INVALID_INPUT
379- EMPTY_LIST
380- MATCH_NOT_FOUND
381- '''
382- if toverify is None or toverify == '' \
383- or pos is None or pos < - 1 or pos == '' :
384- return [FAIL , INVALID_INPUT ]
385- out = validateList (inp )
386- if out [0 ] == FAIL :
387- return [FAIL , out [2 ]]
388- if out [0 ] == PASS :
389- if len (inp ) > pos and inp [pos ] == toverify :
390- return [PASS , None ]
391- else :
392- return [FAIL , MATCH_NOT_FOUND ]
393-
379+ IIrd Argument( 'Reason' ): Reason for failure ( FAIL ),
380+ default to None.
381+ INVALID_INPUT
382+ EMPTY_LIST
383+ MATCH_NOT_FOUND
384+ '''
385+ if toverify is None or toverify == '' \
386+ or pos is None or pos < - 1 or pos == '' :
387+ return [FAIL , INVALID_INPUT ]
388+ out = validateList (inp )
389+ if out [0 ] == FAIL :
390+ return [FAIL , out [2 ]]
391+ if len (inp ) > pos :
392+ if responsevar is None :
393+ if inp [pos ] == toverify :
394+ return [PASS , None ]
395+ else :
396+ if responsevar in inp [pos ].__dict__ and getattr (inp [pos ], responsevar ) == toverify :
397+ return [PASS , None ]
398+ else :
399+ return [FAIL , MATCH_NOT_FOUND ]
400+ else :
401+ return [FAIL , MATCH_NOT_FOUND ]
394402
0 commit comments