mirror of
https://github.com/microsoft/graphrag.git
synced 2025-08-18 13:42:02 +00:00

* Add stricter filtering and tests for cli data directory discovery * Semver * Ignore ruff on error type * Format * Fix for windows paths * Fix for windows paths * Uncomment blob tests * Sort by timestamp name instead of modified date * Format * Add additional folder name test
33 lines
1007 B
Python
33 lines
1007 B
Python
# Copyright (c) 2024 Microsoft Corporation.
|
|
# Licensed under the MIT License
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from graphrag.query.cli import _infer_data_dir
|
|
|
|
|
|
def test_infer_data_dir():
|
|
root = "./tests/unit/query/data/defaults"
|
|
result = Path(_infer_data_dir(root))
|
|
assert result.parts[-2] == "20240812-121000"
|
|
|
|
|
|
def test_infer_data_dir_ignores_hidden_files():
|
|
"""A hidden file, starting with '.', will naturally be selected as latest data directory."""
|
|
root = "./tests/unit/query/data/hidden"
|
|
result = Path(_infer_data_dir(root))
|
|
assert result.parts[-2] == "20240812-121000"
|
|
|
|
|
|
def test_infer_data_dir_ignores_non_numeric():
|
|
root = "./tests/unit/query/data/non-numeric"
|
|
result = Path(_infer_data_dir(root))
|
|
assert result.parts[-2] == "20240812-121000"
|
|
|
|
|
|
def test_infer_data_dir_throws_on_no_match():
|
|
root = "./tests/unit/query/data/empty"
|
|
with pytest.raises(ValueError): # noqa PT011 (this is what is actually thrown...)
|
|
_infer_data_dir(root)
|