Spaces:
Running
Running
File size: 1,002 Bytes
056e46c a79668c | 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 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"])
|