Skip to content

Commit 77f1c9f

Browse files
author
Luiko Czub
committed
new api method getTestCaseKeywords() #42
1 parent e4eda12 commit 77f1c9f

10 files changed

+83
-5
lines changed

CHANGES.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ new TestlinkAPIGeneric and TestlinkAPIClient api method
3636

3737
examples see `<example/TestLinkExample_CF_KW.py>`_
3838

39+
implement 1.9.13 new api - getTestCaseKeywords #42
40+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
41+
42+
new TestlinkAPIGeneric and TestlinkAPIClient api method
43+
44+
- getTestCaseKeywords([testcaseid=<testcaseid>],
45+
[testcaseexternalid=<testcaseexternalid>])
46+
47+
examples see `<example/TestLinkExample_CF_KW.py>`_
48+
49+
3950
TestLink-API-Python-client release notes v0.6.0 (Dec. 2014)
4051
------------------------------------------------------------
4152

example/TestLinkExample.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,8 @@
647647
print("getExecCountersByBuild", response)
648648
response = myTestLink.getExecCountersByBuild(newTestPlanID_B)
649649
print("getExecCountersByBuild", response)
650-
650+
response = myTestLink.getTestCaseKeywords(testcaseexternalid=tc_b_full_ext_id)
651+
print("getTestCaseKeywords noKeyWords", response)
651652

652653
# get information - general
653654
response = myTestLink.getFullPath(int(newTestSuiteID_AA))

example/TestLinkExampleGenericApi.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,8 @@
565565
print("getExecCountersByBuild", response)
566566
response = myTestLink.getExecCountersByBuild(newTestPlanID_B)
567567
print("getExecCountersByBuild", response)
568-
568+
response = myTestLink.getTestCaseKeywords(testcaseexternalid=tc_b_full_ext_id)
569+
print("getTestCaseKeywords noKeyWords", response)
569570

570571
# get information - general
571572
response = myTestLink.getFullPath(int(newTestSuiteID_AA))

example/TestLinkExample_CF_KW.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@
162162
# return keyword lists for all test cases of test newTestSuite_B
163163
response = myTestLink.listKeywordsForTS(newTestSuiteID_B)
164164
print( "listKeywordsForTS", response )
165+
response = myTestLink.getTestCaseKeywords(testcaseid=newTestCaseID_B)
166+
print("getTestCaseKeywords", response)
165167

166168
# new execution result with custom field data
167169
# TC_B passed, explicit build and some notes , TC identified with internal id

src/testlink/testlinkapi.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,11 @@ def listKeywordsForTC(self, internal_or_external_tc_id):
311311
links keywords against a test case and not a test case version
312312
"""
313313

314+
#ToDo LC 12.01.15 - simplify code with TL 1.9.13 api getTestCaseKeywords
315+
# - indirect search via test suite and getTestCasesForTestSuite() isn't
316+
# necessary any more
317+
# - see enhancement issue #45
318+
314319
a_tc_id = str(internal_or_external_tc_id)
315320
argsPositional = [a_tc_id]
316321
argsOptional = {}

src/testlink/testlinkapigeneric.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,27 @@ def getProjectKeywords(self):
12071207
returns an empty dictionary, if no keywords are defined """
12081208

12091209

1210+
# # /**
1211+
# # * Gets list of keywords for a given Test case
1212+
# # *
1213+
# # * @param $testcaseid
1214+
# # *
1215+
# # * @return map indexed by bug_id
1216+
# # *
1217+
# # * @access public
1218+
# # */
1219+
# # public function getTestCaseKeywords($args)
1220+
#
1221+
@decoMakerApiCallReplaceTLResponseError(replaceValue={})
1222+
@decoApiCallAddDevKey
1223+
@decoMakerApiCallWithArgs([], ['testcaseid', 'testcaseexternalid'])
1224+
def getTestCaseKeywords(self):
1225+
""" Gets a dictionary of keywords for a given Test case
1226+
1227+
args variations: testcaseid - testcaseexternalid (mandatoy!)
1228+
1229+
returns an empty dictionary, if no keywords are defined """
1230+
12101231
#
12111232
# public methods for general server calls
12121233
#

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-dev41'
20+
VERSION = '0.6.1-dev42'
2121
TL_RELEASE = 'DEV 1.9.13 (gitorious 0be4cb9)'
2222

