Skip to content

Commit 56ce042

Browse files
author
Luiko Czub
committed
new api method deleteExecution #14
1 parent 3527685 commit 56ce042

File tree

6 files changed

+71
-0
lines changed

6 files changed

+71
-0
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ implement missing 1.9.8 api method - miscellaneous #14
2020
new TestlinkAPIGeneric and TestlinkAPIClient api methods
2121

2222
- getUserByLogin(), getUserByID()
23+
- deleteExecution()
2324

2425
TestLink-API-Python-client release notes v0.4.7 (Jan. 2014)
2526
-----------------------------------------------------------

example/TestLinkExample.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,25 @@
466466
print "reportTCResult", newResult
467467
newResultID_B_b = newResult[0]['id']
468468

469+
# now we make a mistake and commit the same result a second time
470+
# and try to delete this mistake
471+
newResult = myTestLink.reportTCResult(newTestCaseID_B, newTestPlanID_B, NEWBUILD_B,
472+
'b', "mistake, commit same result a second time")
473+
print "reportTCResult", newResult
474+
newResultID_B_b2 = int(newResult[0]['id'])
475+
try:
476+
# if TL configuration allows deletion of executions, no error will occur
477+
response = myTestLink.deleteExecution(newResultID_B_b2)
478+
print "deleteExecution", response
479+
except TLResponseError as tl_err:
480+
if tl_err.code == 232:
481+
# TL configuration does not allow deletion of executions
482+
pass
483+
else:
484+
# sh..: another problem occurs
485+
raise
486+
487+
469488
# get information - TestProject
470489
response = myTestLink.getTestProjectByName(NEWPROJECT)
471490
print "getTestProjectByName", response

example/TestLinkExampleGenericApi.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,24 @@
392392
print "reportTCResult", newResult
393393
newResultID_B_b = newResult[0]['id']
394394

395+
# now we make a mistake and commit the same result a second time
396+
# and try to delete this mistake
397+
newResult = myTestLink.reportTCResult(newTestPlanID_B, 'b',
398+
buildid=newBuildID_B, testcaseid=newTestCaseID_B,
399+
notes="mistake, commit same result a second time")
400+
print "reportTCResult", newResult
401+
newResultID_B_b2 = int(newResult[0]['id'])
402+
try:
403+
# if TL configuration allows deletion of executions, no error will occur
404+
response = myTestLink.deleteExecution(newResultID_B_b2)
405+
print "deleteExecution", response
406+
except TLResponseError as tl_err:
407+
if tl_err.code == 232:
408+
# TL configuration does not allow deletion of executions
409+
pass
410+
else:
411+
# sh..: another problem occurs
412+
raise
395413

396414
# get information - TestProject
397415
response = myTestLink.getTestProjectByName(NEWPROJECT)

src/testlink/testlinkapigeneric.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,15 @@ def getFullPath(self):
385385
# */
386386
# public function deleteExecution($args)
387387

388+
@decoApiCallAddDevKey
389+
@decoMakerApiCallWithArgs(['executionid'])
390+
def deleteExecution(self):
391+
""" delete an execution
392+
393+
Default TL server configuration does not allow deletion of exections
394+
see Installation & Configuration Manual Version 1.9
395+
chap. 5.8. Test execution settings
396+
$tlCfg->exec_cfg->can_delete_execution """
388397

389398
@decoApiCallAddDevKey
390399
@decoMakerApiCallWithArgs(['testsuiteid'])

test/utest-online/testlinkapi_online_test.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,18 @@ def test_getUserByLogin_unknownKey(self):
266266
# response = self.client.setTestMode(False)
267267
# self.assertTrue(response)
268268

269+
def test_deleteExecution_unknownKey(self):
270+
try:
271+
response = self.client.deleteExecution(4711)
272+
# case: TL configuration allows deletion of executions
273+
# response returns Success, even if executionID is unkown
274+
self.assertEqual([{'status': True, 'message': 'Success!', 'id': 4711,
275+
'operation': 'deleteExecution'}], response)
276+
except TLResponseError as tl_err:
277+
# case: TL configuration does not allow deletion of executions
278+
# Expects: 232: Configuration does not allow delete executions
279+
self.assertEqual(232, tl_err.code)
280+
269281

270282
if __name__ == "__main__":
271283
#import sys;sys.argv = ['', 'Test.testName']

test/utest-online/testlinkapigeneric_online_test.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,18 @@ def test_getUserByID_unknownKey(self):
282282
# self.assertTrue(response)
283283
# response = self.client.setTestMode(False)
284284
# self.assertTrue(response)
285+
286+
def test_deleteExecution_unknownKey(self):
287+
try:
288+
response = self.client.deleteExecution(4711)
289+
# case: TL configuration allows deletion of executions
290+
# response returns Success, even if executionID is unkown
291+
self.assertEqual([{'status': True, 'message': 'Success!', 'id': 4711,
292+
'operation': 'deleteExecution'}], response)
293+
except TLResponseError as tl_err:
294+
# case: TL configuration does not allow deletion of executions
295+
# Expects: 232: Configuration does not allow delete executions
296+
self.assertEqual(232, tl_err.code)
285297

286298

287299
if __name__ == "__main__":

0 commit comments

Comments
 (0)