Files
SuperCharged-Claude-Code-Up…/prometheus/tests/parser/test_tree_sitter_parser.py
admin b52318eeae feat: Add intelligent auto-router and enhanced integrations
- Add intelligent-router.sh hook for automatic agent routing
- Add AUTO-TRIGGER-SUMMARY.md documentation
- Add FINAL-INTEGRATION-SUMMARY.md documentation
- Complete Prometheus integration (6 commands + 4 tools)
- Complete Dexto integration (12 commands + 5 tools)
- Enhanced Ralph with access to all agents
- Fix /clawd command (removed disable-model-invocation)
- Update hooks.json to v5 with intelligent routing
- 291 total skills now available
- All 21 commands with automatic routing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-28 00:27:56 +04:00

69 lines
2.1 KiB
Python

from pathlib import Path
from unittest.mock import MagicMock, create_autospec, mock_open, patch
import pytest
from tree_sitter._binding import Tree
from prometheus.parser.file_types import FileType
from prometheus.parser.tree_sitter_parser import (
FILE_TYPE_TO_LANG,
parse,
supports_file,
)
# Test fixtures
@pytest.fixture
def mock_python_file():
return Path("test.py")
@pytest.fixture
def mock_tree():
tree = create_autospec(Tree, instance=True)
return tree
# Test supports_file function
def test_supports_file_with_supported_type(mock_python_file):
with patch("prometheus.parser.file_types.FileType.from_path") as mock_from_path:
mock_from_path.return_value = FileType.PYTHON
assert supports_file(mock_python_file) is True
mock_from_path.assert_called_once_with(mock_python_file)
def test_parse_python_file_successfully(mock_python_file, mock_tree):
mock_content = b'print("hello")'
m = mock_open(read_data=mock_content)
with (
patch("prometheus.parser.file_types.FileType.from_path") as mock_from_path,
patch("prometheus.parser.tree_sitter_parser.get_parser") as mock_get_parser,
patch.object(Path, "open", m),
):
# Setup mocks
mock_from_path.return_value = FileType.PYTHON
mock_parser = mock_get_parser.return_value
mock_parser.parse.return_value = mock_tree
# Test parse function
result = parse(mock_python_file)
# Verify results and interactions
assert result == mock_tree
mock_from_path.assert_called_once_with(mock_python_file)
mock_get_parser.assert_called_once_with("python")
mock_parser.parse.assert_called_once_with(mock_content)
def test_parse_all_supported_languages():
"""Test that we can get parsers for all supported languages."""
with patch("tree_sitter_language_pack.get_parser") as mock_get_parser:
mock_parser = MagicMock()
mock_get_parser.return_value = mock_parser
for lang in FILE_TYPE_TO_LANG.values():
mock_get_parser(lang)
mock_get_parser.assert_called_with(lang)
mock_get_parser.reset_mock()