def test_decompress2(file_tree2, tmp_path, local, remote, name, arch, skip, content): ft = loader.FileTransfer(name, tmp_path / local, remote, arch) ft.decompress(skip) filename = ft._name with open(tmp_path / local / filename) as f: data = f.read() assert data == content
def test_compress2(file_tree3, tmp_path, local, remote, name, arch, skip, content): ft = loader.FileTransfer(name, tmp_path / local, remote, arch) ft.compress(skip) filename = ft._arch_name with open(tmp_path / local / filename, 'rb') as f: data = f.read() archivator = loader.get_archivator(arch) assert archivator.decompress(data).decode() == content
def test_upload_raise(ftp_server3, file_tree2, tmp_path, local, remote, name, arch, skip): host = '127.0.0.1' port = ftp_server3.port cnopts = CnOpts() cnopts.hostkeys = None ft = loader.FileTransfer(name, tmp_path / local, remote, arch) with Connection(host, port=port, username='******', password='******', cnopts=cnopts) as conn: with pytest.raises(loader.LoaderException): ft.upload(conn, skip_existing=skip)
def test_download(ftp_server1, file_tree1, tmp_path, local, remote, name, arch, skip): host = '127.0.0.1' port = ftp_server1.port cnopts = CnOpts() cnopts.hostkeys = None ft = loader.FileTransfer(name, tmp_path / local, remote, arch) with Connection(host, port=port, username='******', password='******', cnopts=cnopts) as conn: ft.download(conn, skip_existing=skip) filename = ft._arch_name mode = 'rb' if arch else 'r' with open(tmp_path / local / filename, mode) as f: data = f.read() assert data == ftp_server1.content_provider.get(remote + '/' + filename)
def test_upload2(ftp_server3, file_tree2, tmp_path, local, remote, name, arch, skip, content): host = '127.0.0.1' port = ftp_server3.port cnopts = CnOpts() cnopts.hostkeys = None ft = loader.FileTransfer(name, tmp_path / local, remote, arch) with Connection(host, port=port, username='******', password='******', cnopts=cnopts) as conn: ft.upload(conn, skip_existing=skip) filename = ft._arch_name data = ftp_server3.content_provider.get(remote + '/' + filename) if arch: data = loader.get_archivator(arch).decompress(data) assert data.decode() == content
def test_compress_raises(file_tree3, tmp_path, local, remote, name, arch, skip): ft = loader.FileTransfer(name, tmp_path / local, remote, arch) with pytest.raises(loader.LoaderException): ft.compress(skip)
def test_clear(file_tree2, tmp_path, local, remote, name, arch): ft = loader.FileTransfer(name, tmp_path / local, remote, arch) ft.clear() if arch: assert False == (tmp_path / local / ft._arch_name).exists() assert False == (tmp_path / local / ft._name).exists()