Second batch of comprehensive linting fixes: Unused Arguments/Variables (136 errors): - ARG002/ARG001 (91 errors): Prefixed unused method/function arguments with '_' - Interface methods in adaptors (base.py, gemini.py, markdown.py) - AST analyzer methods maintaining signatures (code_analyzer.py) - Test fixtures and hooks (conftest.py) - Added noqa: ARG001/ARG002 for pytest hooks requiring exact names - F841 (45 errors): Prefixed unused local variables with '_' - Tuple unpacking where some values aren't needed - Variables assigned but not referenced Loop & Boolean Quality (28 errors): - B007 (18 errors): Prefixed unused loop control variables with '_' - enumerate() loops where index not used - for-in loops where loop variable not referenced - E712 (10 errors): Simplified boolean comparisons - Changed '== True' to direct boolean check - Changed '== False' to 'not' expression - Improved test readability Code Quality (24 errors): - SIM201 (4 errors): Already fixed in previous commit - SIM118 (2 errors): Already fixed in previous commit - E741 (4 errors): Already fixed in previous commit - Config manager loop variable fix (1 error) All Tests Passing: - test_scraper_features.py: 42 passed - test_integration.py: 51 passed - test_architecture_scenarios.py: 11 passed - test_real_world_fastmcp.py: 19 passed, 1 skipped Note: Some SIM errors (nested if, multiple with) remain unfixed as they would require non-trivial refactoring. Focus was on functional correctness. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
80 lines
2.7 KiB
Python
80 lines
2.7 KiB
Python
from unittest.mock import Mock, patch
|
|
|
|
from skill_seekers.cli.llms_txt_detector import LlmsTxtDetector
|
|
|
|
|
|
def test_detect_llms_txt_variants():
|
|
"""Test detection of llms.txt file variants"""
|
|
detector = LlmsTxtDetector("https://hono.dev/docs")
|
|
|
|
with patch("skill_seekers.cli.llms_txt_detector.requests.head") as mock_head:
|
|
mock_response = Mock()
|
|
mock_response.status_code = 200
|
|
mock_head.return_value = mock_response
|
|
|
|
variants = detector.detect()
|
|
|
|
assert variants is not None
|
|
assert variants["url"] == "https://hono.dev/llms-full.txt"
|
|
assert variants["variant"] == "full"
|
|
mock_head.assert_called()
|
|
|
|
|
|
def test_detect_no_llms_txt():
|
|
"""Test detection when no llms.txt file exists"""
|
|
detector = LlmsTxtDetector("https://example.com/docs")
|
|
|
|
with patch("skill_seekers.cli.llms_txt_detector.requests.head") as mock_head:
|
|
mock_response = Mock()
|
|
mock_response.status_code = 404
|
|
mock_head.return_value = mock_response
|
|
|
|
variants = detector.detect()
|
|
|
|
assert variants is None
|
|
assert mock_head.call_count == 3 # Should try all three variants
|
|
|
|
|
|
def test_url_parsing_with_complex_paths():
|
|
"""Test URL parsing handles non-standard paths correctly"""
|
|
detector = LlmsTxtDetector("https://example.com/docs/v2/guide")
|
|
|
|
with patch("skill_seekers.cli.llms_txt_detector.requests.head") as mock_head:
|
|
mock_response = Mock()
|
|
mock_response.status_code = 200
|
|
mock_head.return_value = mock_response
|
|
|
|
variants = detector.detect()
|
|
|
|
assert variants is not None
|
|
assert variants["url"] == "https://example.com/llms-full.txt"
|
|
mock_head.assert_called_with(
|
|
"https://example.com/llms-full.txt", timeout=5, allow_redirects=True
|
|
)
|
|
|
|
|
|
def test_detect_all_variants():
|
|
"""Test detecting all llms.txt variants"""
|
|
detector = LlmsTxtDetector("https://hono.dev/docs")
|
|
|
|
with patch("skill_seekers.cli.llms_txt_detector.requests.head") as mock_head:
|
|
# Mock responses for different variants
|
|
def mock_response(url, **_kwargs):
|
|
response = Mock()
|
|
# All 3 variants exist for Hono
|
|
if "llms-full.txt" in url or "llms.txt" in url or "llms-small.txt" in url:
|
|
response.status_code = 200
|
|
else:
|
|
response.status_code = 404
|
|
return response
|
|
|
|
mock_head.side_effect = mock_response
|
|
|
|
variants = detector.detect_all()
|
|
|
|
assert len(variants) == 3
|
|
assert any(v["variant"] == "full" for v in variants)
|
|
assert any(v["variant"] == "standard" for v in variants)
|
|
assert any(v["variant"] == "small" for v in variants)
|
|
assert all("url" in v for v in variants)
|