def test__uploadExternallyStoringProjects_external_user( self, mock_upload_destination): # setup expected_storage_location_id = "1234567" expected_path = "~/fake/path/file.txt" expected_path_expanded = os.path.expanduser(expected_path) expected_file_handle_id = "8786" mock_upload_destination.return_value = { 'storageLocationId': expected_storage_location_id, 'concreteType': concrete_types.EXTERNAL_S3_UPLOAD_DESTINATION } test_file = File(expected_path, parent="syn12345") # method under test with patch.object(synapseclient.upload_functions, "multipart_upload", return_value=expected_file_handle_id) as mocked_multipart_upload, \ patch.object(syn.cache, "add") as mocked_cache_add,\ patch.object(syn, "_getFileHandle") as mocked_getFileHandle: upload_functions.upload_file_handle(syn, test_file['parentId'], test_file['path']) mock_upload_destination.assert_called_once_with( test_file['parentId']) mocked_multipart_upload.assert_called_once_with( syn, expected_path_expanded, contentType=None, storageLocationId=expected_storage_location_id) mocked_cache_add.assert_called_once_with(expected_file_handle_id, expected_path_expanded) mocked_getFileHandle.assert_called_once_with( expected_file_handle_id)
def test__uploadExternallyStoringProjects_external_user(self, mock_upload_destination): # setup expected_storage_location_id = "1234567" expected_path = "~/fake/path/file.txt" expected_path_expanded = os.path.expanduser(expected_path) expected_file_handle_id = "8786" mock_upload_destination.return_value = {'storageLocationId': expected_storage_location_id, 'concreteType': concrete_types.EXTERNAL_S3_UPLOAD_DESTINATION} test_file = File(expected_path, parent="syn12345") # method under test with patch.object(synapseclient.upload_functions, "multipart_upload", return_value=expected_file_handle_id) as mocked_multipart_upload, \ patch.object(syn.cache, "add") as mocked_cache_add,\ patch.object(syn, "_getFileHandle") as mocked_getFileHandle: upload_functions.upload_file_handle(syn, test_file['parentId'], test_file['path']) mock_upload_destination.assert_called_once_with(test_file['parentId']) mocked_multipart_upload.assert_called_once_with(syn, expected_path_expanded, contentType=None, storageLocationId=expected_storage_location_id) mocked_cache_add.assert_called_once_with(expected_file_handle_id, expected_path_expanded) mocked_getFileHandle.assert_called_once_with(expected_file_handle_id)