test/utest-offline/testlinkapigeneric_offline_test.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@
8383
'getProjectKeywords' : {
8484
'twoKeywords' : {'25': 'KeyWord01', '26': 'KeyWord02'},
8585
'noKeyword' : {}
86-
}
86+
},
87+
'getTestCaseKeywords' : {
88+
'twoKeywords' : {'25': 'KeyWord01', '26': 'KeyWord02'},
89+
'noKeyword' : {}
90+
}
8791
}
8892

8993
# scenario_tl198 used by test with older responses, changed in TL 1.9.9
@@ -241,6 +245,8 @@ def _callServer(self, methodAPI, argsAPI=None):
241245
response = data[argsAPI['testsuiteid']]
242246
elif methodAPI in ['getTestCaseIDByName']:
243247
response = data[argsAPI['testcasename']]
248+
elif methodAPI in ['getTestCaseKeywords']:
249+
response = data[argsAPI['testcaseid']]
244250
elif methodAPI in ['testLinkVersion']:
245251
response = data
246252
if data == 'unknown':
@@ -720,6 +726,18 @@ def test_getProjectKeywords_twoKeywords(self):
720726
self.assertEqual('KeyWord01', response['25'])
721727
self.assertEqual('KeyWord02', response['26'])
722728

729+
def test_getTestCaseKeywords_noKeywords(self):
730+
self.api.loadScenario(SCENARIO_A)
731+
response = self.api.getTestCaseKeywords(testcaseid='noKeyword')
732+
self.assertEqual({}, response)
733+
self.assertEqual(self.api.devKey, self.api.callArgs['devKey'])
734+
735+
def test_getProjectKeywords_twoKeywords(self):
736+
self.api.loadScenario(SCENARIO_A)
737+
response = self.api.getTestCaseKeywords(testcaseid='twoKeywords')
738+
self.assertEqual('KeyWord01', response['25'])
739+
self.assertEqual('KeyWord02', response['26'])
740+
723741

724742
if __name__ == "__main__":
725743
#import sys;sys.argv = ['', 'Test.testName']

test/utest-online/testlinkapi_generic_online_test.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,15 @@ def test_unassignTestCaseExecutionTask_unknownID(self):
390390
def test_getProjectKeywords_unknownID(self):
391391
with self.assertRaisesRegex(TLResponseError, '7000.*4711'):
392392
self.client.getProjectKeywords(4711)
393+
394+
def test_getTestCaseKeywords_unknownID(self):
395+
with self.assertRaisesRegex(TLResponseError, '5000.*4712'):
396+
self.client.getTestCaseKeywords(testcaseid=4712)
397+
398+
def test_getTestCaseKeywords_unknownID_external(self):
399+
with self.assertRaisesRegex(TLResponseError, '5040.*4712'):
400+
self.client.getTestCaseKeywords(testcaseexternalid='TC-4712')
401+
393402

394403
if __name__ == "__main__":
395404
#import sys;sys.argv = ['', 'Test.testName']

test/utest-online/testlinkapi_online_test.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,17 @@ def test_unassignTestCaseExecutionTask_unknownID(self):
339339

340340
def test_getProjectKeywords_unknownID(self):
341341
with self.assertRaisesRegex(TLResponseError, '7000.*4711'):
342-
self.client.getProjectKeywords(4711)
342+
self.client.getProjectKeywords(4711)
343+
344+
def test_getTestCaseKeywords_unknownID(self):
345+
with self.assertRaisesRegex(TLResponseError, '5000.*4712'):
346+
self.client.getTestCaseKeywords(testcaseid=4712)
347+
348+
def test_getTestCaseKeywords_unknownID_external(self):
349+
with self.assertRaisesRegex(TLResponseError, '5040.*4712'):
350+
self.client.getTestCaseKeywords(testcaseexternalid='TC-4712')
351+
352+
343353

344354
if __name__ == "__main__":
345355
#import sys;sys.argv = ['', 'Test.testName']

0 commit comments

Comments
 (0)