Skip to content

Commit 5965f52

Browse files
authored
Merge pull request #25 from cloudblue/LITE-27338-fix-report-filename
LITE-27338 fix report filename
2 parents df91cfb + 0b9595b commit 5965f52

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

executor/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,13 @@ def get_user_agent():
108108

109109
def upload_file(client, report_name, report_id, owner_id):
110110
report_filename = os.path.basename(report_name)
111+
_, report_extension = report_filename.rsplit('.', 1)
111112
reports_media_api = client.ns('media').ns('folders').collection('reports_report_file')
112113
media_file = reports_media_api[owner_id].action('files').post(
113114
data=open(report_name, 'rb'),
114115
headers={
115116
'Content-Type': 'application/octet-stream',
116-
'Content-Disposition': f'attachment; filename="{report_filename}"',
117+
'Content-Disposition': f'attachment; filename="{report_id}.{report_extension}"',
117118
},
118119
)
119120

tests/test_utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pytest
66
from connect.client import ConnectClient
77
from pkg_resources import DistributionNotFound
8+
from responses import matchers
89

910
from executor.exceptions import RunnerException
1011
from executor.utils import (
@@ -102,6 +103,10 @@ def test_upload_file(mocked_responses, fs):
102103
url='https://localhost/public/v1/media/folders/reports_report_file/VA-001/files',
103104
status=201,
104105
body=b'{"id": "MFL-001"}',
106+
match=[matchers.header_matcher({
107+
'Content-Type': 'application/octet-stream',
108+
'Content-Disposition': 'attachment; filename="REC-000-000-0000-000000.zip"',
109+
})],
105110
)
106111

107112
mocked_responses.add(

0 commit comments

Comments
 (0)