fix(lint): resolve remaining ruff errors and unblock MCP SSE test (#1)
Some checks failed
CI / lint (push) Failing after 2s
CI / typecheck (push) Failing after 1s
CI / test (push) Failing after 1s
CI / Secret scan (gitleaks) (push) Failing after 2s
CI / Security audit (bandit) (push) Failing after 2s

This commit is contained in:
Crypto Rug Munch 2026-07-02 23:18:40 +02:00
parent a7c30b12cd
commit 98eebe62bf
17 changed files with 60 additions and 87 deletions

View file

@ -12,12 +12,15 @@ import json
import socket
import subprocess
import time
from pathlib import Path
import httpx
from fastapi.testclient import TestClient
from api import app
REPO_ROOT = Path(__file__).resolve().parents[1]
def _find_free_port() -> int:
"""Return an available TCP port on 127.0.0.1."""
@ -31,9 +34,9 @@ def _wait_for_server(url: str, timeout: float = 30.0) -> None:
deadline = time.time() + timeout
while time.time() < deadline:
try:
httpx.get(url, timeout=1.0)
httpx.get(url, timeout=5.0)
return
except Exception:
except httpx.RequestError:
time.sleep(0.5)
raise TimeoutError(f"Server at {url} did not start within {timeout}s")
@ -194,7 +197,7 @@ class TestMCPSSE:
"--log-level",
"warning",
],
cwd="/home/dev/pry",
cwd=str(REPO_ROOT),
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)

View file

@ -101,19 +101,19 @@ async def test_seo_llm_enhancement_fills_empty_critical_fields():
patch("seo_monitor._get_attr", return_value=""),
patch("seo_monitor._count_links", return_value=0),
patch("llm_features.llm_seo_analyze", fake_llm),
patch("client.get_client") as mock_get_client,
):
# Mock the HTTP client to return a fake HTML response
with patch("client.get_client") as mock_get_client:
mock_resp = MagicMock()
mock_resp.is_success = True
mock_resp.text = "<html><body><h1>placeholder</h1></body></html>"
mock_resp.status_code = 200
mock_resp.headers = {"content-type": "text/html", "last-modified": ""}
mock_client = MagicMock()
mock_client.get = AsyncMock(return_value=mock_resp)
mock_get_client.return_value = mock_client
mock_resp = MagicMock()
mock_resp.is_success = True
mock_resp.text = "<html><body><h1>placeholder</h1></body></html>"
mock_resp.status_code = 200
mock_resp.headers = {"content-type": "text/html", "last-modified": ""}
mock_client = MagicMock()
mock_client.get = AsyncMock(return_value=mock_resp)
mock_get_client.return_value = mock_client
result = await analyze_seo("https://example.com/")
result = await analyze_seo("https://example.com/")
assert fake_llm.called
assert result["title"] == "Pry - Web Intelligence"

View file

@ -42,7 +42,7 @@ def test_json_output_has_required_fields(capsys):
log.info("test_event", key="value", count=42)
captured = capsys.readouterr()
# Find the JSON line
lines = [l for l in captured.out.splitlines() if l.strip().startswith("{")]
lines = [line for line in captured.out.splitlines() if line.strip().startswith("{")]
assert lines, f"no JSON output: {captured.out!r}"
record = json.loads(lines[0])
# Per CONVENTIONS.md Part 5, required fields: timestamp, level, service, event

View file

@ -31,9 +31,7 @@ def test_normalize_name_adds_pry_prefix():
def test_get_secret_default_when_missing():
# Use a name that definitely doesn't exist anywhere
with patch.dict(os.environ, {"PRY_SECRET_BACKEND": "env"}, clear=False):
# Clear any env vars that might match
with patch.dict(os.environ, {}, clear=False):
value = get_secret("definitely_not_a_real_secret_name_xyz_12345", default="missing")
value = get_secret("definitely_not_a_real_secret_name_xyz_12345", default="missing")
assert value == "missing"