diff --git a/src/mega/mega.py b/src/mega/mega.py index 37ba3dd..f509f59 100644 --- a/src/mega/mega.py +++ b/src/mega/mega.py @@ -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( diff --git a/src/tests/test_crypto.py b/src/tests/test_crypto.py new file mode 100644 index 0000000..9b8cc77 --- /dev/null +++ b/src/tests/test_crypto.py @@ -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 diff --git a/src/tests/tests.py b/src/tests/test_mega.py similarity index 100% rename from src/tests/tests.py rename to src/tests/test_mega.py diff --git a/tox.ini b/tox.ini index fd4b4c3..52c8da7 100644 --- a/tox.ini +++ b/tox.ini @@ -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