from pathlib import Path # Generated by CodiumAI import unittest from utils.file_utils import ensure_directory_exists class TestEnsureDirectoryExists(unittest.TestCase): # creates directory if it does not exist def test_creates_directory_if_not_exists(self): path = Path('/tmp/testdir') if path.exists(): path.rmdir() ensure_directory_exists(path) self.assertTrue(path.exists()) path.rmdir() # does not create directory if it already exists def test_does_not_create_directory_if_exists(self): path = Path('/tmp/testdir') path.mkdir(exist_ok=True) ensure_directory_exists(path) self.assertTrue(path.exists()) path.rmdir() # path is a symbolic link def test_path_is_a_symbolic_link(self): target_dir = Path('/tmp/targetdir') symlink_path = Path('/tmp/symlinkdir') target_dir.mkdir(exist_ok=True) symlink_path.symlink_to(target_dir) ensure_directory_exists(symlink_path) self.assertTrue(symlink_path.exists()) self.assertTrue(symlink_path.is_symlink()) symlink_path.unlink() target_dir.rmdir()