free-claude-code/smoke/lib/report.py
Ali Khokhar 462a9430bb
Add local live smoke test suite (#148)
## Summary
- add an opt-in local `smoke/` pytest suite for API, auth, providers,
CLI, IDE-shaped requests, messaging, voice, tools, and thinking stream
contracts
- keep smoke tests out of normal CI collection with `testpaths =
["tests"]`
- write sanitized smoke artifacts under `.smoke-results/`

## Verification
- `uv run ruff format`
- `uv run ruff check`
- `uv run ty check`
- `uv run ty check smoke`
- `FCC_LIVE_SMOKE=1 FCC_SMOKE_TARGETS=all FCC_SMOKE_RUN_VOICE=1 uv run
pytest smoke -n 0 -m live -s --tb=short` -> 17 passed, 9 skipped
- `uv run pytest` -> 904 passed

## Notes
- Skipped live checks require local credentials/tools/services, such as
provider models, Telegram/Discord targets, voice backend, or Claude CLI.
- `claude-pick` smoke was intentionally removed.
2026-04-23 19:06:09 -07:00

58 lines
1.5 KiB
Python

"""Small JSON report writer for smoke runs."""
from __future__ import annotations
import json
import time
from dataclasses import asdict, dataclass
from .config import SmokeConfig, redacted
@dataclass(slots=True)
class SmokeOutcome:
nodeid: str
outcome: str
duration_s: float
markers: list[str]
detail: str
class SmokeReport:
def __init__(self, config: SmokeConfig) -> None:
self.config = config
self.started_at = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
self.outcomes: list[SmokeOutcome] = []
def add(
self,
*,
nodeid: str,
outcome: str,
duration_s: float,
markers: list[str],
detail: str = "",
) -> None:
self.outcomes.append(
SmokeOutcome(
nodeid=nodeid,
outcome=outcome,
duration_s=duration_s,
markers=markers,
detail=redacted(detail),
)
)
def write(self) -> None:
self.config.results_dir.mkdir(parents=True, exist_ok=True)
path = (
self.config.results_dir
/ f"report-{self.config.worker_id}-{int(time.time())}.json"
)
payload = {
"started_at": self.started_at,
"worker_id": self.config.worker_id,
"targets": sorted(self.config.targets),
"outcomes": [asdict(outcome) for outcome in self.outcomes],
}
path.write_text(json.dumps(payload, indent=2, sort_keys=True), encoding="utf-8")