Refactoring: Remove names of methods moved to Project:

* search_files_for_pattern -> search_source_files_for_patterh
  * request_parsed_files -> gather_source_files
This commit is contained in:
Dominik Jain
2025-07-09 22:42:20 +02:00
committed by Dominik Jain
parent c4d89f21e7
commit 75436727d0
5 changed files with 17 additions and 15 deletions
+8 -6
View File
@@ -193,35 +193,37 @@ class TestProjectBasics:
"""Test search_files_for_pattern with various patterns and glob filters."""
# Test 1: Search for class definitions across all files
class_pattern = r"class\s+\w+\s*(?:\([^{]*\)|:)"
matches = project.search_files_for_pattern(class_pattern)
matches = project.search_source_files_for_pattern(class_pattern)
assert len(matches) > 0
# Should find multiple classes like User, Item, BaseModel, etc.
assert len(matches) >= 5
# Test 2: Search for specific class with include glob
user_class_pattern = r"class\s+User\s*(?:\([^{]*\)|:)"
matches = project.search_files_for_pattern(user_class_pattern, paths_include_glob="**/models.py")
matches = project.search_source_files_for_pattern(user_class_pattern, paths_include_glob="**/models.py")
assert len(matches) == 1 # Should only find User class in models.py
assert matches[0].source_file_path is not None
assert "models.py" in matches[0].source_file_path
# Test 3: Search for method definitions with exclude glob
method_pattern = r"def\s+\w+\s*\([^)]*\):"
matches = project.search_files_for_pattern(method_pattern, paths_exclude_glob="**/models.py")
matches = project.search_source_files_for_pattern(method_pattern, paths_exclude_glob="**/models.py")
assert len(matches) > 0
# Should find methods in services.py but not in models.py
assert all(match.source_file_path is not None and "models.py" not in match.source_file_path for match in matches)
# Test 4: Search for specific method with both include and exclude globs
create_user_pattern = r"def\s+create_user\s*\([^)]*\)(?:\s*->[^:]+)?:"
matches = project.search_files_for_pattern(create_user_pattern, paths_include_glob="**/*.py", paths_exclude_glob="**/models.py")
matches = project.search_source_files_for_pattern(
create_user_pattern, paths_include_glob="**/*.py", paths_exclude_glob="**/models.py"
)
assert len(matches) == 1 # Should only find create_user in services.py
assert matches[0].source_file_path is not None
assert "services.py" in matches[0].source_file_path
# Test 5: Search for a pattern that should appear in multiple files
init_pattern = r"def\s+__init__\s*\([^)]*\):"
matches = project.search_files_for_pattern(init_pattern)
matches = project.search_source_files_for_pattern(init_pattern)
assert len(matches) > 1 # Should find __init__ in multiple classes
# Should find __init__ in both models.py and services.py
assert any(match.source_file_path is not None and "models.py" in match.source_file_path for match in matches)
@@ -229,5 +231,5 @@ class TestProjectBasics:
# Test 6: Search with a pattern that should have no matches
no_match_pattern = r"def\s+this_method_does_not_exist\s*\([^)]*\):"
matches = project.search_files_for_pattern(no_match_pattern)
matches = project.search_source_files_for_pattern(no_match_pattern)
assert len(matches) == 0