Skip to content

Commit 41a2f5c

Browse files
author
Luiko Czub
committed
server call methods shifted to generic API lczub#7
getTestSuitesForTestPlan, getTestSuiteByID, getTestSuitesForTestSuite, getFirstLevelTestSuitesForTestProject, getTestCasesForTestSuite
1 parent 2de35be commit 41a2f5c

7 files changed

Lines changed: 215 additions & 126 deletions

example/TestLinkExample.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,11 @@
170170
# print "Error creating the Test Suite '%s': %s " % (NEWTESTSUITE_A, isOk)
171171
# sys.exit(-1)
172172
print "createTestSuite", newTestSuite
173-
newTestSuiteID = newTestSuite[0]['id']
174-
print "New Test Suite '%s' - id: %s" % (NEWTESTSUITE_A, newTestSuiteID)
173+
newTestSuiteID_A = newTestSuite[0]['id']
174+
print "New Test Suite '%s' - id: %s" % (NEWTESTSUITE_A, newTestSuiteID_A)
175175
# -- END CHANGE v0.4.5 --
176176

177-
FirstLevelID = newTestSuiteID
177+
FirstLevelID = newTestSuiteID_A
178178

179179
#Creates the test Suite B
180180
newTestSuite = myTestLink.createTestSuite(newProjectID, NEWTESTSUITE_B,
@@ -188,8 +188,8 @@
188188
# print "Error creating the Test Suite '%s': %s " % (NEWTESTSUITE_B, isOk)
189189
# sys.exit(-1)
190190
print "createTestSuite", newTestSuite
191-
TestSuiteID_B = newTestSuite[0]['id']
192-
print "New Test Suite '%s' - id: %s" % (NEWTESTSUITE_B, TestSuiteID_B)
191+
newTestSuiteID_B = newTestSuite[0]['id']
192+
print "New Test Suite '%s' - id: %s" % (NEWTESTSUITE_B, newTestSuiteID_B)
193193
# -- END CHANGE v0.4.5 --
194194

195195
#Creates the test Suite AA
@@ -206,8 +206,8 @@
206206
newTestSuite = myTestLink.createTestSuite(newProjectID, NEWTESTSUITE_AA,
207207
"Details of the Test Suite AA",parentid=FirstLevelID)
208208
print "createTestSuite", newTestSuite
209-
TestSuiteID_AA = newTestSuite[0]['id']
210-
print "New Test Suite '%s' - id: %s" % (NEWTESTSUITE_AA, TestSuiteID_AA)
209+
newTestSuiteID_AA = newTestSuite[0]['id']
210+
print "New Test Suite '%s' - id: %s" % (NEWTESTSUITE_AA, newTestSuiteID_AA)
211211
# -- END CHANGE v0.4.5 --
212212

213213
MANUAL = 1
@@ -231,7 +231,7 @@
231231
# else:
232232
# print "Error creating the Test Case '%s': %s " % (NEWTESTCASE_AA, isOk)
233233
# sys.exit(-1)
234-
newTestCase = myTestLink.createTestCase(NEWTESTCASE_AA, TestSuiteID_AA,
234+
newTestCase = myTestLink.createTestCase(NEWTESTCASE_AA, newTestSuiteID_AA,
235235
newProjectID, "admin", "This is the summary of the Test Case AA",
236236
preconditions='these are the preconditions')
237237
print "createTestCase", newTestCase
@@ -258,7 +258,7 @@
258258
# else:
259259
# print "Error creating the Test Case '%s': %s " % (NEWTESTCASE_B, isOk)
260260
# sys.exit(-1)
261-
newTestCase = myTestLink.createTestCase(NEWTESTCASE_B, TestSuiteID_B,
261+
newTestCase = myTestLink.createTestCase(NEWTESTCASE_B, newTestSuiteID_B,
262262
newProjectID, "admin", "This is the summary of the Test Case B",
263263
preconditions='these are the preconditions', executiontype=AUTOMATED)
264264
print "createTestCase", newTestCase
@@ -322,6 +322,8 @@
322322
print "getTestProjectByName", response
323323
response = myTestLink.getProjectTestPlans(newProjectID)
324324
print "getProjectTestPlans", response
325+
response = myTestLink.getFirstLevelTestSuitesForTestProject(newProjectID)
326+
print "getFirstLevelTestSuitesForTestProject", response
325327

326328
# get information - testPlan
327329
response = myTestLink.getTestPlanByName(NEWPROJECT, NEWTESTPLAN)
@@ -334,6 +336,16 @@
334336
print "getLatestBuildForTestPlan", response
335337
response = myTestLink.getTestPlanPlatforms(newTestPlanID)
336338
print "getTestPlanPlatforms", response
339+
response = myTestLink.getTestSuitesForTestPlan(newTestPlanID)
340+
print "getTestSuitesForTestPlan", response
341+
342+
# get information - TestSuite
343+
response = myTestLink.getTestSuiteByID(newTestSuiteID_B)
344+
print "getTestSuiteByID", response
345+
response = myTestLink.getTestSuitesForTestSuite(newTestSuiteID_A)
346+
print "getTestSuitesForTestSuite", response
347+
response = myTestLink.getTestCasesForTestSuite(newTestSuiteID_AA, True, 'full')
348+
print "getTestCasesForTestSuite", response
337349

338350
print ""
339351
print "Number of Projects in TestLink: %s " % (myTestLink.countProjects(),)

example/TestLinkExampleGenericApi.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,10 @@
244244
print "getTestProjectByName", response
245245
response = myTestLink.getProjectTestPlans(id_cache[NEWPROJECT])
246246
print "getProjectTestPlans", response
247+
response = myTestLink.getFirstLevelTestSuitesForTestProject(id_cache[NEWPROJECT])
248+
print "getFirstLevelTestSuitesForTestProject", response
247249

248-
# get information - testPlan
250+
# get information - TestPlan
249251
response = myTestLink.getTestPlanByName(NEWPROJECT, NEWTESTPLAN)
250252
print "getTestPlanByName", response
251253
response = myTestLink.getTotalsForTestPlan(id_cache[NEWTESTPLAN])
@@ -256,6 +258,18 @@
256258
print "getLatestBuildForTestPlan", response
257259
response = myTestLink.getTestPlanPlatforms(id_cache[NEWTESTPLAN])
258260
print "getTestPlanPlatforms", response
261+
response = myTestLink.getTestSuitesForTestPlan(id_cache[NEWTESTPLAN])
262+
print "getTestSuitesForTestPlan", response
263+
264+
# get information - TestSuite
265+
response = myTestLink.getTestSuiteByID(id_cache[NEWTESTSUITE_B])
266+
print "getTestSuiteByID", response
267+
response = myTestLink.getTestSuitesForTestSuite(id_cache[NEWTESTSUITE_A])
268+
print "getTestSuitesForTestSuite", response
269+
response = myTestLink.getTestCasesForTestSuite(id_cache[NEWTESTSUITE_AA],
270+
deep=True, detail='full')
271+
print "getTestCasesForTestSuite", response
272+
259273

260274
print ""
261275
print "Number of Projects in TestLink: %i " % len(myTestLink.getProjects())

src/testlink/testlinkapi.py

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ def _changePositionalArgConfig(self):
7575
pos_arg_config['reportTCResult'] = ['testcaseid', 'testplanid',
7676
'buildname', 'status', 'notes']
7777
# uploadExecutionAttachment
78-
pos_arg_config['uploadExecutionAttachment'] = ['executionid', 'title', 'description']
78+
pos_arg_config['uploadExecutionAttachment'] = ['executionid', 'title',
79+
'description']
80+
# getTestCasesForTestSuite
81+
pos_arg_config['getTestCasesForTestSuite'] = ['testsuiteid', 'deep',
82+
'details']
7983

8084
#
8185
# BUILT-IN API CALLS - extented / customised against generic behaviour
@@ -130,13 +134,13 @@ def echo(self, message):
130134
# return response
131135

132136

133-
def getFirstLevelTestSuitesForTestProject(self,testprojectid):
134-
""" getFirstLevelTestSuitesForTestProject :
135-
Get set of test suites AT TOP LEVEL of tree on a Test Project
136-
"""
137-
argsAPI = {'devKey' : self.devKey,
138-
'testprojectid':str(testprojectid)}
139-
return self._callServer('getFirstLevelTestSuitesForTestProject', argsAPI)
137+
# def getFirstLevelTestSuitesForTestProject(self,testprojectid):
138+
# """ getFirstLevelTestSuitesForTestProject :
139+
# Get set of test suites AT TOP LEVEL of tree on a Test Project
140+
# """
141+
# argsAPI = {'devKey' : self.devKey,
142+
# 'testprojectid':str(testprojectid)}
143+
# return self._callServer('getFirstLevelTestSuitesForTestProject', argsAPI)
140144

141145
def getFullPath(self,nodeid):
142146
""" getFullPath :
@@ -264,15 +268,15 @@ def getTestCasesForTestPlan(self, *args):
264268
argsAPI[paramlist[0]] = paramlist[1]
265269
return self._callServer('getTestCasesForTestPlan', argsAPI)
266270

267-
def getTestCasesForTestSuite(self, testsuiteid, deep, details):
268-
""" getTestCasesForTestSuite :
269-
List test cases within a test suite
270-
"""
271-
argsAPI = {'devKey' : self.devKey,
272-
'testsuiteid' : str(testsuiteid),
273-
'deep' : str(deep),
274-
'details' : str(details)}
275-
return self._callServer('getTestCasesForTestSuite', argsAPI)
271+
# def getTestCasesForTestSuite(self, testsuiteid, deep, details):
272+
# """ getTestCasesForTestSuite :
273+
# List test cases within a test suite
274+
# """
275+
# argsAPI = {'devKey' : self.devKey,
276+
# 'testsuiteid' : str(testsuiteid),
277+
# 'deep' : str(deep),
278+
# 'details' : str(details)}
279+
# return self._callServer('getTestCasesForTestSuite', argsAPI)
276280

277281
# def getTestPlanByName(self, testprojectname, testplanname):
278282
# """ getTestPlanByName :
@@ -299,29 +303,29 @@ def getTestCasesForTestSuite(self, testsuiteid, deep, details):
299303
# 'testprojectname' : str(testprojectname)}
300304
# return self._callServer('getTestProjectByName', argsAPI)
301305

302-
def getTestSuiteByID(self, testsuiteid):
303-
""" getTestSuiteByID :
304-
Return a TestSuite by ID
305-
"""
306-
argsAPI = {'devKey' : self.devKey,
307-
'testsuiteid' : str(testsuiteid)}
308-
return self._callServer('getTestSuiteByID', argsAPI)
306+
# def getTestSuiteByID(self, testsuiteid):
307+
# """ getTestSuiteByID :
308+
# Return a TestSuite by ID
309+
# """
310+
# argsAPI = {'devKey' : self.devKey,
311+
# 'testsuiteid' : str(testsuiteid)}
312+
# return self._callServer('getTestSuiteByID', argsAPI)
309313

310-
def getTestSuitesForTestPlan(self, testplanid):
311-
""" getTestSuitesForTestPlan :
312-
List test suites within a test plan alphabetically
313-
"""
314-
argsAPI = {'devKey' : self.devKey,
315-
'testplanid' : str(testplanid)}
316-
return self._callServer('getTestSuitesForTestPlan', argsAPI)
314+
# def getTestSuitesForTestPlan(self, testplanid):
315+
# """ getTestSuitesForTestPlan :
316+
# List test suites within a test plan alphabetically
317+
# """
318+
# argsAPI = {'devKey' : self.devKey,
319+
# 'testplanid' : str(testplanid)}
320+
# return self._callServer('getTestSuitesForTestPlan', argsAPI)
317321

318-
def getTestSuitesForTestSuite(self, testsuiteid):
319-
""" getTestSuitesForTestSuite :
320-
get list of TestSuites which are DIRECT children of a given TestSuite
321-
"""
322-
argsAPI = {'devKey' : self.devKey,
323-
'testsuiteid' : str(testsuiteid)}
324-
return self._callServer('getTestSuitesForTestSuite', argsAPI)
322+
# def getTestSuitesForTestSuite(self, testsuiteid):
323+
# """ getTestSuitesForTestSuite :
324+
# get list of TestSuites which are DIRECT children of a given TestSuite
325+
# """
326+
# argsAPI = {'devKey' : self.devKey,
327+
# 'testsuiteid' : str(testsuiteid)}
328+
# return self._callServer('getTestSuitesForTestSuite', argsAPI)
325329

326330
# def getTotalsForTestPlan(self, testplanid):
327331
# """ getTotalsForTestPlan :

src/testlink/testlinkapigeneric.py

Lines changed: 65 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,16 @@
3838
'createTestProject' : ['testprojectname', 'testcaseprefix'],
3939
'createTestSuite' : ['testprojectid', 'testsuitename', 'details'],
4040
'getBuildsForTestPlan' : ['testplanid'],
41+
'getFirstLevelTestSuitesForTestProject' : ['testprojectid'],
4142
'getLatestBuildForTestPlan' : ['testplanid'],
4243
'getProjectTestPlans' : ['testprojectid'],
44+
'getTestCasesForTestSuite' : ['testsuiteid'],
4345
'getTestPlanByName' : ['testprojectname', 'testplanname'],
4446
'getTestPlanPlatforms' : ['testplanid'],
4547
'getTestProjectByName' : ['testprojectname'],
48+
'getTestSuiteByID' : ['testsuiteid'],
49+
'getTestSuitesForTestPlan' : ['testplanid'],
50+
'getTestSuitesForTestSuite' : ['testsuiteid'],
4651
'getTotalsForTestPlan' : ['testplanid'],
4752
'doesUserExist' : ['user'],
4853
'repeat' : ['str'],
@@ -81,10 +86,11 @@ def decoMakerApiCallReplaceTLResponseError(replaceCode=None):
8186
8287
Default (replaceCode=None) handles the cause 'Empty Result'
8388
- ok for getProjectTestPlans, getBuildsForTestPlan, which returns just ''
84-
Problem is getTestPlanByName
85-
- this does not return just '', it returns the error message
86-
3041: Test plan (name:TestPlan_API) has no platforms linked
87-
coudl be handled with replaceCode=3041
89+
Problems are getTestPlanByName, getFirstLevelTestSuitesForTestProject
90+
- they do not return just '', they returns the error message
91+
3041: Test plan (noPlatform) has no platforms linked
92+
7008: Test Project (noSuite) is empty
93+
could be handled with replaceCode=3041 / replaceCode=7008
8894
8995
"""
9096
# for understanding, what we are doing here please read
@@ -279,7 +285,7 @@ def getProjectTestPlans(self):
279285
# */
280286
# public function getBuildsForTestPlan($args)
281287

282-
@decoMakerApiCallReplaceTLResponseError()
288+
@decoMakerApiCallReplaceTLResponseError()
283289
@decoApiCallAddDevKey
284290
@decoApiCallWithArgs
285291
def getBuildsForTestPlan(self):
@@ -290,14 +296,15 @@ def getBuildsForTestPlan(self):
290296
returns an empty list, if no build is assigned """
291297

292298

293-
# * List test suites within a test plan alphabetically
294-
# *
295-
# * @param struct $args
296-
# * @param string $args["devKey"]
297-
# * @param int $args["testplanid"]
298-
# * @return mixed $resultInfo
299-
# */
300-
# public function getTestSuitesForTestPlan($args)
299+
@decoMakerApiCallReplaceTLResponseError()
300+
@decoApiCallAddDevKey
301+
@decoApiCallWithArgs
302+
def getTestSuitesForTestPlan(self):
303+
""" getTestSuitesForTestPlan : List test suites within a test plan alphabetically
304+
positional args: testplanid
305+
optional args : ---
306+
307+
returns an empty list, if no build is assigned """
301308

302309
@decoApiCallAddDevKey
303310
@decoApiCallWithArgs
@@ -333,6 +340,18 @@ def createTestProject(self):
333340
# */
334341
# public function getTestCasesForTestSuite($args)
335342

343+
@decoMakerApiCallReplaceTLResponseError()
344+
@decoApiCallAddDevKey
345+
@decoApiCallWithArgs
346+
def getTestCasesForTestSuite(self):
347+
""" getTestCasesForTestSuite : List test suites within a test plan alphabetically
348+
positional args: testsuiteid
349+
optional args : deep, details
350+
351+
details - default is simple,
352+
use full if you want to get summary,steps & expected_results
353+
354+
returns an empty list, if no build is assigned """
336355

337356
# /**
338357
# * Find a test case by its name
@@ -473,6 +492,19 @@ def reportTCResult(self):
473492
# */
474493
# public function getFirstLevelTestSuitesForTestProject($args)
475494

495+
@decoMakerApiCallReplaceTLResponseError(7008)
496+
@decoApiCallAddDevKey
497+
@decoApiCallWithArgs
498+
def getFirstLevelTestSuitesForTestProject(self):
499+
""" getFirstLevelTestSuitesForTestProject : get set of test suites
500+
AT TOP LEVEL of tree on a Test Project
501+
502+
positional args: testprojectid
503+
optional args : ---
504+
505+
returns an empty list, if no suite is assigned (api error 7008)
506+
- details see comments for decoMakerApiCallReplaceTLResponseError """
507+
476508
# /**
477509
# * Assign Requirements to a test case
478510
# * we can assign multiple requirements.
@@ -598,30 +630,26 @@ def createTestPlan(self):
598630
# */
599631
# public function deleteExecution($args)
600632

601-
# /**
602-
# * Return a TestSuite by ID
603-
# *
604-
# * @param
605-
# * @param struct $args
606-
# * @param string $args["devKey"]
607-
# * @param int $args["testsuiteid"]
608-
# * @return mixed $resultInfo
609-
# *
610-
# * @access public
611-
# */
612-
# public function getTestSuiteByID($args)
613633

614-
# /**
615-
# * get list of TestSuites which are DIRECT children of a given TestSuite
616-
# *
617-
# * @param struct $args
618-
# * @param string $args["devKey"]
619-
# * @param int $args["testsuiteid"]
620-
# * @return mixed $resultInfo
621-
# *
622-
# * @access public
623-
# */
624-
# public function getTestSuitesForTestSuite($args)
634+
@decoApiCallAddDevKey
635+
@decoApiCallWithArgs
636+
def getTestSuiteByID(self):
637+
""" getTestSuiteByID : Return a TestSuite by ID
638+
639+
positional args: testsuiteid
640+
optional args : --- """
641+
642+
643+
@decoMakerApiCallReplaceTLResponseError()
644+
@decoApiCallAddDevKey
645+
@decoApiCallWithArgs
646+
def getTestSuitesForTestSuite(self):
647+
""" getTestSuitesForTestSuite : get list of TestSuites which are DIRECT
648+
children of a given TestSuite
649+
positional args: testsuiteid
650+
optional args : ---
651+
652+
returns an empty list, if no platform is assigned """
625653

626654
# /**
627655
# * Returns the list of platforms associated to a given test plan
@@ -645,7 +673,7 @@ def getTestPlanPlatforms(self):
645673
positional args: testplanid
646674
optional args : ---
647675
648-
returns an empty list, if no platform is assigned
676+
returns an empty list, if no platform is assigned (api error 3041)
649677
- details see comments for decoMakerApiCallReplaceTLResponseError """
650678

651679
# /**

0 commit comments

Comments
 (0)