def test_fetch_file_local_dir_specified(OSF_project, os_path_exists,
os_makedirs):
# check that `osf fetch` opens the right files with the right name
# and mode when specifying a local filename
args = MockArgs(project='1234', remote='osfstorage/a/a/a',
local='subdir/foobar.txt')
mock_open_func = mock_open()
with patch('osfclient.cli.open', mock_open_func):
fetch(args)
OSF_project.assert_called_once_with('1234')
# check that the project and the files have been accessed
store = OSF_project.return_value.storages[0]
assert store._name_mock.return_value == 'osfstorage'
assert (mock.call('subdir/foobar.txt', 'wb') in
mock_open_func.mock_calls)
assert mock.call('subdir', exist_ok=True) in os_makedirs.mock_calls
评论列表
文章目录