Skip to content

Commit fea5044

Browse files
author
Luiko Czub
committed
new api - getRequirements getReqCoverage #82
1 parent 2187b6e commit fea5044

File tree

9 files changed

+279
-11
lines changed

9 files changed

+279
-11
lines changed

CHANGES.rst

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,26 @@ TestLink-API-Python-client v0.6.5 (under develop)
55
-------------------------------------------------
66
support for TL 1.9.17 future release and py27, py34, py35 and py36
77

8-
implement 1.9.17 new api interfaces - #76
9-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8+
implement 1.9.17 new api interfaces - #76, #82
9+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1010

1111
- getExecutionSet(<testplanid>, [testcaseid=<testcaseid>], [testcaseexternalid=<testcaseexternalid>],
1212
[buildid=<buildid>], [buildname=<buildname>], [platformid=<platformid>],
1313
[platformname=<platformname>], [options=<options>], [devKey=<devKey>])
14+
- getRequirements(<testprojectid>, [testplanid=<testplanid>], [platformid=<platformid>], [devKey=<devKey>])
15+
- getReqCoverage(<testprojectid>, <requirementdocid>, [devKey=<devKey>])
1416

1517
known TL 1.9.17-DEV issues:
1618
~~~~~~~~~~~~~~~~~~~~~~~~~~~
1719

18-
API-XMLRPC - getExecutionSet raise database error
20+
API-XMLRPC - getRequirements raise PHP Fatal error (github commit 0c8feb6)
21+
22+
- see `TL Mantis Ticket 7902 <http://mantis.testlink.org/view.php?id=7900>`_
23+
24+
fixed TL 1.9.17-DEV issues:
25+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
26+
27+
API-XMLRPC - getExecutionSet raise database error (github commit 1ee5f78)
1928

2029
- see `TL Mantis Ticket 7900 <http://mantis.testlink.org/view.php?id=7900>`_
2130

example/TestLinkExampleGenericApi.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,16 @@
718718
# {'req_spec' : 6733, 'requirements' : [6735, 6737]}])
719719
print("assignRequirements", "Sorry currently no testdata")
720720

721+
# get requirements for the test project
722+
response = myTestLink.getRequirements(newProjectID,
723+
testplanid = newTestPlanID_A,
724+
platformid = newPlatFormID_B)
725+
print("getRequirements", "Sorry currently no testdata", response)
726+
727+
# get requirements for the test project
728+
response = myTestLink.getReqCoverage(newProjectID, 'feature-01')
729+
print("getReqCoverage", "Sorry currently no testdata", response)
730+
721731
print("")
722732
print("Number of Projects in TestLink: %i " % len(myTestLink.getProjects()))
723733
print("")

example/all-req.xml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<requirement-specification>
3+
<req_spec title="requirement section 01" doc_id="req-spec-01" >
4+
<revision><![CDATA[2]]></revision>
5+
6+
<type><![CDATA[1]]></type>
7+
8+
<node_order><![CDATA[1]]></node_order>
9+
10+
<total_req><![CDATA[0]]></total_req>
11+
<scope>
12+
<![CDATA[<p>a section</p>]]>
13+
</scope>
14+
<requirement>
15+
<docid><![CDATA[use-case-01]]></docid>
16+
<title><![CDATA[use case 01]]></title>
17+
<version>1</version>
18+
<revision>1</revision>
19+
<node_order>1</node_order>
20+
<description><![CDATA[<p>a use case</p>]]></description>
21+
<status><![CDATA[D]]></status>
22+
<type><![CDATA[3]]></type>
23+
<expected_coverage><![CDATA[1]]></expected_coverage>
24+
25+
</requirement>
26+
<requirement>
27+
<docid><![CDATA[none-function-01]]></docid>
28+
<title><![CDATA[none function requirement 01]]></title>
29+
<version>1</version>
30+
<revision>1</revision>
31+
<node_order>2</node_order>
32+
<description><![CDATA[<p>a none functional requirement</p>]]></description>
33+
<status><![CDATA[D]]></status>
34+
<type><![CDATA[5]]></type>
35+
<expected_coverage><![CDATA[1]]></expected_coverage>
36+
37+
</requirement>
38+
<relation>
39+
<source>none-function-01</source>
40+
<destination>use-case-01</destination>
41+
<type>2</type>
42+
</relation>
43+
</req_spec><req_spec title="user requirement 02" doc_id="req-spec-02" >
44+
<revision><![CDATA[1]]></revision>
45+
46+
<type><![CDATA[2]]></type>
47+
48+
<node_order><![CDATA[2]]></node_order>
49+
50+
<total_req><![CDATA[0]]></total_req>
51+
<scope>
52+
<![CDATA[<p>a user requirement</p>]]>
53+
</scope>
54+
<requirement>
55+
<docid><![CDATA[restriction-01]]></docid>
56+
<title><![CDATA[restriction 01]]></title>
57+
<version>1</version>
58+
<revision>1</revision>
59+
<node_order>1</node_order>
60+
<description><![CDATA[<p>a restriction</p>]]></description>
61+
<status><![CDATA[D]]></status>
62+
<type><![CDATA[6]]></type>
63+
<expected_coverage><![CDATA[1]]></expected_coverage>
64+
65+
</requirement>
66+
<requirement>
67+
<docid><![CDATA[user-gui-01]]></docid>
68+
<title><![CDATA[user gui 01]]></title>
69+
<version>1</version>
70+
<revision>1</revision>
71+
<node_order>2</node_order>
72+
<description><![CDATA[<p>a user gui</p>]]></description>
73+
<status><![CDATA[D]]></status>
74+
<type><![CDATA[4]]></type>
75+
<expected_coverage><![CDATA[1]]></expected_coverage>
76+
77+
</requirement>
78+
<relation>
79+
<source>system-func-01</source>
80+
<destination>user-gui-01</destination>
81+
<type>2</type>
82+
</relation>
83+
</req_spec><req_spec title="system requirement 03" doc_id="rec-spec-03" >
84+
<revision><![CDATA[1]]></revision>
85+
86+
<type><![CDATA[3]]></type>
87+
88+
<node_order><![CDATA[3]]></node_order>
89+
90+
<total_req><![CDATA[0]]></total_req>
91+
<scope>
92+
<![CDATA[<p>a system requirement</p>]]>
93+
</scope>
94+
<requirement>
95+
<docid><![CDATA[system-func-01]]></docid>
96+
<title><![CDATA[system function 01]]></title>
97+
<version>1</version>
98+
<revision>1</revision>
99+
<node_order>2</node_order>
100+
<description><![CDATA[<p>a system function</p>]]></description>
101+
<status><![CDATA[D]]></status>
102+
<type><![CDATA[7]]></type>
103+
<expected_coverage><![CDATA[1]]></expected_coverage>
104+
105+
</requirement>
106+
<requirement>
107+
<docid><![CDATA[feature-01]]></docid>
108+
<title><![CDATA[feature 01]]></title>
109+
<version>1</version>
110+
<revision>1</revision>
111+
<node_order>3</node_order>
112+
<description><![CDATA[<p>a feature</p>]]></description>
113+
<status><![CDATA[D]]></status>
114+
<type><![CDATA[2]]></type>
115+
<expected_coverage><![CDATA[1]]></expected_coverage>
116+
117+
</requirement>
118+
<relation>
119+
<source>system-func-01</source>
120+
<destination>user-gui-01</destination>
121+
<type>2</type>
122+
</relation>
123+
</req_spec></requirement-specification>

