Skip to content

Commit

Permalink
[qatl] added method name 'tl.getTestSuitesForTestSuite'
Browse files Browse the repository at this point in the history
  • Loading branch information
crypto netzulo committed Mar 18, 2018
1 parent f3e0f3b commit 4e33a0e
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 43 deletions.
6 changes: 6 additions & 0 deletions README.rst
Expand Up @@ -219,6 +219,12 @@ Usage ( *XMLRPC* )
* **XMLRPC**: *call to method named* '*tl.getTestSuiteByID*'
* **Description** : get test suite filtered by id

**api_tsuite_tsuites**
+++++++++++++++++++++++

* **XMLRPC**: *call to method named* '*tl.getTestSuitesForTestSuite*'
* **Description** : get test suites down of tree for one test suite filtered by id

**api_tcase**
+++++++++++++++++++++++

Expand Down
4 changes: 2 additions & 2 deletions qatestlink/configs/settings.json
Expand Up @@ -19,8 +19,8 @@
"tplan_id" : 2,
"tcase_id" : 8,
"tcase_full_external_id": "qalab-1",
"tsuite_id": 12,
"tsuite_name": "tox environments",
"tsuite_id": 3,
"tsuite_name": "qacode",
"build_id_one": 1,
"build_name_one": "issue1",
"build_id_two": 2,
Expand Down
18 changes: 18 additions & 0 deletions qatestlink/core/testlink_manager.py
Expand Up @@ -381,6 +381,24 @@ def api_tsuite(self, tsuite_id, dev_key=None):
properties = res_param.get('struct')['member']
return TSuite(properties)

def api_tsuite_tsuites(self, tsuite_id, dev_key=None):
"""TODO: doc"""
if dev_key is None:
dev_key = self._settings.get('dev_key')
req_data = self._xml_manager.req_tsuite_tsuites_by_id(
dev_key, tsuite_id)
res = self._conn.post(self._xml_manager.headers, req_data)
res_dict = self._xml_manager.parse_response(res)
res_param = res_dict.get(
'methodResponse')['params']['param']['value']
data_list = res_param.get('struct')['member']
tsuites = list()
for data_properties in data_list:
properties = data_properties['value']['struct']['member']
tsuite = TSuite(properties)
tsuites.append(tsuite)
return tsuites

def api_tcase(self, tcase_id=None, external_id=None, dev_key=None):
"""TODO: doc"""
if dev_key is None:
Expand Down
70 changes: 35 additions & 35 deletions qatestlink/core/xmls/xmlrpc_manager.py
Expand Up @@ -481,7 +481,7 @@ def req_tsuite_by_id(self, dev_key, tsuite_id):
Arguments:
dev_key {str} -- string of developer key provided by Testlink
(default: {value obtained from JSON settings file})
tsute_id {int} -- ID of Testlink Test Suite data
tsuite_id {int} -- ID of Testlink Test Suite data
Raises:
Exception -- Bad params
Expand All @@ -508,6 +508,40 @@ def req_tsuite_by_id(self, dev_key, tsuite_id):
self.req_dict, custom_root='methodCall', attr_type=False)
return xml

def req_tsuite_tsuites_by_id(self, dev_key, tsuite_id):
"""Obtains all test suites down of one test suite created on remote
testlink database, can filter by test plan id
Arguments:
dev_key {str} -- string of developer key provided by Testlink
(default: {value obtained from JSON settings file})
tsuite_id {int} -- ID of Testlink Test Suite data
Raises:
Exception -- Bad params
Returns:
str -- string xml object ready to use on API call
"""
if not tsuite_id:
raise Exception("Can't call XMLRPC without param, tsuite_id")
self.req_dict.update({
"methodName": RouteType.TSUITE_TSUITES.value
})
self.req_dict.update({
"params": {
"struct": {
"member": [
{"name": "devKey", "value": dev_key},
{"name": "testsuiteid", "value": tsuite_id}
]
}
}
})
xml = dicttoxml(
self.req_dict, custom_root='methodCall', attr_type=False)
return xml

