Skip to content

Commit 20fe8b3

Browse files
committed
tests: update for 0.9.1
1 parent 24d8510 commit 20fe8b3

File tree

2 files changed

+3
-63
lines changed

2 files changed

+3
-63
lines changed

tests/test_download.py

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -70,51 +70,3 @@ async def test_download_range(self):
7070
assert int(downloaded_file.content_length) == len(downloaded_file.content)
7171

7272
await client.close()
73-
74-
@pytest.mark.asyncio
75-
@pytest.mark.order(2)
76-
async def test_download_params(self):
77-
client = Client(os.environ['KEY_ID'], os.environ['KEY'], log_level=logging.DEBUG)
78-
file = ValueStorage.test_upload_file
79-
assert isinstance(file, File)
80-
81-
content_disposition = f'attachment; filename="filename.jpg"'
82-
content_language = 'de-DE'
83-
expires = 'Wed, 21 Oct 2015 07:28:00 GMT'
84-
# TODO: this is a valid value for cache-control, but DownloadedFile tries to parse it as a timestamp
85-
# cache_control = 'max-age=604800, must-revalidate'
86-
content_encoding = 'compress'
87-
content_type = 'text/html;charset=utf-8'
88-
89-
downloaded_file = await client.download_file_by_name(
90-
file_name=file.name,
91-
bucket_name=os.environ['BUCKET_NAME'],
92-
content_disposition=content_disposition,
93-
content_language=content_language,
94-
expires=expires,
95-
# cache_control=cache_control,
96-
content_encoding=content_encoding,
97-
content_type=content_type
98-
)
99-
100-
assert downloaded_file.name == file.name
101-
assert downloaded_file.id == file.id
102-
assert downloaded_file.content == path.read_bytes()
103-
assert downloaded_file.content_disposition == content_disposition
104-
assert downloaded_file.content_language == content_language
105-
# TODO: cache-control header is not exposed by DownloadedFile, and the logic that sets expires needs some
106-
# attention
107-
# assert downloaded_file.cache_control == cache_control
108-
# assert downloaded_file.expires == expires
109-
assert downloaded_file.content_encoding == content_encoding
110-
assert downloaded_file.content_type == content_type
111-
112-
# Download (by id)
113-
114-
downloaded_file = await client.download_file_by_id(file_id=file.id)
115-
116-
assert downloaded_file.name == file.name
117-
assert downloaded_file.id == file.id
118-
assert downloaded_file.content == path.read_bytes()
119-
120-
await client.close()

tests/test_large_upload.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,8 @@ async def test_large_upload(self):
1919

2020
file_name = str(uuid.uuid4())
2121
comments = {'foo': 'bar', 'spam': 'eggs'}
22-
large_file = await client.upload_large_file(bucket_id, file_name, comments=comments)
23-
24-
size = 0
25-
with open(path, 'rb') as file:
26-
while True:
27-
# ideally we'd use the recommended_part_size, but
28-
# our test payload isn't above 100mb (typical
29-
# recommended part size).
30-
data = file.read(large_file.absolute_minimum_part_size)
31-
if len(data) == 0:
32-
break
33-
await large_file.upload_part(content_bytes=data)
34-
size += len(data)
35-
22+
large_file = await client.start_large_file_upload(bucket_id, file_name, comments=comments)
23+
await large_file.chunk_file(path, chunk_size=10_000_000)
3624
file = await large_file.finish()
3725

3826
# uploading one part isn't a proper test, so we'll ensure
@@ -41,7 +29,7 @@ async def test_large_upload(self):
4129

4230
assert file.name == file_name
4331
assert file.bucket_id == bucket_id
44-
assert file.content_length == size
32+
assert file.content_length == path.stat().st_size
4533

4634
ValueStorage.test_large_upload_file = file
4735

0 commit comments

Comments
 (0)