Skip to content

Commit fda002c

Browse files
committed
Refactor Windows path compatibility to maintain Unix-only behavior
1 parent fc0bee9 commit fda002c

File tree

1 file changed

+27
-34
lines changed

1 file changed

+27
-34
lines changed

tests/test_query_ingestion.py

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -97,66 +97,59 @@ def test_include_nonexistent_extension(temp_directory: Path, sample_query: dict[
9797

9898
# single folder patterns
9999
def test_include_src_star_pattern(temp_directory: Path, sample_query: dict[str, Any]) -> None:
100-
100+
"""
101+
Test that when using 'src/*' as include pattern, files under the src directory
102+
are included.
103+
Note: Windows is not supported - test converts Windows paths to Unix-style for validation.
104+
"""
101105
sample_query["local_path"] = temp_directory
102-
sample_query["include_patterns"] = ["src/*"] # Without leading slash
106+
sample_query["include_patterns"] = ["src/*"]
103107

104108
result = _scan_directory(temp_directory, query=sample_query)
105109
assert result is not None, "Result should not be None"
106110

107111
files = _extract_files_content(query=sample_query, node=result, max_file_size=1_000_000)
108-
assert len(files) == 4, "Should find all files under src directory"
109-
110-
# Normalize paths to use platform-specific separator
111-
file_paths = {str(Path(f["path"])) for f in files} # Using set and Path for normalization
112-
expected_paths = {
113-
str(Path("src/subfile1.txt")),
114-
str(Path("src/subfile2.py")),
115-
str(Path("src/subdir/file_subdir.txt")),
116-
str(Path("src/subdir/file_subdir.py")),
117-
}
112+
# Convert Windows paths to Unix-style for test validation
113+
file_paths = {f["path"].replace("\\", "/") for f in files}
114+
expected_paths = {"src/subfile1.txt", "src/subfile2.py", "src/subdir/file_subdir.txt", "src/subdir/file_subdir.py"}
118115
assert file_paths == expected_paths, "Missing or unexpected files in result"
119116

120117

121118
def test_include_src_recursive(temp_directory: Path, sample_query: dict[str, Any]) -> None:
122-
119+
"""
120+
Test that when using 'src/**' as include pattern, all files under src
121+
directory are included recursively.
122+
Note: Windows is not supported - test converts Windows paths to Unix-style for validation.
123+
"""
123124
sample_query["local_path"] = temp_directory
124-
sample_query["include_patterns"] = ["src/**"] # Use ** for recursive matching
125+
sample_query["include_patterns"] = ["src/**"]
125126

126127
result = _scan_directory(temp_directory, query=sample_query)
127128
assert result is not None, "Result should not be None"
128129

129130
files = _extract_files_content(query=sample_query, node=result, max_file_size=1_000_000)
130-
assert len(files) == 4, "Should find all files under src/"
131-
132-
file_paths = {str(Path(f["path"])) for f in files}
133-
expected_paths = {
134-
str(Path("src/subfile1.txt")),
135-
str(Path("src/subfile2.py")),
136-
str(Path("src/subdir/file_subdir.txt")),
137-
str(Path("src/subdir/file_subdir.py")),
138-
}
131+
# Convert Windows paths to Unix-style for test validation
132+
file_paths = {f["path"].replace("\\", "/") for f in files}
133+
expected_paths = {"src/subfile1.txt", "src/subfile2.py", "src/subdir/file_subdir.txt", "src/subdir/file_subdir.py"}
139134
assert file_paths == expected_paths, "Missing or unexpected files in result"
140135

141136

142137
def test_include_src_wildcard_prefix(temp_directory: Path, sample_query: dict[str, Any]) -> None:
143-
138+
"""
139+
Test that when using 'src*' as include pattern, it matches the src directory
140+
and any paths that start with 'src'.
141+
Note: Windows is not supported - test converts Windows paths to Unix-style for validation.
142+
"""
144143
sample_query["local_path"] = temp_directory
145-
sample_query["include_patterns"] = ["src*"] # Without leading slash
144+
sample_query["include_patterns"] = ["src*"]
146145

147146
result = _scan_directory(temp_directory, query=sample_query)
148147
assert result is not None, "Result should not be None"
149148

150149
files = _extract_files_content(query=sample_query, node=result, max_file_size=1_000_000)
151-
assert len(files) == 4, "Should find all files under paths starting with src"
152-
153-
file_paths = {str(Path(f["path"])) for f in files}
154-
expected_paths = {
155-
str(Path("src/subfile1.txt")),
156-
str(Path("src/subfile2.py")),
157-
str(Path("src/subdir/file_subdir.txt")),
158-
str(Path("src/subdir/file_subdir.py")),
159-
}
150+
# Convert Windows paths to Unix-style for test validation
151+
file_paths = {f["path"].replace("\\", "/") for f in files}
152+
expected_paths = {"src/subfile1.txt", "src/subfile2.py", "src/subdir/file_subdir.txt", "src/subdir/file_subdir.py"}
160153
assert file_paths == expected_paths, "Missing or unexpected files in result"
161154

162155

0 commit comments

Comments
 (0)