33TestLinkAPI - v0.20
44Created on 5 nov. 2011
55@author: Olivier Renault ([email protected] ) 6-
6+ @author: kereval.com
77Initialy based on the James Stock testlink-api-python-client R7.
8-
8+
9+ Updated by Kereval to support testCase Reporting and File attachment to test execution
910
1011"""
1112import xmlrpclib
@@ -329,6 +330,16 @@ def createTestCase(self, *args):
329330 return ret
330331
331332 def reportTCResult (self , testcaseid , testplanid , buildid , status , notes ):
333+ """
334+ Report execution result
335+ testcaseid: internal testlink id of the test case
336+ testplanid: testplan associated with the test case
337+ buildid: build version of the test case
338+ status: test verdict ('p': pass,'f': fail,'b': blocked)
339+
340+ Return : [{'status': True, 'operation': 'reportTCResult', 'message': 'Success!', 'overwrite': False, 'id': '37'}]
341+ id correspond to the executionID needed to attach files to a test execution
342+ """
332343 argsAPI = {'devKey' : self .devKey ,
333344 'testcaseid' : testcaseid ,
334345 'testplanid' : testplanid ,
@@ -337,6 +348,28 @@ def reportTCResult(self, testcaseid, testplanid, buildid, status, notes ):
337348 'notes' : notes
338349 }
339350 return self .server .tl .reportTCResult (argsAPI )
351+
352+ def uploadExecutionAttachment (self ,attachmentfile ,executionid ,title ,description ):
353+ """
354+ Attach a file to a test execution
355+ attachmentfile: python file descriptor pointing to the file
356+ name : name of the file
357+ title : title of the attachment
358+ description : description of the attachment
359+ content type : mimetype of the file
360+ """
361+ import mimetypes
362+ import base64
363+ import os .path
364+ argsAPI = {'devKey' : self .devKey ,
365+ 'executionid' :executionid ,
366+ 'title' :title ,
367+ 'filename' :os .path .basename (attachmentfile .name ),
368+ 'description' :description ,
369+ 'filetype' :mimetypes .guess_type (attachmentfile .name )[0 ],
370+ 'content' :base64 .encodestring (attachmentfile .read ())
371+ }
372+ return self .server .tl .uploadExecutionAttachment (argsAPI )
340373
341374 #
342375 # ADDITIONNAL FUNCTIONS
0 commit comments