Skip to content

Commit 76c68a6

Browse files
author
Luiko Czub
committed
server call methods shifted to generic API lczub#7
createTestCase
1 parent 6e65170 commit 76c68a6

9 files changed

+430
-317
lines changed

example/TestLinkExample.py

+63-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#! /usr/bin/python
22
# -*- coding: UTF-8 -*-
33

4-
# Copyright 2011-2012 Olivier Renault, TestLink-API-Python-client developers
4+
# Copyright 2011-2013 Olivier Renault, TestLink-API-Python-client developers
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.
@@ -45,6 +45,13 @@
4545
--------- Test Case B
4646
|
4747
--- 5 automated test steps
48+
49+
Update 12. Oct. 2013, L. Czub
50+
Integrates v0.4.5 changes for optional arguments
51+
The v0.4.0 method calls are still visible as comments (look for CHANGE v0.4.5)
52+
So this file helps to understand where existing own code needs adjustment.
53+
-
54+
used as behaviour is still
4855
"""
4956
from testlink import TestlinkAPIClient, TestLinkHelper
5057
import sys
@@ -90,9 +97,16 @@
9097
print ""
9198

9299
# Creates the project
100+
101+
# -- Start CHANGE v0.4.5 --
102+
# newProject = myTestLink.createTestProject(NEWPROJECT, "NPROAPI",
103+
# "notes=This is a Project created with the API", "active=1", "public=1",
104+
# "options=requirementsEnabled:0,testPriorityEnabled:1,automationEnabled:1,inventoryEnabled:0")
93105
newProject = myTestLink.createTestProject(NEWPROJECT, "NPROAPI",
94-
"notes=This is a Project created with the API", "active=1", "public=1",
95-
"options=requirementsEnabled:0,testPriorityEnabled:1,automationEnabled:1,inventoryEnabled:0")
106+
notes='This is a Project created with the API', active=1, public=1,
107+
options={'requirementsEnabled' : 0, 'testPriorityEnabled' : 1,
108+
'automationEnabled' : 1, 'inventoryEnabled' : 0})
109+
# -- END CHANGE v0.4.5 --
96110
isOk = newProject[0]['message']
97111
if isOk=="Success!":
98112
newProjectID = newProject[0]['id']
@@ -102,8 +116,12 @@
102116
sys.exit(-1)
103117

104118
# Creates the test plan
119+
# -- Start CHANGE v0.4.5 --
120+
# newTestPlan = myTestLink.createTestPlan(NEWTESTPLAN, NEWPROJECT,
121+
# "notes=New TestPlan created with the API","active=1", "public=1")
105122
newTestPlan = myTestLink.createTestPlan(NEWTESTPLAN, NEWPROJECT,
106-
"notes=New TestPlan created with the API","active=1", "public=1")
123+
notes='New TestPlan created with the API',active=1, public=1)
124+
# -- END CHANGE v0.4.5 --
107125
isOk = newTestPlan[0]['message']
108126
if isOk=="Success!":
109127
newTestPlanID = newTestPlan[0]['id']
@@ -137,8 +155,12 @@
137155
sys.exit(-1)
138156

139157
#Creates the test Suite AA
158+
# -- Start CHANGE v0.4.5 --
159+
# newTestSuite = myTestLink.createTestSuite(newProjectID, NEWTESTSUITE_AA,
160+
# "Details of the Test Suite AA","parentid="+FirstLevelID)
140161
newTestSuite = myTestLink.createTestSuite(newProjectID, NEWTESTSUITE_AA,
141-
"Details of the Test Suite AA","parentid="+FirstLevelID)
162+
"Details of the Test Suite AA",parentid=FirstLevelID)
163+
# -- END CHANGE v0.4.5 --
142164
isOk = newTestSuite[0]['message']
143165
if isOk=="ok":
144166
TestSuiteID_AA = newTestSuite[0]['id']
@@ -157,13 +179,18 @@
157179
myTestLink.appendStep("Step action 4", "Step result 4", MANUAL)
158180
myTestLink.appendStep("Step action 5", "Step result 5", MANUAL)
159181

182+
# -- Start CHANGE v0.4.5 --
183+
# newTestCase = myTestLink.createTestCase(NEWTESTCASE_AA, TestSuiteID_AA,
184+
# newProjectID, "admin", "This is the summary of the Test Case AA",
185+
# "preconditions=these are the preconditions")
160186
newTestCase = myTestLink.createTestCase(NEWTESTCASE_AA, TestSuiteID_AA,
161187
newProjectID, "admin", "This is the summary of the Test Case AA",
162-
"preconditions=these are the preconditions")
188+
preconditions='these are the preconditions')
189+
# -- END CHANGE v0.4.5 --
163190
isOk = newTestCase[0]['message']
164191
if isOk=="Success!":
165-
newTestCaseID = newTestCase[0]['id']
166-
print "New Test Case '%s' - id: %s" % (NEWTESTCASE_AA, newTestCaseID)
192+
newTestCaseID_AA = newTestCase[0]['id']
193+
print "New Test Case '%s' - id: %s" % (NEWTESTCASE_AA, newTestCaseID_AA)
167194
else:
168195
print "Error creating the Test Case '%s': %s " % (NEWTESTCASE_AA, isOk)
169196
sys.exit(-1)
@@ -175,17 +202,41 @@
175202
myTestLink.appendStep("Step action 4", "Step result 4", AUTOMATED)
176203
myTestLink.appendStep("Step action 5", "Step result 5", AUTOMATED)
177204

205+
# -- Start CHANGE v0.4.5 --
206+
# newTestCase = myTestLink.createTestCase(NEWTESTCASE_B, TestSuiteID_B,
207+
# newProjectID, "admin", "This is the summary of the Test Case B",
208+
# "preconditions=these are the preconditions",
209+
# "executiontype=%i" % AUTOMATED)
178210
newTestCase = myTestLink.createTestCase(NEWTESTCASE_B, TestSuiteID_B,
179211
newProjectID, "admin", "This is the summary of the Test Case B",
180-
"preconditions=these are the preconditions",
181-
"executiontype=%i" % AUTOMATED)
212+
preconditions='these are the preconditions', executiontype=AUTOMATED)
213+
# -- END CHANGE v0.4.5 --
182214
isOk = newTestCase[0]['message']
183215
if isOk=="Success!":
184-
newTestCaseID = newTestCase[0]['id']
185-
print "New Test Case '%s' - id: %s" % (NEWTESTCASE_B, newTestCaseID)
216+
newTestCaseID_B = newTestCase[0]['id']
217+
print "New Test Case '%s' - id: %s" % (NEWTESTCASE_B, newTestCaseID_B)
186218
else:
187219
print "Error creating the Test Case '%s': %s " % (NEWTESTCASE_B, isOk)
188220
sys.exit(-1)
221+
222+
# -- New Examples with v0.4.5 --
223+
224+
# Add test cases to test plan - we need the full external id !
225+
tc_aa_full_ext_id = myTestLink.getTestCase(newTestCaseID_AA)[0]['full_tc_external_id']
226+
response = myTestLink._callServer('addTestCaseToTestPlan',
227+
{'devKey' : myTestLink.devKey,
228+
'testprojectid' : newProjectID,
229+
'testplanid' : newTestPlanID,
230+
'testcaseexternalid' : tc_aa_full_ext_id, 'version' : 1})
231+
print response
232+
tc_b_full_ext_id = myTestLink.getTestCase(testcaseid=newTestCaseID_B)[0]['full_tc_external_id']
233+
response = myTestLink._callServer('addTestCaseToTestPlan',
234+
{'devKey' : myTestLink.devKey,
235+
'testprojectid' : newProjectID,
236+
'testplanid' : newTestPlanID,
237+
'testcaseexternalid' : tc_b_full_ext_id, 'version' : 1})
238+
print response
239+
189240

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

0 commit comments

Comments
 (0)