Skip to content

Commit

Permalink
service method listKeywordsForTC() uses now getTestCaseKeywords() #45
Browse files Browse the repository at this point in the history
  • Loading branch information
Luiko Czub committed Jun 18, 2015
1 parent 6bf9d4f commit d8b344d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 31 deletions.
6 changes: 5 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ a different error code

- 1.9.13 error code *5000* - 1.9.14 error code *5040*

Bugfixes TestLink-API-Python-client v0.6.1 - #51 #55 #56
Bugfixes TestLink-API-Python-client v0.6.1 - #51 #55 #56 #45
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

whatArgs reports incorrect arg name for createTestCase
Expand All @@ -64,6 +64,10 @@ configuration

- *TestlinkAPIClient* accepts now like *TestlinkAPIGeneric* optional arguments

TestlinkAPIClient service method listKeywordsForTC() uses now getTestCaseKeywords()

- internal change to reduce code complexity

TestLink-API-Python-client release notes v0.6.1 (Mar. 2015)
------------------------------------------------------------
support for TL 1.9.13 release
Expand Down
1 change: 1 addition & 0 deletions example/TestLinkExample_CF_KW.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
from testlink import TestlinkAPIClient, TestLinkHelper
from testlink.testlinkerrors import TLResponseError
import sys, os.path
from platform import python_version

# precondition a)
# SERVER_URL and KEY are defined in environment
Expand Down
40 changes: 13 additions & 27 deletions src/testlink/testlinkapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,34 +318,20 @@ def listKeywordsForTC(self, internal_or_external_tc_id):
# - see enhancement issue #45

a_tc_id = str(internal_or_external_tc_id)
argsPositional = [a_tc_id]
argsOptional = {}
if '-' in a_tc_id:
# full external ID like 'NPROAPI-2'
argsPositional = [None]
argsOptional = {'testcaseexternalid' : a_tc_id}
a_tc = self.getTestCase(*argsPositional, **argsOptional)[0]
a_ts_id = a_tc['testsuite_id']
# attention!
# don't use 'id', that is the tcversion_id
# - table tcversions, field id
# use testcase_id, that is id test case id without a version info
# - table nodes_hierarchy, fied id (condition node_type_id == 3)
a_tc_id = a_tc['testcase_id']
all_tc_for_ts = self.getTestCasesForTestSuite(a_ts_id, False,
'full', getkeywords=True)

keyword_details = {}

for a_ts_tc in all_tc_for_ts:
if a_ts_tc['id'] == a_tc_id:
keyword_details = a_ts_tc.get('keywords', {})

if sys.version_info[0] < 3:
keywords = map((lambda x: x['keyword']), keyword_details.values())
else:
keywords = [kw['keyword'] for kw in keyword_details.values()]
return keywords
if '-' in a_tc_id:
# full external ID like 'NPROAPI-2', but we need the internal
a_tc = self.getTestCase(None, testcaseexternalid=a_tc_id )[0]
a_tc_id = a_tc['testcase_id']

# getTestCaseKeywords returns a dictionary like
# {'12622': {'34': 'KeyWord01', '36': 'KeyWord03'}}
# key is the testcaseid, why that? cause it is possible to ask for
# a set of test cases. we are just interested in one tc
a_keyword_dic = self.getTestCaseKeywords(testcaseid=a_tc_id )[a_tc_id]
keywords = a_keyword_dic.values()

return list(keywords)

def listKeywordsForTS(self, internal_ts_id):
""" Returns dictionary with keyword lists for all test cases of
Expand Down
2 changes: 1 addition & 1 deletion src/testlink/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
#
# ------------------------------------------------------------------------

VERSION = '0.6.2-dev54'
VERSION = '0.6.2-dev45'
TL_RELEASE = '1.9.14 github 2a91690'

13 changes: 11 additions & 2 deletions test/utest-offline/testlinkapi_offline_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,16 @@
'8169' : [{'full_tc_external_id': 'NPROAPI-4', 'id': '8170', 'tc_external_id': '3', 'version': '1',
'testsuite_id': 'deepFalse3', 'testcase_id': '8169', 'name': 'TESTCASE_B3'}],
'NPROAPI-4' : [{'full_tc_external_id': 'NPROAPI-4', 'id': '8170', 'tc_external_id': '3', 'version': '1',
'testsuite_id': 'deepFalse3', 'testcase_id': '8169', 'name': 'TESTCASE_B3'}] }
'testsuite_id': 'deepFalse3', 'testcase_id': '8169', 'name': 'TESTCASE_B3'}] },
'getTestCaseKeywords' : {
#{'12622': {'34': 'KeyWord01', '36': 'KeyWord03'}}
'8144' : {'8144' : {'1': 'KeyWord01', '3': 'KeyWord03'} },
'NPROAPI-2' : {'8144' : {'1': 'KeyWord01', '3': 'KeyWord03'} },
'8159' : {'8159' : {'2': 'KeyWord02'}},
'NPROAPI-3' : {'8159' : {'2': 'KeyWord02'}},
'8169' : {'8169' : {}},
'NPROAPI-4' : {'8169' : {}}
}
}

# scenario_no_project simulates a fresh empty test link application
Expand Down Expand Up @@ -295,7 +304,7 @@ def _callServer(self, methodAPI, argsAPI=None):
response = data[argsAPI['testsuiteid']]
elif methodAPI in ['getTestCaseIDByName']:
response = data[argsAPI['testcasename']]
elif methodAPI in ['getTestCase']:
elif methodAPI in ['getTestCase', 'getTestCaseKeywords']:
datakey = argsAPI.get('testcaseid')
if datakey:
datakey = str(datakey)
Expand Down

0 comments on commit d8b344d

Please sign in to comment.