Skip to content

Commit 5effe56

Browse files
author
Luiko Czub
committed
new api method deleteTestPlan #44
1 parent 77f1c9f commit 5effe56

File tree

7 files changed

+364
-244
lines changed

7 files changed

+364
-244
lines changed

CHANGES.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ new TestlinkAPIGeneric and TestlinkAPIClient api method
4646

4747
examples see `<example/TestLinkExample_CF_KW.py>`_
4848

49+
implement 1.9.13 new api - deleteTestPlan #44
50+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
51+
52+
new TestlinkAPIGeneric and TestlinkAPIClient api method
53+
54+
- deleteTestPlan(<testplanid>)
55+
56+
examples see `<example/TestLinkExample.py>`_
4957

5058
TestLink-API-Python-client release notes v0.6.0 (Dec. 2014)
5159
------------------------------------------------------------

example/TestLinkExample.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
NEWPREFIX="NPROAPI%i" % projNr
8989
NEWTESTPLAN_A="TestPlan_API A"
9090
NEWTESTPLAN_B="TestPlan_API B"
91+
NEWTESTPLAN_C="TestPlan_API C - DeleteTest"
9192
NEWPLATFORM_A='Big Birds %i' % projNr
9293
NEWPLATFORM_B='Small Birds'
9394
NEWPLATFORM_C='Ugly Birds'
@@ -99,6 +100,7 @@
99100
myApiVersion='%s v%s' % (myTestLink.__class__.__name__ , myTestLink.__version__)
100101
NEWBUILD_A='%s' % myApiVersion
101102
NEWBUILD_B='%s' % myApiVersion
103+
NEWBUILD_C='%s - DeleteTest' % myApiVersion
102104

103105
this_file_dirname=os.path.dirname(__file__)
104106
NEWATTACHMENT_PY= os.path.join(this_file_dirname, 'TestLinkExample.py')
@@ -579,6 +581,47 @@
579581
newProjectID, MANUAL)
580582
print("setTestCaseExecutionType", response)
581583

584+
# create TestPlan C with Platform, Build , TestCase, assigned TestCase
585+
# and delete it
586+
newTestPlan = myTestLink.createTestPlan(NEWTESTPLAN_C, NEWPROJECT,
587+
notes='TestPlan for delete test.',
588+
active=1, public=1)
589+
print("createTestPlan for DeleteTest", newTestPlan)
590+
newTestPlanID_C = newTestPlan[0]['id']
591+
print("Test Plan '%s' - id: %s" % (NEWTESTPLAN_C,newTestPlanID_C))
592+
newBuild = myTestLink.createBuild(newTestPlanID_C, NEWBUILD_C,
593+
'Build for TestPlan delete test')
594+
print("createBuild for DeleteTest", newBuild)
595+
newBuildID_C = newBuild[0]['id']
596+
print("Build '%s' - id: %s" % (NEWBUILD_C, newBuildID_C))
597+
response = myTestLink.addPlatformToTestPlan(newTestPlanID_C, NEWPLATFORM_C)
598+
print("addPlatformToTestPlan", response)
599+
response = myTestLink.addTestCaseToTestPlan(newProjectID, newTestPlanID_C,
600+
tc_aa_full_ext_id, tc_version, platformid=newPlatFormID_C)
601+
print("addTestCaseToTestPlan", response)
602+
response = myTestLink.assignTestCaseExecutionTask( myTestUserName,
603+
newTestPlanID_C, tc_aa_full_ext_id, buildid=newBuildID_C,
604+
platformid=newPlatFormID_C)
605+
print("assignTestCaseExecutionTask", response)
606+
newResult = myTestLink.reportTCResult(newTestCaseID_AA, newTestPlanID_C,
607+
NEWBUILD_C, 'p', "TP delete test",
608+
platformname=NEWPLATFORM_C)
609+
print("reportTCResult", newResult)
610+
newResultID_B = newResult[0]['id']
611+
newAttachment = myTestLink.uploadExecutionAttachment(NEWATTACHMENT_PY, newResultID_B,
612+
'Textfile Example', 'Attachment Example for a TC Execution and TP delete test',
613+
filename='MyPyTPDeleteTest.py')
614+
print("uploadExecutionAttachment", newAttachment)
615+
response = myTestLink.getTotalsForTestPlan(newTestPlanID_C)
616+
print("getTotalsForTestPlan before delete", response)
617+
response = myTestLink.deleteTestPlan(newTestPlanID_C)
618+
print("deleteTestPlan", response)
619+
try:
620+
response = myTestLink.getTotalsForTestPlan(newTestPlanID_C)
621+
print("getTotalsForTestPlan after delete", response)
622+
except TLResponseError as tl_err:
623+
print(tl_err.message)
624+
582625
# get information - TestProject
583626
response = myTestLink.getTestProjectByName(NEWPROJECT)
584627
print("getTestProjectByName", response)

