Skip to content

Commit 5321168

Browse files
committed
reworked attach method semantic
1 parent f21f7e6 commit 5321168

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

reportportal_client/service.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,25 +74,24 @@ def log(self, save_log_rq):
7474
r = self.session.post(url=url, json=save_log_rq.as_dict())
7575
return EntryCreatedRS(raw=r.text)
7676

77-
def attach(self, save_log_rq, data):
77+
def attach(self, save_log_rq, name, data, mime="application/octet-stream"):
7878
"""Logs message with attachment.
7979
8080
Args:
8181
save_log_rq: SaveLogRQ instance
82-
data: 2-tuple ("filename", fileobj or content) in this case
83-
"application/octet-stream" will be used by default, or
84-
3-tuple ("filename", fileobj or content, "content_type")
82+
name: name of attachment
83+
data: fileobj or content
84+
mime: content type for attachment
8585
8686
Returns:
8787
An instance of EntryCreatedRS.
8888
"""
8989
url = self.uri_join(self.base_url, "log")
9090
dct = save_log_rq.as_dict()
91-
dct["file"] = {"name": data[0]}
91+
dct["file"] = {"name": name}
9292
files = {
9393
"json_request_part": (None, json.dumps([dct]), "application/json"),
94-
"file": (data[0], data[1],
95-
data[2] if len(data) > 2 else "application/octet-stream")
94+
"file": (name, data, mime)
9695
}
9796
r = self.session.post(url=url, files=files)
9897
return EntryCreatedRS(raw=r.text)

0 commit comments

Comments
 (0)