Skip to content

Commit e4eda12

Browse files
author
Luiko Czub
committed
new api method getProjectKeywords #41
1 parent f542a17 commit e4eda12

File tree

9 files changed

+87
-41
lines changed

9 files changed

+87
-41
lines changed

CHANGES.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,16 @@ new TestlinkAPIGeneric and TestlinkAPIClient api method
2525
[platformname=<platformname>], [user=<loginname>],
2626
[action='unassignAll'|'unassignOne'], [devKey=<devKey>])
2727
28-
examples see `<example/TestLinkExample.py>`_
28+
examples see `<example/TestLinkExample.py>`_
29+
30+
implement 1.9.13 new api - getProjectKeywords #41
31+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
32+
33+
new TestlinkAPIGeneric and TestlinkAPIClient api method
34+
35+
- getProjectKeywords(<testprojectid>)
36+
37+
examples see `<example/TestLinkExample_CF_KW.py>`_
2938

3039
TestLink-API-Python-client release notes v0.6.0 (Dec. 2014)
3140
------------------------------------------------------------

example/TestLinkExample.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,10 @@
586586
print("getProjectTestPlans", response)
587587
response = myTestLink.getFirstLevelTestSuitesForTestProject(newProjectID)
588588
print("getFirstLevelTestSuitesForTestProject", response)
589+
response = myTestLink.getProjectPlatforms(newProjectID)
590+
print("getProjectPlatforms", response)
591+
response = myTestLink.getProjectKeywords(newProjectID)
592+
print("getProjectKeywords", response)
589593

590594
# get information - testPlan
591595
response = myTestLink.getTestPlanByName(NEWPROJECT, NEWTESTPLAN_A)

example/TestLinkExampleGenericApi.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,6 @@
187187
response = myTestLink.addPlatformToTestPlan(newTestPlanID_A, NEWPLATFORM_C)
188188
print("addPlatformToTestPlan", response)
189189

190-
# looking, which platforms exists
191-
response = myTestLink.getProjectPlatforms(newProjectID)
192-
print("getProjectPlatforms", response)
193-
194-
195-
196190
#Creates the test Suite A
197191
newTestSuite = myTestLink.createTestSuite(newProjectID, NEWTESTSUITE_A,
198192
"Details of the Test Suite A")
@@ -512,6 +506,10 @@
512506
print("getProjectTestPlans", response)
513507
response = myTestLink.getFirstLevelTestSuitesForTestProject(newProjectID)
514508
print("getFirstLevelTestSuitesForTestProject", response)
509+
response = myTestLink.getProjectPlatforms(newProjectID)
510+
print("getProjectPlatforms", response)
511+
response = myTestLink.getProjectKeywords(newProjectID)
512+
print("getProjectKeywords", response)
515513

516514
# get information - TestPlan
517515
response = myTestLink.getTestPlanByName(NEWPROJECT, NEWTESTPLAN_A)

example/TestLinkExample_CF_KW.py

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -109,57 +109,59 @@
109109
myTLVersion = myTestLink.testLinkVersion()
110110

111111
# used connection settings
112-
print myTestLink.connectionInfo()
113-
print ""
112+
print( myTestLink.connectionInfo() )
113+
print( "" )
114114

115115
# get information - TestProject
116116
newProject = myTestLink.getTestProjectByName(NEWPROJECT)
117-
print "getTestProjectByName", newProject
117+
print( "getTestProjectByName", newProject )
118118
newProjectID = newProject['id']
119-
print "Project '%s' - id: %s" % (NEWPROJECT,newProjectID)
119+
print( "Project '%s' - id: %s" % (NEWPROJECT,newProjectID) )
120+
response = myTestLink.getProjectKeywords(newProjectID)
121+
print("getProjectKeywords", response)
120122

121123
# get information - TestPlan
122124
newTestPlan = myTestLink.getTestPlanByName(NEWPROJECT, NEWTESTPLAN_A)
123-
print "getTestPlanByName", newTestPlan
125+
print( "getTestPlanByName", newTestPlan )
124126
newTestPlanID_A = newTestPlan[0]['id']
125-
print "Test Plan '%s' - id: %s" % (NEWTESTPLAN_A,newTestPlanID_A)
127+
print( "Test Plan '%s' - id: %s" % (NEWTESTPLAN_A,newTestPlanID_A) )
126128
response = myTestLink.getTotalsForTestPlan(newTestPlanID_A)
127-
print "getTotalsForTestPlan", response
129+
print( "getTotalsForTestPlan", response )
128130
response = myTestLink.getBuildsForTestPlan(newTestPlanID_A)
129-
print "getBuildsForTestPlan", response
131+
print( "getBuildsForTestPlan", response )
130132
newBuildID_A = response[0]['id']
131133
newBuildName_A = response[0]['name']
132134
# get information - TestSuite
133135
response = myTestLink.getTestSuitesForTestPlan(newTestPlanID_A)
134-
print "getTestSuitesForTestPlan", response
136+
print( "getTestSuitesForTestPlan", response )
135137
newTestSuiteID_A=response[0]['id']
136138
newTestSuiteID_AA=response[1]['id']
137139
newTestSuiteID_B=response[2]['id']
138140
newTestSuite = myTestLink.getTestSuiteByID(newTestSuiteID_B)
139-
print "getTestSuiteByID", newTestSuite
141+
print( "getTestSuiteByID", newTestSuite )
140142

141143
# list test cases with assigned keywords
142144
response = myTestLink.getTestCasesForTestSuite(newTestSuiteID_B, True,
143145
'full', getkeywords=True)
144-
print "getTestCasesForTestSuite (deep=True)", response
146+
print( "getTestCasesForTestSuite (deep=True)", response )
145147
response = myTestLink.getTestCasesForTestSuite(newTestSuiteID_B, False,
146148
'full', getkeywords=True)
147-
print "getTestCasesForTestSuite (deep=False)", response
149+
print( "getTestCasesForTestSuite (deep=False)", response )
148150

149151
# get informationen - TestCase_B
150152
response = myTestLink.getTestCaseIDByName(NEWTESTCASE_B, testprojectname=NEWPROJECT)
151-
print "getTestCaseIDByName", response
153+
print( "getTestCaseIDByName", response )
152154
newTestCaseID_B = response[0]['id']
153-
print "Test Case '%s' - id: %s" % (NEWTESTCASE_B, newTestCaseID_B)
155+
print( "Test Case '%s' - id: %s" % (NEWTESTCASE_B, newTestCaseID_B) )
154156
newTestCase_B = myTestLink.getTestCase(testcaseid=newTestCaseID_B)[0]
155-
print "getTestCase", newTestCase_B
157+
print( "getTestCase", newTestCase_B )
156158

157159
# return keyword list for TestCase_B
158160
response = myTestLink.listKeywordsForTC(newTestCaseID_B)
159-
print "listKeywordsForTC", response
161+
print( "listKeywordsForTC", response )
160162
# return keyword lists for all test cases of test newTestSuite_B
161163
response = myTestLink.listKeywordsForTS(newTestSuiteID_B)
162-
print "listKeywordsForTS", response
164+
print( "listKeywordsForTS", response )
163165

164166
# new execution result with custom field data
165167
# TC_B passed, explicit build and some notes , TC identified with internal id
@@ -168,12 +170,12 @@
168170
platformname=NEWPLATFORM_B, bugid='4711',
169171
customfields={'cf_tc_ex_string' : 'a custom exec value set via api',
170172
'cf_tc_sd_listen' : 'ernie'})
171-
print "reportTCResult", newResult
173+
print( "reportTCResult", newResult )
172174

173175
# get execution results
174176
lastResult = myTestLink.getLastExecutionResult(newTestPlanID_A, newTestCaseID_B,
175177
options={'getBugs' : True})[0]
176-
print "getLastExecutionResult", lastResult
178+
print( "getLastExecutionResult", lastResult )
177179

