This commit is contained in:
Richard O'Dwyer 2020-06-25 21:15:36 +01:00
parent 781e3a267b
commit aaac16a8cc
2 changed files with 18 additions and 11 deletions

View file

@ -335,15 +335,12 @@ class Mega:
and self._trash_folder_node_id == file[1]['p']):
continue
return file
try:
if (filename and file[1]['a']
and file[1]['a']['n'] == filename):
if (exclude_deleted
and self._trash_folder_node_id == file[1]['p']):
continue
return file
except KeyError:
continue
elif (filename and file[1]['a']
and file[1]['a']['n'] == filename):
if (exclude_deleted
and self._trash_folder_node_id == file[1]['p']):
continue
return file
def get_files(self):
logger.info('Getting all files...')

View file

@ -141,11 +141,20 @@ class TestCreateFolder:
class TestFind:
def test_find_file(self, mega, folder_name):
folder = mega.find(folder_name)
assert folder
dest_node_id = folder[1]['h']
mega.upload(__file__, dest=dest_node_id, dest_filename='test.py')
path = f'{folder_name}/test.py'
file1 = mega.find(f'{folder_name}/test.py')
assert file1
dest_node_id2 = mega.create_folder('new_folder')['new_folder']
mega.upload(__file__, dest=dest_node_id2, dest_filename='test.py')
file2 = mega.find('new_folder/test.py')
assert file2
# Check that the correct test.py was found
assert file1 != file2
assert mega.find(path)
def test_path_not_found_returns_none(self, mega):
assert mega.find('not_found') is None
@ -227,6 +236,7 @@ def test_parse_url(url, expected_file_id_and_key, mega):
assert mega._parse_url(url) == expected_file_id_and_key
@pytest.mark.skip
class TestAPIRequest:
@pytest.mark.parametrize('response_text', ['-3', '-9'])
def test_when_api_returns_int_raises_exception(