example/TestLinkExampleGenericApi.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
NEWPREFIX="GPROAPI%i" % projNr
7878
NEWTESTPLAN_A="TestPlan_API_GENERIC A"
7979
NEWTESTPLAN_B="TestPlan_API_GENERIC B"
80+
NEWTESTPLAN_C="TestPlan_API_GENERIC C - DeleteTest"
8081
NEWPLATFORM_A='Big Bird %i' % projNr
8182
NEWPLATFORM_B='Small Bird'
8283
NEWPLATFORM_C='Ugly Bird'
@@ -88,6 +89,7 @@
8889
myApiVersion='%s v%s' % (myTestLink.__class__.__name__ , myTestLink.__version__)
8990
NEWBUILD_A='%s' % myApiVersion
9091
NEWBUILD_B='%s' % myApiVersion
92+
NEWBUILD_C='%s - DeleteTest' % myApiVersion
9193

9294
this_file_dirname=os.path.dirname(__file__)
9395
NEWATTACHMENT_PY= os.path.join(this_file_dirname, 'TestLinkExampleGenericApi.py')
@@ -499,6 +501,47 @@
499501
newProjectID, MANUAL)
500502
print("setTestCaseExecutionType", response)
501503

504+
# create TestPlan C with Platform, Build , TestCase, assigned TestCase
505+
# and delete it
506+
newTestPlan = myTestLink.createTestPlan(NEWTESTPLAN_C, NEWPROJECT,
507+
notes='TestPlan for delete test.',
508+
active=1, public=1)
509+
print("createTestPlan for DeleteTest", newTestPlan)
510+
newTestPlanID_C = newTestPlan[0]['id']
511+
print("Test Plan '%s' - id: %s" % (NEWTESTPLAN_C,newTestPlanID_C))
512+
newBuild = myTestLink.createBuild(newTestPlanID_C, NEWBUILD_C,
513+
buildnotes='Build for TestPlan delete test')
514+
print("createBuild for DeleteTest", newBuild)
515+
newBuildID_C = newBuild[0]['id']
516+
print("Build '%s' - id: %s" % (NEWBUILD_C, newBuildID_C))
517+
response = myTestLink.addPlatformToTestPlan(newTestPlanID_C, NEWPLATFORM_C)
518+
print("addPlatformToTestPlan", response)
519+
response = myTestLink.addTestCaseToTestPlan(newProjectID, newTestPlanID_C,
520+
tc_aa_full_ext_id, tc_version, platformid=newPlatFormID_C)
521+
print("addTestCaseToTestPlan", response)
522+
response = myTestLink.assignTestCaseExecutionTask( myTestUserName,
523+
newTestPlanID_C, tc_aa_full_ext_id, buildid=newBuildID_C,
524+
platformid=newPlatFormID_C)
525+
print("assignTestCaseExecutionTask", response)
526+
newResult = myTestLink.reportTCResult(newTestPlanID_C, 'p',
527+
buildid=newBuildID_C, testcaseid=newTestCaseID_AA,
528+
platformname=NEWPLATFORM_C, notes="TP delete test")
529+
print("reportTCResult", newResult)
530+
newResultID_B = newResult[0]['id']
531+
newAttachment = myTestLink.uploadExecutionAttachment(NEWATTACHMENT_PY, newResultID_B,
532+
title='Textfile Example', filename='MyPyTPDeleteTest.py',
533+
description='Attachment Example for a TC Execution and TP delete test')
534+
print("uploadExecutionAttachment", newAttachment)
535+
response = myTestLink.getTotalsForTestPlan(newTestPlanID_C)
536+
print("getTotalsForTestPlan before delete", response)
537+
response = myTestLink.deleteTestPlan(newTestPlanID_C)
538+
print("deleteTestPlan", response)
539+
try:
540+
response = myTestLink.getTotalsForTestPlan(newTestPlanID_C)
541+
print("getTotalsForTestPlan after delete", response)
542+
except TLResponseError as tl_err:
543+
print(tl_err.message)
544+
502545
# get information - TestProject
503546
response = myTestLink.getTestProjectByName(NEWPROJECT)
504547
print("getTestProjectByName", response)

src/testlink/testlinkapigeneric.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,6 +1227,26 @@ def getTestCaseKeywords(self):
12271227
args variations: testcaseid - testcaseexternalid (mandatoy!)
12281228
12291229
returns an empty dictionary, if no keywords are defined """
1230+
1231+
# /**
1232+
# * Delete a test plan and all related link to other items
1233+
# *
1234+
# * @param struct $args
1235+
# * @param string $args["devKey"]
1236+
# * @param int $args["$tplanID"]
1237+
# *
1238+
# * @return mixed $resultInfo
1239+
# * [status] => true/false of success
1240+
# * [id] => result id or error code
1241+
# * [message] => optional message for error message string
1242+
# * @access public
1243+
# */
1244+
# public function deleteTestPlan($args)
1245+
1246+
@decoApiCallAddDevKey
1247+
@decoMakerApiCallWithArgs(['testplanid'])
1248+
def deleteTestPlan(self):
1249+
""" Delete a test plan and all related link to other items """
12301250

12311251
#
12321252
# public methods for general server calls

src/testlink/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
#
1818
# ------------------------------------------------------------------------
1919

20-
VERSION = '0.6.1-dev42'
20+
VERSION = '0.6.1-dev44'
2121
TL_RELEASE = 'DEV 1.9.13 (gitorious 0be4cb9)'
2222

0 commit comments

Comments
 (0)