mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 08:14:59 +00:00
test: add tests for is_important() and filter_important_files()
This commit is contained in:
parent
ff0350f5ae
commit
2af6b96daa
1 changed files with 66 additions and 0 deletions
|
@ -0,0 +1,66 @@
|
|||
import os
|
||||
import pytest
|
||||
from aider.special import is_important, filter_important_files
|
||||
|
||||
def test_is_important():
|
||||
# Test common important files
|
||||
assert is_important("README.md")
|
||||
assert is_important(".gitignore")
|
||||
assert is_important("requirements.txt")
|
||||
assert is_important("setup.py")
|
||||
|
||||
# Test files in .github/workflows
|
||||
assert is_important(os.path.join(".github", "workflows", "test.yml"))
|
||||
assert is_important(os.path.join(".github", "workflows", "deploy.yml"))
|
||||
|
||||
# Test files that should not be considered important
|
||||
assert not is_important("random_file.txt")
|
||||
assert not is_important("src/main.py")
|
||||
assert not is_important("tests/test_app.py")
|
||||
|
||||
def test_filter_important_files():
|
||||
files = [
|
||||
"README.md",
|
||||
"src/main.py",
|
||||
".gitignore",
|
||||
"tests/test_app.py",
|
||||
"requirements.txt",
|
||||
".github/workflows/test.yml",
|
||||
"random_file.txt",
|
||||
]
|
||||
|
||||
important_files = filter_important_files(files)
|
||||
|
||||
assert set(important_files) == {
|
||||
"README.md",
|
||||
".gitignore",
|
||||
"requirements.txt",
|
||||
".github/workflows/test.yml",
|
||||
}
|
||||
|
||||
def test_is_important_case_sensitivity():
|
||||
# Test case sensitivity
|
||||
assert is_important("README.md")
|
||||
assert not is_important("readme.md")
|
||||
assert is_important(".gitignore")
|
||||
assert not is_important(".GITIGNORE")
|
||||
|
||||
def test_is_important_with_paths():
|
||||
# Test with different path formats
|
||||
assert is_important("project/README.md")
|
||||
assert is_important("./README.md")
|
||||
assert is_important("/absolute/path/to/README.md")
|
||||
|
||||
@pytest.mark.parametrize("file_path", [
|
||||
"README",
|
||||
"README.txt",
|
||||
"README.rst",
|
||||
"LICENSE",
|
||||
"LICENSE.md",
|
||||
"LICENSE.txt",
|
||||
"Dockerfile",
|
||||
"package.json",
|
||||
"pyproject.toml",
|
||||
])
|
||||
def test_is_important_various_files(file_path):
|
||||
assert is_important(file_path)
|
Loading…
Add table
Add a link
Reference in a new issue