def test_fs_volume_copy_all(basedir, emptydir, filenames_all, data_a): """Test copying the full directory of a storage volume.""" source = FileSystemStorage(basedir=basedir) target = FileSystemStorage(basedir=emptydir) source.copy(src=None, dst=None, store=target) files = {key: file for key, file in target.walk(src='')} assert set(files.keys()) == filenames_all with files['A.json'].open() as f: assert json.load(f) == data_a
def test_remote_volume_copy_all(mock_ssh, basedir, emptydir, filenames_all, data_a): """Test copying the full directory of a storage volume.""" source = FileSystemStorage(basedir=basedir) with ssh.ssh_client('test', sep=os.sep) as client: target = RemoteStorage(remotedir=emptydir, client=client) source.copy(src=None, dst=None, store=target) files = {key: file for key, file in target.walk(src='')} assert set(files.keys()) == filenames_all with files['A.json'].open() as f: assert json.load(f) == data_a
def test_remote_volume_copy_file(mock_ssh, basedir, emptydir, data_e): """Test copying a file from a storage volume.""" source = FileSystemStorage(basedir=basedir) with ssh.ssh_client('test', sep=os.sep) as client: target = RemoteStorage(remotedir=emptydir, client=client) source.copy(src='examples/data/data.json', dst='static/examples/data/data.json', store=target) files = {key: file for key, file in target.walk(src='static')} assert set(files.keys()) == {'static/examples/data/data.json'} with files['static/examples/data/data.json'].open() as f: assert json.load(f) == data_e
def test_fs_volume_upload_file(basedir, emptydir, data_e): """Test uploading a file to a storage volume.""" source = FileSystemStorage(basedir=basedir) target = FileSystemStorage(basedir=emptydir) source.copy( src='examples/data/data.json', dst='static/examples/data/data.json', store=target, verbose=True ) files = {key: file for key, file in target.walk(src='static')} assert set(files.keys()) == {'static/examples/data/data.json'} with files['static/examples/data/data.json'].open() as f: assert json.load(f) == data_e
def test_fs_volume_copy_files(basedir, emptydir, data_a, data_e): """Test copying separate files from a storage volume.""" source = FileSystemStorage(basedir=basedir) target = FileSystemStorage(basedir=emptydir) source.copy(src='A.json', dst='static/A.json', store=target) source.copy(src='examples/data', dst='static/examples/data', store=target) files = {key: file for key, file in target.walk(src='static')} assert set(files.keys()) == {'static/A.json', 'static/examples/data/data.json'} with files['static/examples/data/data.json'].open() as f: assert json.load(f) == data_e source.copy(src=['examples'], dst='static2', store=target, verbose=True) files = {key: file for key, file in target.walk(src='static2')} assert set(files.keys()) == {'static2/B.json', 'static2/C.json', 'static2/data/data.json'} source.copy(src=['examples/'], dst='static3', store=target, verbose=True) files = {key: file for key, file in target.walk(src='static3')} assert set(files.keys()) == {'static3/B.json', 'static3/C.json', 'static3/data/data.json'}