This commit is contained in:
Richard O'Dwyer 2019-11-06 20:00:09 +00:00
parent b87694e72d
commit 13cb3b565e
4 changed files with 50 additions and 4 deletions

View file

@ -569,8 +569,8 @@ class Mega:
Download a file by it's file object
"""
self._download_file(
None,
None,
file_handle=None,
file_key=None,
file=file[1],
dest_path=dest_path,
dest_filename=dest_filename,
@ -647,7 +647,11 @@ class Mega:
file_id = path[0]
file_key = path[1]
self._download_file(
file_id, file_key, dest_path, dest_filename, is_public=True
file_handle=file_id,
file_key=file_key,
dest_path=dest_path,
dest_filename=dest_filename,
is_public=True,
)
def _download_file(

42
src/tests/test_crypto.py Normal file
View file

@ -0,0 +1,42 @@
import pytest
from mega.crypto import get_chunks
@pytest.mark.parametrize(
'file_size, exp_result', [
(
10,
(
(0, 10),
)
),
(
1000,
(
(0, 1000),
)
),
(
1000000,
(
(0, 131072), (131072, 262144), (393216, 393216),
(786432, 213568)
)
),
(
10000000,
(
(0, 131072), (131072, 262144), (393216, 393216),
(786432, 524288), (1310720, 655360), (1966080, 786432),
(2752512, 917504), (3670016, 1048576), (4718592, 1048576),
(5767168, 1048576), (6815744, 1048576), (7864320, 1048576),
(8912896, 1048576), (9961472, 38528)
)
),
]
)
def test_get_chunks(file_size, exp_result):
result = tuple(get_chunks(file_size))
assert result == exp_result

View file

@ -6,7 +6,7 @@ commands =
flake8 {toxinidir}/src/
coverage erase
python setup.py install
pytest {toxinidir}/src/tests/tests.py
pytest {toxinidir}/src/tests/
passenv =
EMAIL
PASS