Skip to content

Commit

Permalink
[qatl] call to tl.getTestSuiteByID
Browse files Browse the repository at this point in the history
  • Loading branch information
crypto netzulo committed Mar 15, 2018
1 parent de48277 commit 40b5c29
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 3 deletions.
12 changes: 10 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ Configuration File
"tplan_name" : "v0.4.1",
"tplan_id" : 2,
"tcase_id" : 8,
"tcase_full_external_id": "qalab-1"
"tcase_full_external_id": "qalab-1",
"tsuite_id": 12,
"tsuite_name": "tox environments"
}
}

Expand Down Expand Up @@ -191,4 +193,10 @@ Usage ( *XMLRPC* )
+++++++++++++++++++++++

* **XMLRPC**: *call to method named* '*tl.getTestSuitesForTestPlan*'
* **Description** : get all test suites assigned to test plan filtered by id
* **Description** : get all test suites assigned to test plan filtered by id

**api_tsuite**
+++++++++++++++++++++++

* **XMLRPC**: *call to method named* '*tl.getTestSuiteByID*'
* **Description** : get test suite filtered by id
4 changes: 3 additions & 1 deletion qatestlink/configs/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
"tplan_name" : "v0.4.1",
"tplan_id" : 2,
"tcase_id" : 8,
"tcase_full_external_id": "qalab-1"
"tcase_full_external_id": "qalab-1",
"tsuite_id": 12,
"tsuite_name": "tox environments"
}
}
}
12 changes: 12 additions & 0 deletions qatestlink/core/testlink_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,3 +343,15 @@ def api_tplan_tcases(self, tplan_id, dev_key=None):
tcase = TCase(properties)
tcases.append(tcase)
return tcases

def api_tsuite(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_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']
properties = res_param.get('struct')['member']
return TSuite(properties)
34 changes: 34 additions & 0 deletions qatestlink/core/xmls/xmlrpc_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,3 +405,37 @@ def req_tplan_tcases(self, dev_key, tplan_id):
xml = dicttoxml(
self.req_dict, custom_root='methodCall', attr_type=False)
return xml

def req_tsuite_by_id(self, dev_key, tsuite_id):
"""Obtains 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})
tsute_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_BY_ID.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
8 changes: 8 additions & 0 deletions tests/unitaries/suite_002_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ def test_009_method_tplan_tcases(self):
DATA['tcase_full_external_id']
)

@skipIf(False, SKIP_MESSAGE)
def test_010_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'])


class TestMethodsRaises(TestCase):
"""Test suite for tests methods
Expand Down

0 comments on commit 40b5c29

Please sign in to comment.