ai-code-review-agent / tests /test_tools.py
Padmanav's picture
fixed lint
a79668c
Raw
History Blame Contribute Delete
1 kB
import os
import tempfile
from app.tools.file_scanner import scan_repository, get_python_files
from app.tools.ast_parser import parse_python_file
def test_scan_repository_empty_dir():
with tempfile.TemporaryDirectory() as tmpdir:
result = scan_repository(tmpdir)
assert result["total_files"] == 0
assert result["primary_language"] == "Unknown"
def test_get_python_files_finds_py():
with tempfile.TemporaryDirectory() as tmpdir:
path = os.path.join(tmpdir, "sample.py")
with open(path, "w") as f:
f.write("x = 1\n")
files = get_python_files(tmpdir)
assert any("sample.py" in f for f in files)
def test_parse_python_file_extracts_functions():
with tempfile.TemporaryDirectory() as tmpdir:
path = os.path.join(tmpdir, "sample.py")
with open(path, "w") as f:
f.write("def hello():\n pass\n")
result = parse_python_file(path)
assert any(fn["name"] == "hello" for fn in result["functions"])