Skip to content

Commit f65eaa8

Browse files
author
Luiko Czub
committed
api methode reportTCResult - new optional argument 'user' #24
1 parent 2909005 commit f65eaa8

File tree

8 files changed

+95
-13
lines changed

8 files changed

+95
-13
lines changed

CHANGES.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ Changes in TestLink-API-Python-client Source Distribution
44
TestLink-API-Python-client UNDER DEVELOP v0.4.9
55
-----------------------------------------------------------
66

7+
implement 1.9.10 api change - reportTCResult #24
8+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9+
10+
TestlinkAPIGeneric and TestlinkAPIClient api method reportTCResult()
11+
accepts now following additional optional arguments (usable with TL >= 1.9.10)
12+
13+
- user
14+
15+
716
implement missing 1.9.8 api method - CustomField #12
817
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
918

doc/usage.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,39 @@ argument. Examples::
6767
>>> tls.copyTCnewVersion(tc_info[0]['testcase_id'], 1, summary='new summary',
6868
importance='1')
6969
70+
Report test results
71+
-------------------
7072

73+
Using the TestLink API Client - failed test case with none default reporter
74+
(argument 'users' usable with TL >= 1.9.10):
75+
76+
>>> import testlink
77+
>>> tls = testlink.TestLinkHelper().connect(testlink.TestlinkAPIClient)
78+
>>> import testlink
79+
>>> tls.reportTCResult(a_TestCaseID, a_TestPlanID, 'a build name', 'f',
80+
'some notes',
81+
user='a user login name', platformid=a_platformID)
82+
83+
Using the TestLink Generic API Client - passed test case with none default
84+
reporter:
85+
86+
>>> import testlink
87+
>>> tls = testlink.TestLinkHelper().connect(testlink.TestlinkAPIGeneric)
88+
>>> import testlink
89+
>>> tls.reportTCResult(a_TestPlanID, 'p', testcaseid=a_TestCaseID,
90+
buildname='a build name', notes='some notes',
91+
user='a login name', platformid=a_platformID)
92+
93+
Using the TestLink Generic API Client - blocked test case with
94+
alternative optional args, default reporter (user for devKey)
95+
96+
>>> import testlink
97+
>>> tls = testlink.TestLinkHelper().connect(testlink.TestlinkAPIGeneric)
98+
>>> exTCID = tls.getTestCase(testcaseid=a_TestCaseID)[0]['full_tc_external_id']
99+
>>> tls.reportTCResult(a_TestPlanID, 'b', testcaseexternalid=exTCID,
100+
buildid='a build name', platformname='a platform name')
101+
102+
71103
Run examples
72104
------------
73105

example/TestLinkExample.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,13 +456,16 @@
456456
newBuildID_B = newBuild[0]['id']
457457
print "New Build '%s' - id: %s" % (NEWBUILD_B, newBuildID_B)
458458

459-
# TC_B blocked (without platform), explicit build and some notes , TC identified with internal id
459+
# TC_B blocked (without platform), explicit build and some notes ,
460+
# TC identified with internal id, report by myTestUserName
460461
newResult = myTestLink.reportTCResult(newTestCaseID_B, newTestPlanID_B, NEWBUILD_B,
461-
'f', "no birds are singing")
462+
'f', "no birds are singing",
463+
user=myTestUserName)
462464
print "reportTCResult", newResult
463465
newResultID_B_f = newResult[0]['id']
464466
newResult = myTestLink.reportTCResult(newTestCaseID_B, newTestPlanID_B, NEWBUILD_B,
465-
'b', "hungry birds blocks the execution")
467+
'b', "hungry birds blocks the execution",
468+
user=myTestUserName)
466469
print "reportTCResult", newResult
467470
newResultID_B_b = newResult[0]['id']
468471

example/TestLinkExampleGenericApi.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,9 @@
264264
# for every test case version 1 is used
265265
tc_version=1
266266
# TC AA should be tested with platforms 'Big Bird'+'Small Bird'
267-
tc_aa_full_ext_id = myTestLink.getTestCase(testcaseid=newTestCaseID_AA)[0]['full_tc_external_id']
267+
response = myTestLink.getTestCase(testcaseid=newTestCaseID_AA)
268+
print "getTestCase", response
269+
tc_aa_full_ext_id = response[0]['full_tc_external_id']
268270
response = myTestLink.addTestCaseToTestPlan(newProjectID, newTestPlanID_A,
269271
tc_aa_full_ext_id, tc_version, platformid=newPlatFormID_A)
270272
print "addTestCaseToTestPlan", response
@@ -380,15 +382,15 @@
380382
print "New Build '%s' - id: %s" % (NEWBUILD_B, newBuildID_B)
381383

