Update cognee/tests/test_path_config.py
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
parent
d3dd87d90e
commit
c9e4e6e6f4
1 changed files with 5 additions and 20 deletions
|
|
@ -1,26 +1,11 @@
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
def ensure_absolute_path(path: str, base_path: str = None, allow_relative: bool = False) -> str:
|
from pathlib import Path
|
||||||
"""Ensures a path is absolute, optionally converting relative paths."""
|
import pytest
|
||||||
if path is None:
|
from cognee.root_dir import ensure_absolute_path
|
||||||
raise ValueError("Path cannot be None")
|
|
||||||
|
# …rest of your test cases using ensure_absolute_path…
|
||||||
path_obj = Path(path)
|
|
||||||
if path_obj.is_absolute():
|
|
||||||
return str(path_obj.resolve())
|
|
||||||
|
|
||||||
if not allow_relative:
|
|
||||||
raise ValueError(f"Path must be absolute. Got relative path: {path}")
|
|
||||||
|
|
||||||
if base_path is None:
|
|
||||||
raise ValueError("base_path must be provided when converting relative paths")
|
|
||||||
|
|
||||||
base = Path(base_path)
|
|
||||||
if not base.is_absolute():
|
|
||||||
raise ValueError("base_path must be absolute when converting relative paths")
|
|
||||||
|
|
||||||
return str((base / path).resolve())
|
|
||||||
|
|
||||||
def test_root_dir_absolute_paths():
|
def test_root_dir_absolute_paths():
|
||||||
"""Test absolute path handling in root_dir.py"""
|
"""Test absolute path handling in root_dir.py"""
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue