@@ -212,7 +212,23 @@ def copyTCnewTestCase(self, origTestCaseId, origVersion=None, **changedAttribute
212
212
return self ._copyTC (origTestCaseId , changedAttributes , origVersion ,
213
213
duplicateaction = 'generate_new' )
214
214
215
-
215
+ def getTestCaseByVersion (self , testCaseID , version = None ):
216
+ """
217
+ Gets testcase information based on the version.
218
+
219
+ :param testCaseID: test case to search for
220
+ :param version: version to search for defaults to None. None searches for latest
221
+ :return: test case info dictionary
222
+ """
223
+ testcases = self .getTestCase (testCaseID , version = version )
224
+ if version is None :
225
+ return testcases [0 ]
226
+ for testcase in testcases :
227
+ if str (testcase ['version' ]) == str (version ):
228
+ return testcase
229
+ else :
230
+ raise RuntimeError ("Testcase {} doesn't have version {}." .format (testCaseID , version ))
231
+
216
232
def _copyTC (self , origTestCaseId , changedArgs , origVersion = None , ** options ):
217
233
""" creates a copy of test case with id ORIGTESTCASEID
218
234
@@ -237,7 +253,7 @@ def _copyTC(self, origTestCaseId, changedArgs, origVersion=None, **options):
237
253
"""
238
254
239
255
# get orig test case content
240
- origArgItems = self .getTestCase (origTestCaseId , version = origVersion )[ 0 ]
256
+ origArgItems = self .getTestCaseByVersion (origTestCaseId , version = origVersion )
241
257
# get orig test case project id
242
258
origArgItems ['testprojectid' ] = self .getProjectIDByNode (origTestCaseId )
243
259
0 commit comments