refactor: move config path test to unit tests
This commit is contained in:
parent
3069870a12
commit
405b7d80c6
2 changed files with 20 additions and 22 deletions
|
|
@ -1,21 +0,0 @@
|
|||
import os
|
||||
from pathlib import Path
|
||||
import pytest
|
||||
from cognee.root_dir import ensure_absolute_path
|
||||
|
||||
|
||||
def test_root_dir_absolute_paths():
|
||||
"""Test absolute path handling in root_dir.py"""
|
||||
# Test with absolute path
|
||||
abs_path = "C:/absolute/path" if os.name == "nt" else "/absolute/path"
|
||||
result = ensure_absolute_path(abs_path, allow_relative=False)
|
||||
assert result == str(Path(abs_path).resolve())
|
||||
|
||||
# Test with relative path (should fail)
|
||||
rel_path = "relative/path"
|
||||
with pytest.raises(ValueError, match="must be absolute"):
|
||||
ensure_absolute_path(rel_path, allow_relative=False)
|
||||
|
||||
# Test with None path
|
||||
with pytest.raises(ValueError, match="cannot be None"):
|
||||
ensure_absolute_path(None)
|
||||
|
|
@ -4,8 +4,9 @@ import pytest
|
|||
from unittest.mock import patch, mock_open
|
||||
from io import BytesIO
|
||||
from uuid import uuid4
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
from cognee.root_dir import ensure_absolute_path
|
||||
from cognee.infrastructure.files.utils.get_file_content_hash import get_file_content_hash
|
||||
from cognee.shared.utils import get_anonymous_id
|
||||
|
||||
|
|
@ -52,3 +53,21 @@ async def test_get_file_content_hash_stream():
|
|||
expected_hash = hashlib.md5(b"test_data").hexdigest()
|
||||
result = await get_file_content_hash(stream)
|
||||
assert result == expected_hash
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_root_dir_absolute_paths():
|
||||
"""Test absolute path handling in root_dir.py"""
|
||||
# Test with absolute path
|
||||
abs_path = "C:/absolute/path" if os.name == "nt" else "/absolute/path"
|
||||
result = ensure_absolute_path(abs_path)
|
||||
assert result == str(Path(abs_path).resolve())
|
||||
|
||||
# Test with relative path (should fail)
|
||||
rel_path = "relative/path"
|
||||
with pytest.raises(ValueError, match="must be absolute"):
|
||||
ensure_absolute_path(rel_path)
|
||||
|
||||
# Test with None path
|
||||
with pytest.raises(ValueError, match="cannot be None"):
|
||||
ensure_absolute_path(None)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue