Skip to content

uploadAttachment() should handle file path #40

Closed
@lczub

Description

@lczub

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.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions