Skip to content

Commit 98065f9

Browse files
author
Luiko Czub
committed
server call methods shifted to generic API lczub#7
createTestProject, createTestCase, createTestSuite, createTestPlan, getProject
1 parent 6e65170 commit 98065f9

9 files changed

+340
-244
lines changed

example/TestLinkExample.py

+40-8
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,9 +179,14 @@
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!":
165192
newTestCaseID = newTestCase[0]['id']
@@ -175,10 +202,15 @@
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!":
184216
newTestCaseID = newTestCase[0]['id']

example/TestLinkExampleGenericApi.py

+100-105
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"""
2222
2323
Shows how to use the TestLinkAPIGeneric.
24-
- does same steps as Example TestLinkAPI in TestLinkExample.py
24+
- does equal things as Example TestLinkAPI in TestLinkExample.py
2525
2626
=> Counts and lists the Projects
2727
=> Create a new Project with the following structure:
@@ -81,29 +81,17 @@
8181
print "Error with the devKey."
8282
sys.exit(-1)
8383

84-
# NOT GENERIC
85-
#print "Number of Projects in TestLink: %s " % (myTestLink.countProjects(),)
86-
# print ""
87-
# myTestLink.listProjects()
88-
# print ""
89-
# GENERIC
9084
print "Number of Projects in TestLink: %i " % len(myTestLink.getProjects())
9185
print ""
9286
for project in myTestLink.getProjects():
9387
print "Name: %(name)s ID: %(id)s " % project
9488
print ""
9589

96-
9790
# # Creates the project
98-
# NOT GENERIC
99-
# newProject = myTestLink.createTestProject(NEWPROJECT, "NPROAPI",
100-
# "notes=This is a Project created with the API", "active=1", "public=1",
101-
# "options=requirementsEnabled:0,testPriorityEnabled:1,automationEnabled:1,inventoryEnabled:0")
102-
# GENERIC
10391
newProject = myTestLink.createTestProject(NEWPROJECT, 'GPROAPI',
10492
notes='This is a Project created with the Generic API', active=1, public=1,
105-
options={ 'requirementsEnabled' : 0, 'testPriorityEnabled' : 1,
106-
'automationEnabled' : 1, 'inventoryEnabled' : 0})
93+
options={'requirementsEnabled' : 1, 'testPriorityEnabled' : 1,
94+
'automationEnabled' : 1, 'inventoryEnabled' : 1})
10795
print(newProject)
10896
isOk = newProject[0]['message']
10997
if isOk=="Success!":
@@ -113,98 +101,105 @@
113101
print "Error creating the project '%s': %s " % (NEWPROJECT,isOk)
114102
sys.exit(-1)
115103

116-
# # Creates the test plan
117-
# newTestPlan = myTestLink.createTestPlan(NEWTESTPLAN, NEWPROJECT,
118-
# "notes=New TestPlan created with the API","active=1", "public=1")
119-
# isOk = newTestPlan[0]['message']
120-
# if isOk=="Success!":
121-
# newTestPlanID = newTestPlan[0]['id']
122-
# print "New Test Plan '%s' - id: %s" % (NEWTESTPLAN,newTestPlanID)
123-
# else:
124-
# print "Error creating the Test Plan '%s': %s " % (NEWTESTPLAN, isOk)
125-
# sys.exit(-1)
126-
#
127-
# #Creates the test Suite A
128-
# newTestSuite = myTestLink.createTestSuite(newProjectID, NEWTESTSUITE_A,
129-
# "Details of the Test Suite A")
130-
# isOk = newTestSuite[0]['message']
131-
# if isOk=="ok":
132-
# newTestSuiteID = newTestSuite[0]['id']
133-
# print "New Test Suite '%s' - id: %s" % (NEWTESTSUITE_A, newTestSuiteID)
134-
# else:
135-
# print "Error creating the Test Suite '%s': %s " % (NEWTESTSUITE_A, isOk)
136-
# sys.exit(-1)
137-
#
138-
# FirstLevelID = newTestSuiteID
139-
#
140-
# #Creates the test Suite B
141-
# newTestSuite = myTestLink.createTestSuite(newProjectID, NEWTESTSUITE_B,
142-
# "Details of the Test Suite B")
143-
# isOk = newTestSuite[0]['message']
144-
# if isOk=="ok":
145-
# TestSuiteID_B = newTestSuite[0]['id']
146-
# print "New Test Suite '%s' - id: %s" % (NEWTESTSUITE_B, TestSuiteID_B)
147-
# else:
148-
# print "Error creating the Test Suite '%s': %s " % (NEWTESTSUITE_B, isOk)
149-
# sys.exit(-1)
150-
#
151-
# #Creates the test Suite AA
152-
# newTestSuite = myTestLink.createTestSuite(newProjectID, NEWTESTSUITE_AA,
153-
# "Details of the Test Suite AA","parentid="+FirstLevelID)
154-
# isOk = newTestSuite[0]['message']
155-
# if isOk=="ok":
156-
# TestSuiteID_AA = newTestSuite[0]['id']
157-
# print "New Test Suite '%s' - id: %s" % (NEWTESTSUITE_AA, TestSuiteID_AA)
158-
# else:
159-
# print "Error creating the Test Suite '%s': %s " % (NEWTESTSUITE_AA, isOk)
160-
# sys.exit(-1)
161-
#
162-
# MANUAL = 1
163-
# AUTOMATED = 2
164-
#
165-
# #Creates the test case TC_AA
166-
# myTestLink.initStep("Step action 1", "Step result 1", MANUAL)
167-
# myTestLink.appendStep("Step action 2", "Step result 2", MANUAL)
168-
# myTestLink.appendStep("Step action 3", "Step result 3", MANUAL)
169-
# myTestLink.appendStep("Step action 4", "Step result 4", MANUAL)
170-
# myTestLink.appendStep("Step action 5", "Step result 5", MANUAL)
171-
#
172-
# newTestCase = myTestLink.createTestCase(NEWTESTCASE_AA, TestSuiteID_AA,
173-
# newProjectID, "admin", "This is the summary of the Test Case AA",
174-
# "preconditions=these are the preconditions")
175-
# isOk = newTestCase[0]['message']
176-
# if isOk=="Success!":
177-
# newTestCaseID = newTestCase[0]['id']
178-
# print "New Test Case '%s' - id: %s" % (NEWTESTCASE_AA, newTestCaseID)
179-
# else:
180-
# print "Error creating the Test Case '%s': %s " % (NEWTESTCASE_AA, isOk)
181-
# sys.exit(-1)
182-
#
183-
# #Creates the test case TC_B
184-
# myTestLink.initStep("Step action 1", "Step result 1", AUTOMATED)
185-
# myTestLink.appendStep("Step action 2", "Step result 2", AUTOMATED)
186-
# myTestLink.appendStep("Step action 3", "Step result 3", AUTOMATED)
187-
# myTestLink.appendStep("Step action 4", "Step result 4", AUTOMATED)
188-
# myTestLink.appendStep("Step action 5", "Step result 5", AUTOMATED)
189-
#
190-
# newTestCase = myTestLink.createTestCase(NEWTESTCASE_B, TestSuiteID_B,
191-
# newProjectID, "admin", "This is the summary of the Test Case B",
192-
# "preconditions=these are the preconditions",
193-
# "executiontype=%i" % AUTOMATED)
194-
# isOk = newTestCase[0]['message']
195-
# if isOk=="Success!":
196-
# newTestCaseID = newTestCase[0]['id']
197-
# print "New Test Case '%s' - id: %s" % (NEWTESTCASE_B, newTestCaseID)
198-
# else:
199-
# print "Error creating the Test Case '%s': %s " % (NEWTESTCASE_B, isOk)
200-
# sys.exit(-1)
104+
# Creates the test plan
105+
newTestPlan = myTestLink.createTestPlan(NEWTESTPLAN, NEWPROJECT,
106+
notes='New TestPlan created with the API',active=1, public=1)
107+
isOk = newTestPlan[0]['message']
108+
if isOk=="Success!":
109+
newTestPlanID = newTestPlan[0]['id']
110+
print "New Test Plan '%s' - id: %s" % (NEWTESTPLAN,newTestPlanID)
111+
else:
112+
print "Error creating the Test Plan '%s': %s " % (NEWTESTPLAN, isOk)
113+
sys.exit(-1)
114+
115+
#Creates the test Suite A
116+
newTestSuite = myTestLink.createTestSuite(newProjectID, NEWTESTSUITE_A,
117+
"Details of the Test Suite A")
118+
isOk = newTestSuite[0]['message']
119+
if isOk=="ok":
120+
newTestSuiteID = newTestSuite[0]['id']
121+
print "New Test Suite '%s' - id: %s" % (NEWTESTSUITE_A, newTestSuiteID)
122+
else:
123+
print "Error creating the Test Suite '%s': %s " % (NEWTESTSUITE_A, isOk)
124+
sys.exit(-1)
125+
126+
FirstLevelID = newTestSuiteID
127+
128+
#Creates the test Suite B
129+
newTestSuite = myTestLink.createTestSuite(newProjectID, NEWTESTSUITE_B,
130+
"Details of the Test Suite B")
131+
isOk = newTestSuite[0]['message']
132+
if isOk=="ok":
133+
TestSuiteID_B = newTestSuite[0]['id']
134+
print "New Test Suite '%s' - id: %s" % (NEWTESTSUITE_B, TestSuiteID_B)
135+
else:
136+
print "Error creating the Test Suite '%s': %s " % (NEWTESTSUITE_B, isOk)
137+
sys.exit(-1)
138+
139+
#Creates the test Suite AA
140+
newTestSuite = myTestLink.createTestSuite(newProjectID, NEWTESTSUITE_AA,
141+
"Details of the Test Suite AA",parentid=FirstLevelID)
142+
isOk = newTestSuite[0]['message']
143+
if isOk=="ok":
144+
TestSuiteID_AA = newTestSuite[0]['id']
145+
print "New Test Suite '%s' - id: %s" % (NEWTESTSUITE_AA, TestSuiteID_AA)
146+
else:
147+
print "Error creating the Test Suite '%s': %s " % (NEWTESTSUITE_AA, isOk)
148+
sys.exit(-1)
149+
150+
MANUAL = 1
151+
AUTOMATED = 2
201152
#
153+
# #Creates the test case TC_AA
154+
steps_tc_aa = [
155+
{'step_number' : 1, 'actions' : "Step action 1 - aa" ,
156+
'expected_results' : "Step result 1 - aa", 'execution_type' : MANUAL},
157+
{'step_number' : 2, 'actions' : "Step action 2 - aa" ,
158+
'expected_results' : "Step result 2 - aa", 'execution_type' : MANUAL},
159+
{'step_number' : 3, 'actions' : "Step action 3 - aa" ,
160+
'expected_results' : "Step result 3 - aa", 'execution_type' : MANUAL},
161+
{'step_number' : 4, 'actions' : "Step action 4 - aa" ,
162+
'expected_results' : "Step result 4 - aa", 'execution_type' : MANUAL},
163+
{'step_number' : 5, 'actions' : "Step action 5 - aa" ,
164+
'expected_results' : "Step result 5 - aa", 'execution_type' : MANUAL}
165+
]
166+
newTestCase = myTestLink.createTestCase(NEWTESTCASE_AA, TestSuiteID_AA,
167+
newProjectID, "admin", "This is the summary of the Test Case AA",
168+
steps_tc_aa, preconditions='these are the preconditions')
169+
isOk = newTestCase[0]['message']
170+
if isOk=="Success!":
171+
newTestCaseID = newTestCase[0]['id']
172+
print "New Test Case '%s' - id: %s" % (NEWTESTCASE_AA, newTestCaseID)
173+
else:
174+
print "Error creating the Test Case '%s': %s " % (NEWTESTCASE_AA, isOk)
175+
sys.exit(-1)
176+
177+
#Creates the test case TC_B
178+
steps_tc_b = [
179+
{'step_number' : 1, 'actions' : "Step action 1 -b " ,
180+
'expected_results' : "Step result 1 - b", 'execution_type' : AUTOMATED},
181+
{'step_number' : 2, 'actions' : "Step action 2 -b " ,
182+
'expected_results' : "Step result 2 - b", 'execution_type' : AUTOMATED},
183+
{'step_number' : 3, 'actions' : "Step action 3 -b " ,
184+
'expected_results' : "Step result 3 - b", 'execution_type' : AUTOMATED},
185+
{'step_number' : 4, 'actions' : "Step action 4 -b " ,
186+
'expected_results' : "Step result 4 - b", 'execution_type' : AUTOMATED},
187+
{'step_number' : 5, 'actions' : "Step action 5 -b " ,
188+
'expected_results' : "Step result 5 - b", 'execution_type' : AUTOMATED}]
189+
190+
newTestCase = myTestLink.createTestCase(NEWTESTCASE_B, TestSuiteID_B,
191+
newProjectID, "admin", "This is the summary of the Test Case B",
192+
steps_tc_b, preconditions='these are the preconditions',
193+
executiontype=AUTOMATED)
194+
isOk = newTestCase[0]['message']
195+
if isOk=="Success!":
196+
newTestCaseID = newTestCase[0]['id']
197+
print "New Test Case '%s' - id: %s" % (NEWTESTCASE_B, newTestCaseID)
198+
else:
199+
print "Error creating the Test Case '%s': %s " % (NEWTESTCASE_B, isOk)
200+
sys.exit(-1)
201+
202202
print ""
203-
# NOT GENERIC
204-
# print "Number of Projects in TestLink: %s " % (myTestLink.countProjects(),)
205-
# print ""
206-
# myTestLink.listProjects()
207-
# GENERIC
208203
print "Number of Projects in TestLink: %i " % len(myTestLink.getProjects())
209204
print ""
210205
for project in myTestLink.getProjects():

0 commit comments

Comments
 (0)