178180
# map of used ids
179181
args = {'devKey' : myTestLink.devKey,
@@ -192,56 +194,56 @@
192194
response = myTestLink.getTestCaseCustomFieldExecutionValue(
193195
'cf_tc_ex_string', args['testprojectid'], args['tcversion_id'],
194196
args['executionid'] , args['testplanid'] )
195-
print "getTestCaseCustomFieldExecutionValue", response
197+
print( "getTestCaseCustomFieldExecutionValue", response )
196198

197199
# update CustomField Value - TestCase SpecDesign
198200
response = myTestLink.updateTestCaseCustomFieldDesignValue(
199201
args['testcaseexternalid'], args['version'],
200202
args['testprojectid'],
201203
{'cf_tc_sd_string' : 'A custom SpecDesign value set via api',
202204
'cf_tc_sd_list' : 'bibo'})
203-
print "updateTestCaseCustomFieldDesignValue", response
205+
print( "updateTestCaseCustomFieldDesignValue", response )
204206

205207
# get CustomField Value - TestCase SpecDesign
206208
#response = myTestLink._callServer('getTestCaseCustomFieldDesignValue', args)
207209
response = myTestLink.getTestCaseCustomFieldDesignValue(
208210
args['testcaseexternalid'], args['version'],
209211
args['testprojectid'], 'cf_tc_sd_string', 'full')
210-
print "getTestCaseCustomFieldDesignValue full", response
212+
print( "getTestCaseCustomFieldDesignValue full", response )
211213

212214
response = myTestLink.getTestCaseCustomFieldDesignValue(
213215
args['testcaseexternalid'], args['version'],
214216
args['testprojectid'], 'cf_tc_sd_string', 'value')
215-
print "getTestCaseCustomFieldDesignValue value", response
217+
print( "getTestCaseCustomFieldDesignValue value", response )
216218

217219
response = myTestLink.getTestCaseCustomFieldDesignValue(
218220
args['testcaseexternalid'], args['version'],
219221
args['testprojectid'], 'cf_tc_sd_list', 'simple')
220-
print "getTestCaseCustomFieldDesignValue simple", response
222+
print( "getTestCaseCustomFieldDesignValue simple", response )
221223

222224
# get CustomField Value - TestCase Testplan Design
223225
response = myTestLink.getTestCaseCustomFieldTestPlanDesignValue(
224226
'cf_tc_pd_string', args['testprojectid'], args['tcversion_id'],
225227
args['testplanid'], args['linkid'])
226-
print "getTestCaseCustomFieldTestPlanDesignValue", response
228+
print( "getTestCaseCustomFieldTestPlanDesignValue", response )
227229

228230
# get CustomField Value - TestSuite
229231
response = myTestLink.getTestSuiteCustomFieldDesignValue(
230232
'cf_ts_string', args['testprojectid'], args['testsuiteid'])
231-
print "getTestSuiteCustomFieldDesignValue", response
233+
print( "getTestSuiteCustomFieldDesignValue", response )
232234

233235
# get CustomField Value - TestPlan
234236
response = myTestLink.getTestPlanCustomFieldDesignValue(
235237
'cf_tp_string', args['testprojectid'], args['testplanid'])
236-
print "getTestPlanCustomFieldDesignValue", response
238+
print( "getTestPlanCustomFieldDesignValue", response )
237239

238240
# get CustomField Value - Requirement Specification
239241
response = myTestLink.getReqSpecCustomFieldDesignValue(
240242
'cf_req_sd_string', args['testprojectid'], args['reqspecid'])
241-
print "getReqSpecCustomFieldDesignValue", response
243+
print( "getReqSpecCustomFieldDesignValue", response )
242244

243245

244246
# get CustomField Value - Requirement Specification
245247
response = myTestLink.getRequirementCustomFieldDesignValue(
246248
'cf_req_string',args['testprojectid'], args['requirementid'])
247-
print "getRequirementCustomFieldDesignValue", response
249+
print( "getRequirementCustomFieldDesignValue", response )

src/testlink/testlinkapigeneric.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,6 +1198,14 @@ def unassignTestCaseExecutionTask(self):
11981198
11991199
"""
12001200

1201+
@decoMakerApiCallReplaceTLResponseError(replaceValue={})
1202+
@decoApiCallAddDevKey
1203+
@decoMakerApiCallWithArgs(['testprojectid'])
1204+
def getProjectKeywords(self):
1205+
""" Gets a dictionary of valid keywords for a project
1206+
1207+
returns an empty dictionary, if no keywords are defined """
1208+
12011209

12021210
#
12031211
# public methods for general server calls

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

test/utest-offline/testlinkapigeneric_offline_test.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@
7979
'noPlatform' : {}
8080
},
8181
'reportTCResult' : [{'status': True, 'operation': 'reportTCResult',
82-
'message': 'Success!', 'overwrite': False, 'id': '773'}]
82+
'message': 'Success!', 'overwrite': False, 'id': '773'}],
83+
'getProjectKeywords' : {
84+
'twoKeywords' : {'25': 'KeyWord01', '26': 'KeyWord02'},
85+
'noKeyword' : {}
86+
}
8387
}
8488

8589
# scenario_tl198 used by test with older responses, changed in TL 1.9.9
@@ -226,7 +230,8 @@ def _callServer(self, methodAPI, argsAPI=None):
226230
if methodAPI in ['doesUserExist']:
227231
response = data[argsAPI['user']]
228232
elif methodAPI in ['getProjectTestPlans', 'getProjectPlatforms',
229-
'getFirstLevelTestSuitesForTestProject']:
233+
'getFirstLevelTestSuitesForTestProject',
234+
'getProjectKeywords']:
230235
response = data[argsAPI['testprojectid']]
231236
elif methodAPI in ['getBuildsForTestPlan', 'getTestPlanPlatforms',
232237
'getTestSuitesForTestPlan', 'getTestCasesForTestPlan']:
@@ -701,7 +706,20 @@ def test___str__pyversion(self):
701706
self.api.loadScenario(SCENARIO_TL199)
702707
api_info = self.api.__str__()
703708
py_info = '(PY %i.' % sys.version_info[0]
704-
self.assertIn(py_info, api_info)
709+
self.assertIn(py_info, api_info)
710+
711+
def test_getProjectKeywords_noKeywords(self):
712+
self.api.loadScenario(SCENARIO_A)
713+
response = self.api.getProjectKeywords('noKeyword')
714+
self.assertEqual({}, response)
715+
self.assertEqual(self.api.devKey, self.api.callArgs['devKey'])
716+
717+
def test_getProjectKeywords_twoKeywords(self):
718+
self.api.loadScenario(SCENARIO_A)
719+
response = self.api.getProjectKeywords('twoKeywords')
720+
self.assertEqual('KeyWord01', response['25'])
721+
self.assertEqual('KeyWord02', response['26'])
722+
705723

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

test/utest-online/testlinkapi_generic_online_test.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,11 @@ def test_unassignTestCaseExecutionTask_unknownID(self):
386386
buildname='build 4713',
387387
platformname='platform 4714',
388388
user='username',action='unassignOne')
389-
389+
390+
def test_getProjectKeywords_unknownID(self):
391+
with self.assertRaisesRegex(TLResponseError, '7000.*4711'):
392+
self.client.getProjectKeywords(4711)
393+
390394
if __name__ == "__main__":
391395
#import sys;sys.argv = ['', 'Test.testName']
392396
unittest.main()

test/utest-online/testlinkapi_online_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,9 @@ def test_unassignTestCaseExecutionTask_unknownID(self):
337337
platformname='platform 4714',
338338
user='username',action='unassignOne')
339339

340+
def test_getProjectKeywords_unknownID(self):
341+
with self.assertRaisesRegex(TLResponseError, '7000.*4711'):
342+
self.client.getProjectKeywords(4711)
340343

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

0 commit comments

Comments
 (0)