Skip to content

Commit 86b6fc1

Browse files
author
Luiko Czub
committed
changed api - createTestCase - estimatedexecduration, status #71
1 parent 77b6111 commit 86b6fc1

8 files changed

+145
-16
lines changed

Diff for: CHANGES.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ new TestlinkAPIGeneric and TestlinkAPIClient api methods
1515
[details=<details>], [order=<order>], [devKey=<devKey>])
1616
- getTestSuite(<testsuitename>, <prefix>, [devKey=<devKey>])
1717

18-
implement 1.9.15 changed api interfaces - #68 #70 #72
18+
implement 1.9.15 changed api interfaces - #68 #70 #72 #71
1919
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2020

2121
changed TestlinkAPIGeneric and TestlinkAPIClient api methods
@@ -31,6 +31,8 @@ changed TestlinkAPIGeneric and TestlinkAPIClient api methods
3131

3232
- addTestCaseToTestPlan() is adapted to to support the new optional argument
3333
<overwrite> to update linked Test Case Versions
34+
- createTestCase() is adapted to to support the new optional arguments <status>
35+
and <estimatedexecduration>
3436

3537
examples:
3638

Diff for: example/TestLinkExample.py

+12-5
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,13 @@
235235

236236
MANUAL = 1
237237
AUTOMATED = 2
238+
READFORREVIEW=2
239+
REWORK=4
240+
HIGH=3
241+
MEDIUM=2
242+
LOW=1
238243

239-
#Creates the test case TC_AA
244+
#Creates the test case TC_AA with state ready for review
240245
myTestLink.initStep("Step action 1", "Step result 1", MANUAL)
241246
myTestLink.appendStep("Step action 2", "Step result 2", MANUAL)
242247
myTestLink.appendStep("Step action 3", "Step result 3", MANUAL)
@@ -247,12 +252,13 @@
247252

248253
newTestCase = myTestLink.createTestCase(NEWTESTCASE_AA, newTestSuiteID_AA,
249254
newProjectID, myTestUserName, "This is the summary of the Test Case AA",
250-
preconditions='these are the preconditions')
255+
preconditions='these are the preconditions',
256+
importance=LOW, state=READFORREVIEW, estimatedexecduration=10.1)
251257
print("createTestCase", newTestCase)
252258
newTestCaseID_AA = newTestCase[0]['id']
253259
print("New Test Case '%s' - id: %s" % (NEWTESTCASE_AA, newTestCaseID_AA))
254260

255-
#Creates the test case TC_B
261+
#Creates the test case TC_B with state rework
256262
myTestLink.initStep("Step action 1", "Step result 1", AUTOMATED)
257263
myTestLink.appendStep("Step action 2", "Step result 2", AUTOMATED)
258264
myTestLink.appendStep("Step action 3", "Step result 3", AUTOMATED)
@@ -261,7 +267,8 @@
261267

262268
newTestCase = myTestLink.createTestCase(NEWTESTCASE_B, newTestSuiteID_B,
263269
newProjectID, myTestUserName, "This is the summary of the Test Case B",
264-
preconditions='these are the preconditions', executiontype=AUTOMATED)
270+
preconditions='these are the preconditions', executiontype=AUTOMATED,
271+
status=REWORK, estimatedexecduration=0.5)
265272
print("createTestCase", newTestCase)
266273
newTestCaseID_B = newTestCase[0]['id']
267274
print("New Test Case '%s' - id: %s" % (NEWTESTCASE_B, newTestCaseID_B))
@@ -299,7 +306,7 @@
299306
{'step_number' : 6, 'actions' : "Step action 6 -b added by updateTestCase" ,
300307
'expected_results' : "Step result 6 - b added", 'execution_type' : AUTOMATED})
301308
response = myTestLink.updateTestCase(tc_b_full_ext_id, version=tc_version,
302-
steps=steps_tc_b_v1u, importance='high', estimatedexecduration=3)
309+
steps=steps_tc_b_v1u, importance=MEDIUM, estimatedexecduration=3)
303310
print("updateTestCase", response)
304311

305312
# create additional steps via createTestCaseSteps - action create

Diff for: example/TestLinkExampleGenericApi.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,13 @@
225225

226226
MANUAL = 1
227227
AUTOMATED = 2
228+
READFORREVIEW=2
229+
REWORK=4
230+
HIGH=3
231+
MEDIUM=2
232+
LOW=1
228233
#
229-
# #Creates the test case TC_AA
234+
# #Creates the test case TC_AA with state ready for review
230235
steps_tc_aa = [
231236
{'step_number' : 1, 'actions' : "Step action 1 - aa" ,
232237
'expected_results' : "Step result 1 - aa", 'execution_type' : MANUAL},
@@ -244,12 +249,13 @@
244249
]
245250
newTestCase = myTestLink.createTestCase(NEWTESTCASE_AA, newTestSuiteID_AA,
246251
newProjectID, myTestUserName, "This is the summary of the Test Case AA",
247-
steps_tc_aa, preconditions='these are the preconditions')
252+
steps_tc_aa, preconditions='these are the preconditions',
253+
importance=LOW, state=READFORREVIEW, estimatedexecduration=10.1)
248254
print("createTestCase", newTestCase)
249255
newTestCaseID_AA = newTestCase[0]['id']
250256
print("New Test Case '%s' - id: %s" % (NEWTESTCASE_AA, newTestCaseID_AA))
251257

252-
#Creates the test case TC_B
258+
#Creates the test case TC_B with state rework
253259
steps_tc_b = [
254260
{'step_number' : 1, 'actions' : "Step action 1 -b " ,
255261
'expected_results' : "Step result 1 - b", 'execution_type' : AUTOMATED},
@@ -265,7 +271,7 @@
265271
newTestCase = myTestLink.createTestCase(NEWTESTCASE_B, newTestSuiteID_B,
266272
newProjectID, myTestUserName, "This is the summary of the Test Case B",
267273
steps_tc_b, preconditions='these are the preconditions',
268-
executiontype=AUTOMATED)
274+
executiontype=AUTOMATED, status=REWORK, estimatedexecduration=0.5)
269275
print("createTestCase", newTestCase)
270276
newTestCaseID_B = newTestCase[0]['id']
271277
print("New Test Case '%s' - id: %s" % (NEWTESTCASE_B, newTestCaseID_B))
@@ -304,7 +310,7 @@
304310
{'step_number' : 6, 'actions' : "Step action 6 -b added by updateTestCase" ,
305311
'expected_results' : "Step result 6 - b added", 'execution_type' : AUTOMATED})
306312
response = myTestLink.updateTestCase(tc_b_full_ext_id, version=tc_version,
307-
steps=steps_tc_b_v1u, importance='high', estimatedexecduration=3)
313+
steps=steps_tc_b_v1u, importance=MEDIUM, estimatedexecduration=3)
308314
print("updateTestCase", response)
309315

310316
# create additional steps via createTestCaseSteps - action create

Diff for: src/testlink/testlinkapi.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,23 @@ def createTestCase(self, *argsPositional, **argsOptional):
125125
""" createTestCase: Create a test case
126126
positional args: testcasename, testsuiteid, testprojectid, authorlogin,
127127
summary
128-
optional args : preconditions, importance, executiontype, order,
129-
internalid, checkduplicatedname, actiononduplicatedname
128+
optional args : steps, preconditions, importance, executiontype, order,
129+
internalid, checkduplicatedname, actiononduplicatedname,
130+
status, estimatedexecduration
130131
131132
argument 'steps' will be set with values from .stepsList,
132133
- when argsOptional does not include a 'steps' item
133134
- .stepsList can be filled before call via .initStep() and .appendStep()
135+
136+
otherwise, optional arg 'steps' must be defined as a list with
137+
dictionaries , example
138+
[{'step_number' : 1, 'actions' : "action A" ,
139+
'expected_results' : "result A", 'execution_type' : 0},
140+
{'step_number' : 2, 'actions' : "action B" ,
141+
'expected_results' : "result B", 'execution_type' : 1},
142+
{'step_number' : 3, 'actions' : "action C" ,
143+
'expected_results' : "result C", 'execution_type' : 0}]
144+
134145
"""
135146

136147
# store current stepsList as argument 'steps', when argsOptional defines
@@ -266,7 +277,8 @@ def _copyTCbuildArgs(self, origArgItems, changedArgs, options):
266277
externalArgNames.extend(optArgNames)
267278
externalTointernalNames = {'testcasename' : 'name',
268279
'testsuiteid' : 'testsuite_id', 'authorlogin' : 'author_login',
269-
'executiontype' : 'execution_type', 'order' : 'node_order'}
280+
'executiontype' : 'execution_type', 'order' : 'node_order',
281+
'estimatedexecduration' : 'estimated_exec_duration' }
270282

271283
# extend origItems with some values needed in createTestCase
272284
origArgItems['checkduplicatedname'] = 1

Diff for: src/testlink/testlinkapigeneric.py

+73-1
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,50 @@ def getTestCaseIDByName(self):
255255
server return can be a list or a dictionary
256256
- optional arg testprojectname seems to create a dictionary response """
257257

258+
# /**
259+
# * createTestCase
260+
# * @param struct $args
261+
# * @param string $args["devKey"]
262+
# * @param string $args["testcasename"]
263+
# * @param int $args["testsuiteid"]: test case parent test suite id
264+
# * @param int $args["testprojectid"]: test case parent test suite id
265+
# *
266+
# * @param string $args["authorlogin"]: to set test case author
267+
# * @param string $args["summary"]
268+
# * @param array $args["steps"]
269+
# *
270+
# * @param string $args["preconditions"] - optional
271+
# * @param int $args["importance"] - optional - see const.inc.php for domain
272+
# * @param int $args["execution"] - optional - see ... for domain
273+
# * @param int $args["order'] - optional
274+
# * @param int $args["internalid"] - optional - do not use
275+
# * @param string $args["checkduplicatedname"] - optional
276+
# * @param string $args["actiononduplicatedname"] - optional
277+
# * @param int $args["status"] - optional - see const.inc.php $tlCfg->testCaseStatus
278+
# * @param number $args["estimatedexecduration"] - optional
279+
# *
280+
# * @return mixed $resultInfo
281+
# * @return string $resultInfo['operation'] - verbose operation
282+
# * @return boolean $resultInfo['status'] - verbose operation
283+
# * @return int $resultInfo['id'] - test case internal ID (Database ID)
284+
# * @return mixed $resultInfo['additionalInfo']
285+
# * @return int $resultInfo['additionalInfo']['id'] same as $resultInfo['id']
286+
# * @return int $resultInfo['additionalInfo']['external_id'] without prefix
287+
# * @return int $resultInfo['additionalInfo']['status_ok'] 1/0
288+
# * @return string $resultInfo['additionalInfo']['msg'] - for debug
289+
# * @return string $resultInfo['additionalInfo']['new_name'] only present if new name generation was needed
290+
# * @return int $resultInfo['additionalInfo']['version_number']
291+
# * @return boolean $resultInfo['additionalInfo']['has_duplicate'] - for debug
292+
# * @return string $resultInfo['message'] operation message
293+
# */
294+
# public function createTestCase($args)
295+
258296
@decoApiCallAddDevKey
259297
@decoMakerApiCallWithArgs(['testcasename', 'testsuiteid', 'testprojectid',
260298
'authorlogin', 'summary', 'steps'],
261299
['preconditions', 'importance', 'executiontype', 'order',
262-
'internalid', 'checkduplicatedname', 'actiononduplicatedname'])
300+
'internalid', 'checkduplicatedname', 'actiononduplicatedname',
301+
'status', 'estimatedexecduration'])
263302
def createTestCase(self):
264303
""" Create a test case
265304
@@ -270,6 +309,14 @@ def createTestCase(self):
270309
'expected_results' : "result B", 'execution_type' : 1},
271310
{'step_number' : 3, 'actions' : "action C" ,
272311
'expected_results' : "result C", 'execution_type' : 0}]
312+
313+
possible values for optional arguments testlink/cfg/const.inc.php
314+
importance: 1 (low) 2 (medium) 3 (high)
315+
status: 1 (draft) 2 (readyForReview)
316+
3 (reviewInProgress) 4 (rework)
317+
5 (obsolete) 6 (future)
318+
7 (final)
319+
executiontype: 1 (Manual) 2 (Automated)
273320
"""
274321

275322
# /**
@@ -1172,6 +1219,31 @@ def getUserByID(self):
11721219
* ATTENTION: userApiKey will be set to NULL, because is worst that access to user password
11731220
"""
11741221