def req_tcase_by_id_or_external(self, dev_key,
tcase_id=None, external_id=None):
"""Obtains one test case created on remote testlink database, can
Expand Down Expand Up @@ -556,37 +590,3 @@ def req_tcase_by_id_or_external(self, dev_key,
xml = dicttoxml(
self.req_dict, custom_root='methodCall', attr_type=False)
return xml

def req_tplan_build_latest(self, dev_key, tplan_id):
"""Obtains latest build by choosing the maximum build id for a specific
test plan remote testlink database, can filter by test plan id
Arguments:
dev_key {str} -- string of developer key provided by Testlink
(default: {value obtained from JSON settings file})
tplan_id {int} -- ID of Testlink Test Plan data
Raises:
Exception -- Bad params
Returns:
str -- string xml object ready to use on API call
"""
if not tplan_id:
raise Exception("Can't call XMLRPC without param, tsuite_id")
self.req_dict.update({
"methodName": RouteType.TPLAN_BUILD_LATEST.value
})
self.req_dict.update({
"params": {
"struct": {
"member": [
{"name": "devKey", "value": dev_key},
{"name": "testplanid", "value": tplan_id}
]
}
}
})
xml = dicttoxml(
self.req_dict, custom_root='methodCall', attr_type=False)
return xml
22 changes: 16 additions & 6 deletions tests/unitaries/suite_002_methods.py
Expand Up @@ -132,7 +132,7 @@ def test_009_method_tplan_tcases(self):
DATA['tcase_full_external_id']
)

@skipIf(False, SKIP_MESSAGE)
@skipIf(SKIP, SKIP_MESSAGE)
def test_010_method_tplan_tbuild_latest(self):
"""TODO: doc method"""
build = self.testlink_manager.api_tplan_build_latest(
Expand All @@ -141,6 +141,7 @@ def test_010_method_tplan_tbuild_latest(self):
self.assertEquals(build.id, DATA['build_id_two'])
self.assertEquals(build.name, DATA['build_name_two'])

@skipIf(SKIP, SKIP_MESSAGE)
def test_011_method_tplan_totals(self):
"""TODO: doc method"""
totals = self.testlink_manager.api_tplan_totals(
Expand All @@ -158,24 +159,33 @@ def test_011_method_tplan_totals(self):
['p', 'n', 'b', 'f']
)

@skipIf(False, SKIP_MESSAGE)
@skipIf(SKIP, SKIP_MESSAGE)
def test_012_method_tsuite(self):
"""TODO: doc method"""
tsuite = self.testlink_manager.api_tsuite(
DATA['tsuite_id'])
self.assertIsInstance(tsuite, TSuite)
self.assertEquals(tsuite.name, DATA['tsuite_name'])

@skipIf(False, SKIP_MESSAGE)
def test_013_method_tcase_byid(self):
@skipIf(SKIP, SKIP_MESSAGE)
def test_013_method_tsuite_tsuites(self):
"""TODO: doc method"""
tsuites = self.testlink_manager.api_tsuite_tsuites(
DATA['tsuite_id'])
self.assertIsInstance(tsuites, list)
for tsuite in tsuites:
self.assertIsInstance(tsuite, TSuite)

@skipIf(SKIP, SKIP_MESSAGE)
def test_014_method_tcase_byid(self):
"""TODO: doc method"""
tcase = self.testlink_manager.api_tcase(
tcase_id=DATA['tcase_id'])
self.assertIsInstance(tcase, TCase)
self.assertEquals(tcase.id, DATA['tcase_id'])

@skipIf(False, SKIP_MESSAGE)
def test_014_method_tcase_byexternalid(self):
@skipIf(SKIP, SKIP_MESSAGE)
def test_015_method_tcase_byexternalid(self):
"""TODO: doc method"""
tcase = self.testlink_manager.api_tcase(
external_id=DATA['tcase_full_external_id'])
Expand Down

0 comments on commit 4e33a0e

Please sign in to comment.