382384
# TC_B in test plan b (without platform)
383-
# first try failed, second blocked
385+
# first try failed, second blocked - all by user myTestUserName
384386
newResult = myTestLink.reportTCResult(newTestPlanID_B, 'f',
385387
buildid=newBuildID_B, testcaseid=newTestCaseID_B,
386-
notes="no birds are singing")
388+
notes="no birds are singing", user=myTestUserName)
387389
print "reportTCResult", newResult
388390
newResultID_B_f = newResult[0]['id']
389391
newResult = myTestLink.reportTCResult(newTestPlanID_B, 'b',
390392
buildid=newBuildID_B, testcaseid=newTestCaseID_B,
391-
notes="hungry birds blocks the execution")
393+
notes="hungry birds blocks the execution", user=myTestUserName)
392394
print "reportTCResult", newResult
393395
newResultID_B_b = newResult[0]['id']
394396

src/testlink/testlinkapigeneric.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def createTestCase(self):
216216
@decoMakerApiCallWithArgs(['testplanid', 'status'],
217217
['testcaseid', 'testcaseexternalid', 'buildid', 'buildname',
218218
'platformid', 'platformname', 'notes', 'guess', 'bugid',
219-
'customfields', 'overwrite'])
219+
'customfields', 'overwrite', 'user'])
220220
def reportTCResult(self):
221221
""" Reports a result for a single test case
222222
@@ -226,7 +226,11 @@ def reportTCResult(self):
226226
227227
customfields : dictionary with customfields names + values
228228
VERY IMPORTANT: value must be formatted in the way it's written to db
229-
"""
229+
overwrite : if present and true, then last execution for
230+
(testcase,testplan,build,platform) will be overwritten.
231+
user : if present and user is a valid login (no other check will be done)
232+
it will be used when writting execution.
233+
"""
230234

231235
# /**
232236
# * turn on/off testMode

src/testlink/version.py

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

20-
VERSION = '0.4.9-dev-12'
20+
VERSION = '0.4.9-dev-24'

test/utest-offline/testlinkapi_offline_test.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@
144144
'is_public': '1', 'id': '2211', 'option_automation': '0'},
145145
},
146146
'createTestCase' : 'dummy response createTestCase',
147+
'reportTCResult' : [{'status': True, 'operation': 'reportTCResult',
148+
'message': 'Success!', 'overwrite': False, 'id': '773'}]
149+
147150
}
148151

149152
SCENARIO_STEPS = {'createTestCase' : ['noRealReponseData - ok for step tests']}
@@ -382,6 +385,18 @@ def test_copyTCnewTestCase_version(self):
382385
self.assertEqual('V1', self.api.callArgs['preconditions'])
383386
self.assertEqual('4711', self.api.callArgs['testsuiteid'])
384387
self.assertEqual('2211', self.api.callArgs['testprojectid'])
388+
389+
def test_reportTCResult_user(self):
390+
self.api.loadScenario(SCENARIO_A)
391+
response = self.api.reportTCResult(4711, 4712, 'build 4713', 'p',
392+
'note 4714', user='a login name')
393+
self.assertEqual('reportTCResult', response[0]['operation'])
394+
self.assertEqual(self.api.devKey, self.api.callArgs['devKey'])
395+
self.assertEqual('a login name', self.api.callArgs['user'])
396+
397+
def test_whatArgs_reportTCResult(self):
398+
argsDescription = self.api.whatArgs('reportTCResult')
399+
self.assertIn('user=<user>', argsDescription)
385400

386401

387402
if __name__ == "__main__":

test/utest-offline/testlinkapigeneric_offline_test.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@
6262
'twoPlatforms' : {'dutch' : {'id': '1', 'name': 'dutch'},
6363
'platt' : {'id': '2', 'name': 'platt'}},
6464
'noPlatform' : {}
65-
}
65+
},
66+
'reportTCResult' : [{'status': True, 'operation': 'reportTCResult',
67+
'message': 'Success!', 'overwrite': False, 'id': '773'}]
6668
}
6769

6870
# scenario_tl198 used by test with older responses, changed in TL 1.9.9
@@ -593,8 +595,23 @@ def test_getRequirementCustomFieldDesignValue_full(self):
593595
self.assertEqual('a custom Req string', response['value'])
594596
self.assertEqual('1', response['enable_on_design'])
595597
self.assertEqual('0', response['enable_on_testplan_design'])
596-
self.assertEqual('0', response['enable_on_execution'])
597-
598+
self.assertEqual('0', response['enable_on_execution'])
599+
600+
def test_reportTCResult_user(self):
601+
self.api.loadScenario(SCENARIO_A)
602+
response = self.api.reportTCResult(4712, 'p', testcaseid=4711,
603+
buildname='build 4713', notes='note 4714',
604+
user='a login name')
605+
self.assertEqual('reportTCResult', response[0]['operation'])
606+
self.assertEqual(self.api.devKey, self.api.callArgs['devKey'])
607+
self.assertEqual('a login name', self.api.callArgs['user'])
608+
609+
def test_whatArgs_reportTCResult(self):
610+
argsDescription = self.api.whatArgs('reportTCResult')
611+
self.assertIn('user=<user>', argsDescription)
612+
613+
614+
598615
if __name__ == "__main__":
599616
#import sys;sys.argv = ['', 'Test.testName']
600617
unittest.main()

0 commit comments

Comments
 (0)