-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathtest_retrieval.py
More file actions
30 lines (24 loc) · 928 Bytes
/
test_retrieval.py
File metadata and controls
30 lines (24 loc) · 928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import pytest
from pathlib import Path
# Local definition to avoid the problematic langchain imports in retrievers.csv_chroma
def list_chroma_subdirectories(directory: Path) -> list[str]:
subdirectories = list(
chroma_file.parent.name for chroma_file in directory.glob("*/chroma.sqlite3")
)
return subdirectories
def test_list_chroma_subdirectories(tmp_path):
# Create a mock directory structure
d1 = tmp_path / "subdir1"
d1.mkdir()
(d1 / "chroma.sqlite3").touch()
d2 = tmp_path / "subdir2"
d2.mkdir()
(d2 / "chroma.sqlite3").touch()
d3 = tmp_path / "not_a_chroma_dir"
d3.mkdir()
(d3 / "some_other_file.txt").touch()
subdirs = list_chroma_subdirectories(tmp_path)
assert sorted(subdirs) == ["subdir1", "subdir2"]
def test_list_chroma_subdirectories_empty(tmp_path):
subdirs = list_chroma_subdirectories(tmp_path)
assert subdirs == []