Skip to content

Commit

Permalink
Unit test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanFauble committed Oct 30, 2023
1 parent 69e6600 commit 5ac2fab
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions tests/unit/synapseclient/core/unit_test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def mock_generate_headers(self, headers=None):
return {}


def test_mock_download(syn):
def test_mock_download(syn: Synapse):
temp_dir = tempfile.gettempdir()

fileHandleId = "42"
Expand Down Expand Up @@ -388,7 +388,7 @@ def test_mock_download(syn):

class Test__downloadFileHandle(unittest.TestCase):
@pytest.fixture(autouse=True, scope="function")
def init_syn(self, syn):
def init_syn(self, syn: Synapse):
self.syn = syn

def tearDown(self) -> None:
Expand Down Expand Up @@ -506,7 +506,7 @@ def test_multithread_false__S3_fileHandle(self):

class Test_download_from_url_multi_threaded:
@pytest.fixture(autouse=True, scope="function")
def init_syn(self, syn):
def init_syn(self, syn: Synapse):
self.syn = syn

def test_md5_mismatch(self):
Expand Down Expand Up @@ -564,7 +564,7 @@ def test_md5_match(self):
)


def test_download_end_early_retry(syn):
def test_download_end_early_retry(syn: Synapse):
"""
-------Test to ensure download retry even if connection ends early--------
"""
Expand Down Expand Up @@ -645,7 +645,7 @@ def test_download_end_early_retry(syn):
mocked_move.assert_called_once_with(temp_destination, destination)


def test_download_md5_mismatch__not_local_file(syn):
def test_download_md5_mismatch__not_local_file(syn: Synapse):
"""
--------Test to ensure file gets removed on md5 mismatch--------
"""
Expand Down Expand Up @@ -712,7 +712,7 @@ def test_download_md5_mismatch__not_local_file(syn):
mocked_remove.assert_called_once_with(destination)


def test_download_md5_mismatch_local_file(syn):
def test_download_md5_mismatch_local_file(syn: Synapse):
"""
--------Test to ensure file gets removed on md5 mismatch--------
"""
Expand Down Expand Up @@ -743,7 +743,7 @@ def test_download_md5_mismatch_local_file(syn):
assert not mocked_remove.called


def test_download_file_entity__correct_local_state(syn):
def test_download_file_entity__correct_local_state(syn: Synapse):
mock_cache_path = utils.normalize_path("/i/will/show/you/the/path/yi.txt")
file_entity = File(parentId="syn123")
file_entity.dataFileHandleId = 123
Expand All @@ -753,14 +753,15 @@ def test_download_file_entity__correct_local_state(syn):
entity=file_entity,
ifcollision="overwrite.local",
submission=None,
expected_md5=None,
)
assert mock_cache_path == utils.normalize_path(file_entity.path)
assert os.path.dirname(mock_cache_path) == file_entity.cacheDir
assert 1 == len(file_entity.files)
assert os.path.basename(mock_cache_path) == file_entity.files[0]


def test_getFileHandleDownload__error_UNAUTHORIZED(syn):
def test_getFileHandleDownload__error_UNAUTHORIZED(syn: Synapse):
ret_val = {
"requestedFiles": [
{
Expand All @@ -772,7 +773,7 @@ def test_getFileHandleDownload__error_UNAUTHORIZED(syn):
pytest.raises(SynapseError, syn._getFileHandleDownload, "123", "syn456")


def test_getFileHandleDownload__error_NOT_FOUND(syn):
def test_getFileHandleDownload__error_NOT_FOUND(syn: Synapse):
ret_val = {
"requestedFiles": [
{
Expand Down

0 comments on commit 5ac2fab

Please sign in to comment.