Skip to content

Commit e68e0ae

Browse files
author
Luiko Czub
committed
changed api getTestCaseAttachments - optional arg version (TL 1.9.19) #119
changed api uploadTestCaseAttachment - mandatory arg version (TL 1.9.20 dev)
1 parent c92903c commit e68e0ae

9 files changed

+127
-22
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ language: python
33
python:
44
- "2.7"
55
- "3.6"
6+
- "3.7"
67

78
# command to install dependencies
89
install:

CHANGES.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
Changes in TestLink-API-Python-client Source Distribution
22
=========================================================
33

4+
TestLink-API-Python-client v0.8.1 - Under Develop
5+
------------------------------------------------------------
6+
support for TL 1.9.19 and TL 1.9.20 (dev) api changes related to test case
7+
attachments, which will be stored since TL 1.9.19 with a reference to the
8+
test case version instead the test case id .
9+
10+
Parameter <version> is now mandatory for _uploadTestCaseAttachment_ and optional
11+
for _getTestCaseAttachments_.
12+
13+
Cause of the known TL 1.9.19 issue
14+
`TL Mantis Ticket 8658 <http://mantis.testlink.org/view.php?id=8658>`_ it is
15+
recommended to use the TL 1.9.20 development state with github commit
16+
6a4984164 or later.
17+
418
TestLink-API-Python-client v0.8.0 (May. 2018)
519
---------------------------------------------
620
support for TL 1.9.17 release and py27, py36

example/TestLinkExample.py

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -704,17 +704,6 @@
704704
response = myTestLink.getTestSuiteAttachments(newTestSuiteID_A)
705705
print("getTestSuiteAttachments", response)
706706

707-
# add png file as Attachment to test case B
708-
a_file=open(NEWATTACHMENT_PNG, mode='rb')
709-
newAttachment = myTestLink.uploadTestCaseAttachment(a_file, newTestCaseID_B,
710-
title='PNG Example', description='PNG Attachment Example for a TestCase')
711-
print("uploadTestCaseAttachment", newAttachment)
712-
# get Attachment of test case B
713-
# response = myTestLink.getTestCaseAttachments(testcaseexternalid=tc_aa_full_ext_id)
714-
# print "getTestCaseAttachments", response
715-
response = myTestLink.getTestCaseAttachments(testcaseid=newTestCaseID_B)
716-
print("getTestCaseAttachments", response)
717-
718707
# copy test case - as a new TC version
719708
print("create new version of TC B")
720709
response = myTestLink.copyTCnewVersion(newTestCaseID_B,
@@ -729,6 +718,33 @@
729718
response = myTestLink.getTestCaseByVersion(newTestCaseID_B)
730719
print('getTestCaseByVersion vNone', response)
731720

721+
# add png file as Attachment to test case B version 1
722+
a_file=open(NEWATTACHMENT_PNG, mode='rb')
723+
newAttachment = myTestLink.uploadTestCaseAttachment(a_file, newTestCaseID_B, 1,
724+
title='PNG Example v1', description='PNG Attachment Example for a TestCase v1')
725+
print("uploadTestCaseAttachment v1", newAttachment)
726+
# add py file as Attachment to test case B version 2
727+
a_file=open(NEWATTACHMENT_PY, mode='rb')
728+
newAttachment = myTestLink.uploadTestCaseAttachment(a_file, newTestCaseID_B, 2,
729+
title='Textfile Example v2', description='Text Attachment Example for a TestCase v2')
730+
print("uploadTestCaseAttachment v2", newAttachment)
731+
732+
# get Attachment of test case B v1
733+
# response = myTestLink.getTestCaseAttachments(testcaseexternalid=tc_aa_full_ext_id)
734+
# print "getTestCaseAttachments", response
735+
response = myTestLink.getTestCaseAttachments(testcaseid=newTestCaseID_B, version=1)
736+
print("getTestCaseAttachments v1", response)
737+
738+
# get Attachment of test case B - last version
739+
# response = myTestLink.getTestCaseAttachments(testcaseexternalid=tc_aa_full_ext_id)
740+
# print "getTestCaseAttachments", response
741+
response = myTestLink.getTestCaseAttachments(testcaseid=newTestCaseID_B, version=2)
742+
attachment_id = list(response)[0]
743+
print("getTestCaseAttachments v2", response[attachment_id]['title'])
744+
response = myTestLink.getTestCaseAttachments(testcaseid=newTestCaseID_B)
745+
print("getTestCaseAttachments vNone", response[attachment_id]['name'])
746+
747+
732748
# copy test case - as new TC in a different TestSuite
733749
print("copy TC B as TC BA into Test suite A")
734750
response = myTestLink.copyTCnewTestCase(newTestCaseID_B,
@@ -739,6 +755,9 @@
739755
response = myTestLink.getTestCasesForTestSuite(newTestSuiteID_A, True, 'simple')
740756
print('getTestCasesForTestSuite A', response)
741757

758+
759+
760+
742761
# sample, how the test plan can be updated to use the new tc version
743762
# site effect of this step, assigned testers and existing execution results are
744763
# not accessible anymore via the TL Web Gui.

example/TestLinkExampleGenericApi.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -709,14 +709,16 @@
709709

710710
# add png file as Attachment to test case B
711711
a_file=open(NEWATTACHMENT_PNG, mode='rb')
712-
newAttachment = myTestLink.uploadTestCaseAttachment(a_file, newTestCaseID_B,
712+
newAttachment = myTestLink.uploadTestCaseAttachment(a_file, newTestCaseID_B, 1,
713713
title='PNG Example', description='PNG Attachment Example for a TestCase')
714714
print("uploadTestCaseAttachment", newAttachment)
715715
# get Attachment of test case B
716716
# response = myTestLink.getTestCaseAttachments(testcaseexternalid=tc_aa_full_ext_id)
717717
# print "getTestCaseAttachments", response
718+
response = myTestLink.getTestCaseAttachments(testcaseid=newTestCaseID_B, version=1)
719+
print("getTestCaseAttachments v1", response)
718720
response = myTestLink.getTestCaseAttachments(testcaseid=newTestCaseID_B)
719-
print("getTestCaseAttachments", response)
721+
print("getTestCaseAttachments vNone", response)
720722

721723
# get requirements for the test project - empty result
722724
response = myTestLink.getRequirements(newProjectID)

src/testlink/testlinkapigeneric.py

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,10 +595,40 @@ def assignRequirements(self):
595595
b) requirements with ID 6735 and 6737 of requirement spec 6733
596596
"""
597597

598+
# /**
599+
# * Gets attachments for specified test case VERSION.
600+
# * The attachment file content is Base64 encoded. To save the file to disk in client,
601+
# * Base64 decode the content and write file in binary mode.
602+
# *
603+
# * @param struct $args
604+
# * @param string $args["devKey"]
605+
# * Developer key
606+
# * @param int $args["testcaseid"]:
607+
# * optional, if does not is present
608+
# * testcaseexternalid must be present
609+
# *
610+
# * @param int $args["version"]:
611+
# * optional, if not present, the latest version will be used
612+
# *
613+
# * @param int $args["testcaseexternalid"]:
614+
# * optional, if does not is present
615+
# * testcaseid must be present
616+
# *
617+
# * @return mixed $resultInfo
618+
# */
619+
# public function getTestCaseAttachments($args) {
620+
598621
@decoApiCallAddDevKey
599-
@decoMakerApiCallWithArgs([], ['testcaseid', 'testcaseexternalid'])
622+
@decoMakerApiCallWithArgs([], ['testcaseid', 'version',
623+
'testcaseexternalid'])
600624
def getTestCaseAttachments(self):
601625
""" Gets attachments for specified test case.
626+
627+
args variations: testcaseid - testcaseexternalid
628+
629+
version - optional, if not present, the latest test case version
630+
will be used
631+
602632
The attachment file content is Base64 encoded. To save the file to disk
603633
in client, Base64 decode the content and write file in binary mode. """
604634

@@ -808,14 +838,44 @@ def uploadTestSuiteAttachment(self):
808838
ATTACHMENTFILE, but user could overwrite it, if user want to store the
809839
attachment with a different name
810840
"""
841+
# /**
842+
# * Uploads an attachment for a Test Case.
843+
# *
844+
# * The attachment content must be Base64 encoded by the client before sending it.
845+
# *
846+
# * @param struct $args
847+
# * @param string $args["devKey"]
848+
# * Developer key
849+
# * @param int $args["testcaseid"]
850+
# * Test Case INTERNAL ID
851+
# * @param int $args["version"]
852+
# * version number
853+
# *
854+
# * @param string $args["title"]
855+
# * (Optional) The title of the Attachment
856+
# * @param string $args["description"]
857+
# * (Optional) The description of the Attachment
858+
# * @param string $args["filename"]
859+
# * The file name of the Attachment(e.g.:notes.txt)
860+
# * @param string $args["filetype"]
861+
# * The file type of the Attachment(e.g.: text/plain)
862+
# * @param string $args["content"]
863+
# * The content(Base64 encoded) of the Attachment
864+
# *
865+
# * @return mixed $resultInfo an array containing the fk_id, fk_table, title,
866+
# * description, file_name, file_size and file_type. If any errors occur it
867+
# * returns the erros map.
868+
# */
869+
# public function uploadTestCaseAttachment($args) {
811870

812871
@decoApiCallAddAttachment
813-
@decoMakerApiCallWithArgs(['testcaseid'],
872+
@decoMakerApiCallWithArgs(['testcaseid', 'version'],
814873
['title', 'description', 'filename', 'filetype', 'content'])
815874
def uploadTestCaseAttachment(self):
816875
""" Uploads an attachment for a Test Case.
817876
818877
testcaseid - Test Case INTERNAL ID
878+
version - Test Case version number
819879
820880
mandatory non api args: attachmentfile
821881
- python file descriptor pointing to the file

src/testlink/version.py

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

20-
VERSION = '0.8.0'
21-
TL_RELEASE = '1.9.17'
20+
VERSION = '0.8.1-dev119'
21+
TL_RELEASE = 'DEV 1.9.20 (github 6a4984164)'

test/utest-offline/test_apiClients_whatArgs.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,14 @@ def test_whatArgs_unknownMethods(api_client):
9696
('getAllExecutionsResults',['<testplanid>,','testcaseid=<testcaseid>',
9797
'testcaseexternalid=<testcaseexternalid>',
9898
'platformid=<platformid>', 'buildid=<buildid>',
99-
'options=<options>'])
99+
'options=<options>']),
100+
('getTestCaseAttachments',['version=<version>',
101+
'testcaseexternalid=<testcaseexternalid>']),
102+
('uploadTestCaseAttachment',['<testcaseid>,', '<version>,',
103+
'title=<title>', 'description=<description>',
104+
'filename=<filename>', 'filetype=<filetype>',
105+
'content=<content>']),
106+
100107
]
101108

102109
@pytest.mark.parametrize("apiCall, descriptions",
@@ -108,7 +115,8 @@ def test_whatArgs_apiCall_descriptions_equal_all(api_client, apiCall, descriptio
108115

109116
test_data_apiCall_descriptions_only_generic = [
110117
('createTestCase', ['<steps>,']),
111-
('createBuild',['buildnotes=<buildnotes>'])
118+
('createBuild',['buildnotes=<buildnotes>']),
119+
('getTestCaseAttachments',['testcaseid=<testcaseid>'])
112120
]
113121
@pytest.mark.parametrize("apiCall, descriptions",
114122
test_data_apiCall_descriptions_only_generic)
@@ -119,7 +127,8 @@ def test_whatArgs_apiCall_descriptions_only_generic(api_generic_client, apiCall,
119127

120128
test_data_apiCall_descriptions_only_general = [
121129
('createTestCase', ['steps=<steps>']),
122-
('createBuild',['<buildnotes>,'])
130+
('createBuild',['<buildnotes>,']),
131+
('getTestCaseAttachments',['<testcaseid>,'])
123132
]
124133
@pytest.mark.parametrize("apiCall, descriptions",
125134
test_data_apiCall_descriptions_only_general)

test/utest-online/test_apiCall_equalPositionalArgs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ def test_uploadTestSuiteAttachment_unknownID(api_client, attachmentFile):
245245

246246
def test_uploadTestCaseAttachment_unknownID(api_client, attachmentFile):
247247
with pytest.raises(TLResponseError, match='5000.*testcaseid'):
248-
api_client.uploadTestCaseAttachment(attachmentFile, 40000712,
248+
api_client.uploadTestCaseAttachment(attachmentFile, 40000712, 1,
249249
title='title 40000713', description='descr. 40000714')
250250

251251
def test_uploadAttachment_unknownID(api_client, attachmentFile):

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# TESTLINK_API_PYTHON_DEVKEY and TESTLINK_API_PYTHON_SERVER_URL
55
# with your server settings
66
[tox]
7-
envlist = py27,py36
7+
envlist = py27,py36,py37
88
[testenv]
99
deps=pytest
1010
setenv=

0 commit comments

Comments
 (0)