src/testlink/testlinkapigeneric.py

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,16 +1801,70 @@ def getExecutionSet(self):
18011801
If there are no filter criteria regarding platform and build, result
18021802
will be get WITHOUT checking for a particular platform and build.
18031803
1804-
testplanid test plan id
1805-
1806-
args variations: testcaseid - testcaseexternalid
1807-
buildid - buildname
1808-
platformid - platformname
1809-
testcase information is general mandatory
1804+
mandatory arg: testplanid - identifies the test plan
1805+
1806+
mandatory args variations: testcaseid - testcaseexternalid
1807+
- test caset information is general mandatory
1808+
1809+
optional args variations: buildid - buildname
1810+
platformid - platformname
18101811
18111812
options : dictionary with key 'getOrderDescending' and
18121813
values 0 (false = default) or 1 (true)
18131814
"""
1815+
1816+
# /**
1817+
# * Get requirements
1818+
# *
1819+
# * @param string $args["testprojectid"]
1820+
# * @param string $args["testplanid"] OPTIONAL
1821+
# * @param string $args["platformid"] OPTIONAL
1822+
# *
1823+
# * @return mixed error if someting's wrong, else array of test cases
1824+
# *
1825+
# * @access public
1826+
# */
1827+
# public function getRequirements($args)
1828+
1829+
@decoApiCallAddDevKey
1830+
@decoMakerApiCallWithArgs(['testprojectid'], ['testplanid', 'platformid'])
1831+
def getRequirements(self):
1832+
""" Get requirements.
1833+
1834+
mandatory arg: testprojectid - identifies the test project
1835+
1836+
optional args: testplanid, platformid
1837+
"""
1838+
1839+
# /**
1840+
# * Get requirement coverage
1841+
# *
1842+
# * Retrieve the test cases associated to a requirement
1843+
# *
1844+
# * @param struct $args
1845+
# * @param string $args["devKey"]: used to check if operation can be done.
1846+
# * if devKey is not valid => abort.
1847+
# *
1848+
# * @param string $args["testprojectid"]
1849+
# * @param string $args["requirementdocid"]
1850+
# *
1851+
# * @return mixed error if someting's wrong, else array of test cases
1852+
# *
1853+
# * @access public
1854+
# */
1855+
# public function getReqCoverage($args)
1856+
1857+
@decoApiCallAddDevKey
1858+
@decoMakerApiCallWithArgs(['testprojectid', 'requirementdocid'], [])
1859+
def getReqCoverage(self):
1860+
""" Get requirement coverage.
1861+
Retrieve the test cases associated to a requirement
1862+
1863+
mandatory arg:
1864+
testprojectid - identifies the test project
1865+
requirementdocid - odentifies the requirement
1866+
1867+
"""
18141868

18151869
#
18161870
# internal methods for general server calls

src/testlink/version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
#
1818
# ------------------------------------------------------------------------
1919

20-
VERSION = '0.6.5-dev076'
21-
TL_RELEASE = 'DEV 1.9.17 (github 1ee5f78)'
20+
VERSION = '0.6.5-dev082'
21+
TL_RELEASE = 'DEV 1.9.17 (github 0c8feb6)'
2222

test/utest-offline/testlinkapi_offline_test.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,29 @@ def test_whatArgs_getIssueTrackerSystem(self):
735735
argsDescription = self.api.whatArgs('getIssueTrackerSystem')
736736
self.assertIn('<itsname>,', argsDescription)
737737

738+
def test_whatArgs_getExecutionSet(self):
739+
argsDescription = self.api.whatArgs('getExecutionSet')
740+
self.assertIn('<testplanid>,', argsDescription)
741+
self.assertIn('testcaseid=<testcaseid>', argsDescription)
742+
self.assertIn('testcaseexternalid=<testcaseexternalid>', argsDescription)
743+
self.assertIn('buildid=<buildid>', argsDescription)
744+
self.assertIn('buildname=<buildname>', argsDescription)
745+
self.assertIn('platformid=<platformid>', argsDescription)
746+
self.assertIn('platformname=<platformname>', argsDescription)
747+
self.assertIn('options=<options>', argsDescription)
748+
749+
def test_whatArgs_getRequirements(self):
750+
argsDescription = self.api.whatArgs('getRequirements')
751+
self.assertIn('<testprojectid>,', argsDescription)
752+
self.assertIn('testplanid=<testplanid>', argsDescription)
753+
self.assertIn('platformid=<platformid>', argsDescription)
754+
755+
def test_whatArgs_getReqCoverage(self):
756+
argsDescription = self.api.whatArgs('getReqCoverage')
757+
self.assertIn('<testprojectid>,', argsDescription)
758+
self.assertIn('<requirementdocid>,', argsDescription)
759+
760+
738761
if __name__ == "__main__":
739762
#import sys;sys.argv = ['', 'Test.testName']
740763
unittest.main()

test/utest-offline/testlinkapigeneric_offline_test.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,29 @@ def test_whatArgs_getIssueTrackerSystem(self):
842842
argsDescription = self.api.whatArgs('getIssueTrackerSystem')
843843
self.assertIn('<itsname>,', argsDescription)
844844

845+
def test_whatArgs_getExecutionSet(self):
846+
argsDescription = self.api.whatArgs('getExecutionSet')
847+
self.assertIn('<testplanid>,', argsDescription)
848+
self.assertIn('testcaseid=<testcaseid>', argsDescription)
849+
self.assertIn('testcaseexternalid=<testcaseexternalid>', argsDescription)
850+
self.assertIn('buildid=<buildid>', argsDescription)
851+
self.assertIn('buildname=<buildname>', argsDescription)
852+
self.assertIn('platformid=<platformid>', argsDescription)
853+
self.assertIn('platformname=<platformname>', argsDescription)
854+
self.assertIn('options=<options>', argsDescription)
855+
856+
def test_whatArgs_getRequirements(self):
857+
argsDescription = self.api.whatArgs('getRequirements')
858+
self.assertIn('<testprojectid>,', argsDescription)
859+
self.assertIn('testplanid=<testplanid>', argsDescription)
860+
self.assertIn('platformid=<platformid>', argsDescription)
861+
862+
def test_whatArgs_getReqCoverage(self):
863+
argsDescription = self.api.whatArgs('getReqCoverage')
864+
self.assertIn('<testprojectid>,', argsDescription)
865+
self.assertIn('<requirementdocid>,', argsDescription)
866+
867+
845868
if __name__ == "__main__":
846869
#import sys;sys.argv = ['', 'Test.testName']
847870
unittest.main()

test/utest-online/testlinkapi_generic_online_test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,19 @@ def test_getExecutionSet_unknownID(self):
474474
self.client.getExecutionSet(
475475
'40000713 plan', testcaseexternalid = 'TC-40000712')
476476

477+
def test_getRequirements_unknownID(self):
478+
with self.assertRaisesRegex(TLResponseError, '7000.*40000712'):
479+
self.client.getRequirements(
480+
'40000712 project',
481+
testplanid = '40000713 plan',
482+
platformid = '40000714 platform')
483+
484+
def test_getReqCoverage_unknownID(self):
485+
with self.assertRaisesRegex(TLResponseError, '7000.*40000712'):
486+
self.client.getReqCoverage(
487+
'40000712 project',
488+
'40000721 req')
489+
477490

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

test/utest-online/testlinkapi_online_test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,19 @@ def test_getExecutionSet_unknownID(self):
459459
with self.assertRaisesRegex(TLResponseError, '3000.*40000713'):
460460
self.client.getExecutionSet(
461461
'40000713 plan', testcaseexternalid = 'TC-40000712')
462+
463+
def test_getRequirements_unknownID(self):
464+
with self.assertRaisesRegex(TLResponseError, '7000.*40000712'):
465+
self.client.getRequirements(
466+
'40000712 project',
467+
testplanid = '40000713 plan',
468+
platformid = '40000714 platform')
469+
470+
def test_getReqCoverage_unknownID(self):
471+
with self.assertRaisesRegex(TLResponseError, '7000.*40000712'):
472+
self.client.getReqCoverage(
473+
'40000712 project',
474+
requirementdocid = '40000721 req')
462475

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

0 commit comments

Comments
 (0)