1222+
# /**
1223+
# * Update an existing test case
1224+
# * Not all test case attributes will be able to be updated using this method
1225+
# * See details below
1226+
# *
1227+
# * @param struct $args
1228+
# * @param string $args["devKey"]
1229+
# * @param string $args["testcaseexternalid"] format PREFIX-NUMBER
1230+
# * @param int $args["version"] optional version NUMBER (human readable)
1231+
# * @param string $args["testcasename"] - optional
1232+
# * @param string $args["summary"] - optional
1233+
# * @param string $args["preconditions"] - optional
1234+
# * @param array $args["steps"] - optional
1235+
# * each element is a hash with following keys
1236+
# * step_number,actions,expected_results,execution_type
1237+
# *
1238+
# * @param int $args["importance"] - optional - see const.inc.php for domain
1239+
# * @param int $args["executiontype"] - optional - see ... for domain
1240+
# * @param int $args["status'] - optional
1241+
# * @param int $args["estimatedexecduration'] - optional
1242+
# * @param string $args["user'] - login name used as updater - optional
1243+
# * if not provided will be set to user that request update
1244+
# */
1245+
# public function updateTestCase($args)
1246+
11751247
@decoApiCallAddDevKey
11761248
@decoMakerApiCallWithArgs(['testcaseexternalid'],
11771249
['version', 'testcasename','summary', 'preconditions', 'steps',

Diff for: src/testlink/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
#
1818
# ------------------------------------------------------------------------
1919

20-
VERSION = '0.6.3-dev072'
20+
VERSION = '0.6.3-dev071'
2121
TL_RELEASE = '1.9.15'
2222

Diff for: test/utest-offline/testlinkapi_offline_test.py

+16
Original file line numberDiff line numberDiff line change
@@ -651,8 +651,24 @@ def test_whatArgs_getLastExecutionResult(self):
651651

652652
def test_whatArgs_createTestCase(self):
653653
argsDescription = self.api.whatArgs('createTestCase')
654+
self.assertIn('<testcasename>,', argsDescription)
655+
self.assertIn('<testsuiteid>,', argsDescription)
656+
self.assertIn('<testprojectid>,', argsDescription)
657+
self.assertIn('<authorlogin>,', argsDescription)
658+
self.assertIn('<summary>,', argsDescription)
659+
#self.assertIn('<steps>,', argsDescription)
660+
self.assertIn('preconditions=<preconditions>', argsDescription)
661+
self.assertIn('importance=<importance>', argsDescription)
654662
self.assertIn('executiontype=<executiontype>', argsDescription)
663+
self.assertIn('order=<order>', argsDescription)
664+
self.assertIn('internalid=<internalid>', argsDescription)
665+
self.assertIn('checkduplicatedname=<checkduplicatedname>', argsDescription)
666+
self.assertIn('actiononduplicatedname=<actiononduplicatedname>', argsDescription)
667+
self.assertIn('status=<status>', argsDescription)
668+
self.assertIn('estimatedexecduration=<estimatedexecduration>', argsDescription)
655669
self.assertIn('executiontype, order', argsDescription)
670+
self.assertIn('status, estimatedexecduration', argsDescription)
671+
self.assertIn('steps=<steps>', argsDescription)
656672

657673
def test_connect_with_proxy(self):
658674
""" create a TestLink API dummy with ProxiedTransport"""

Diff for: test/utest-offline/testlinkapigeneric_offline_test.py

+14
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,21 @@ def test_whatArgs_getTestCasesForTestPlan(self):
755755

756756
def test_whatArgs_createTestCase(self):
757757
argsDescription = self.api.whatArgs('createTestCase')
758+
self.assertIn('<testcasename>,', argsDescription)
759+
self.assertIn('<testsuiteid>,', argsDescription)
760+
self.assertIn('<testprojectid>,', argsDescription)
761+
self.assertIn('<authorlogin>,', argsDescription)
762+
self.assertIn('<summary>,', argsDescription)
763+
self.assertIn('<steps>,', argsDescription)
764+
self.assertIn('preconditions=<preconditions>', argsDescription)
765+
self.assertIn('importance=<importance>', argsDescription)
758766
self.assertIn('executiontype=<executiontype>', argsDescription)
767+
self.assertIn('order=<order>', argsDescription)
768+
self.assertIn('internalid=<internalid>', argsDescription)
769+
self.assertIn('checkduplicatedname=<checkduplicatedname>', argsDescription)
770+
self.assertIn('actiononduplicatedname=<actiononduplicatedname>', argsDescription)
771+
self.assertIn('status=<status>', argsDescription)
772+
self.assertIn('estimatedexecduration=<estimatedexecduration>', argsDescription)
759773

760774
def test_getProjects_noProject(self):
761775
self.api.loadScenario(SCENARIO_NO_PROJECT)

0 commit comments

Comments
 (0)