lczub / TestLink-API-Python-client

A Python client to use the TestLink API
105 stars 63 forks source link

uploadAttachment() should handle file path #40

Closed lczub closed 9 years ago

lczub commented 9 years ago

Issues #34 and #39 shows, that the current workflow for uploading attachments is not user friendly and prone to errors.

#0.5.2 behaviour
a_file_obj=open(A_VALID_FILE_PATH)
newAttachment = myTestLink.uploadExecutionAttachment(a_file_obj, A_Result_ID, 
            'Attachment Title', 'Attachment Description')

Better solution would be, if instead of a file object the file path could be assigned and the api itselfs creates the required file object (and could decide, if it needs a 'r' or 'rb' mode , what differs between py2 and py3)

# future enhanced behaviour 
newAttachment = myTestLink.uploadExecutionAttachment(A_VALID_FILE_PATH, A_Result_ID, 
            'Attachment Title', 'Attachment Description')

Cause of backward compatibility, the file object must still be supported as argument, too. As error handling for #34 and #39, it should be tried to close the file object and reopen it again with a different read mode.

lczub commented 9 years ago

fixed with release v0.6.0