def test_copy_empty_dir(self): _dir = HDFS(os.path.join("/tmp", str(uuid.uuid4()))) dst = HDFS("/tmp/dst_" + str(uuid.uuid4())) try: _dir.create(directory=True) self.assertTrue(_dir.exists(), "directory not found") self.assertFalse(dst.exists(), "dst directory is already exists") _dir.copy(dst) self.assertTrue(dst.exists(), "directory was not copied") finally: _dir.delete(True) dst.delete(True) self.assertFalse(_dir.exists(), "File was not deleted") self.assertFalse(dst.exists(), "File was not deleted")
def test_copy_file(self): _file = HDFS(os.path.join("/tmp", str(uuid.uuid4()))) dst = HDFS(os.path.join("/tmp", str(uuid.uuid4()))) try: _file.create_file() self.assertTrue(_file.exists(), "original file not found") self.assertFalse(dst.exists(), "destination file already exists") _file.create() _file.copy(dst) self.assertTrue(dst.exists(), "file was not copied") self.assertTrue(_file.exists(), "original file should not be deleted") finally: _file.delete() dst.delete() self.assertFalse(_file.exists(), "File was not deleted") self.assertFalse(dst.exists(), "destination file was not deleted")