test(#830): add pytest suite for analyze-transcript.py - #863
test(#830): add pytest suite for analyze-transcript.py#863fullsend-ai-coder[bot] wants to merge 2 commits into
Conversation
Add 111 tests covering all key functions and subcommands of the transcript analyzer script. Tests are organized by component: - parse_line_range, truncate, extract_content_blocks, get_tool_result_text: unit tests for utility functions - detect_file_type: OTLP detection, non-dict JSON, non-JSON, unreadable files, blank-line-heavy files, empty files - parse_lines / iter_messages: line range filtering, malformed input resilience, non-UTF-8 content, queue/last-prompt types - _accumulate_stats: token accounting, duration calculation, stop reasons, pre-iterated messages, edge cases - Error detection: is_error flag, error tags, result error patterns, assistant keyword mentions, false positive checks - Host matching: exact match, parent-domain, case-insensitive, combined method/host filters - parse_sandbox_log: OCSF entry parsing, field extraction - Subcommand e2e: summary, errors, audit, tools, conversation, search, network, network-search in text and JSON modes Includes crafted JSONL/log fixtures under testdata/ and wires the test into the Makefile script-test target. Note: pre-commit could not run in sandbox (network error fetching hook environments). The post-script runs it authoritatively. Closes #830
|
🤖 Finished Review · ✅ Success · Started 9:44 AM UTC · Completed 9:56 AM UTC |
ReviewFindingsMedium
Previous runReviewFindingsMedium
Low
|
|
/fs-fix |
|
🤖 Finished Fix · ✅ Success · Started 10:31 AM UTC · Completed 10:36 AM UTC |
- test_non_utf8_resilience: assert exact count (== 3) instead of loose lower bound (>= 2) since the fixture deterministically produces 3 parseable lines. - test_json_with_host_filter: assert result count (== 3), verify all returned hosts contain "github.com", and confirm excluded hosts (npmjs) are absent from the filtered output. Addresses review feedback on #863
🔧 Fix agent — iteration 1 (human-triggered)Addressed 2 of 3 review findings by tightening test assertions. Finding 1 (protected-path) is informational and requires no code change. All 111 tests pass. Fixed (2):
Disagreed (1):
Tests: passedNext steps:
|
|
🤖 Finished Review · ✅ Success · Started 10:40 AM UTC · Completed 10:54 AM UTC |
|
This pull request has been automatically marked as stale because it has not had any activity in the last month. It will be closed in 2 weeks if no further activity occurs. Remove the |
Summary
Add a comprehensive pytest suite (111 tests) for
skills/analyze-transcript/analyze-transcript.py, covering all key functions and subcommands that were previously untested. The script has ~820 lines of heuristic-based parsing logic that is easy to regress on.Related Issue
Fixes #830
Changes
skills/analyze-transcript/analyze_transcript_test.pywith 111 tests organized by component:parse_line_range,truncate,extract_content_blocks,get_tool_result_text— unit tests for utility functionsdetect_file_type— OTLP telemetry detection, non-dict JSON, non-JSON lines, unreadable files, blank-line-heavy files, empty files, stdin bypassparse_lines/iter_messages— line range filtering, malformed input resilience, non-UTF-8 content, queue-operation and last-prompt type handling_accumulate_stats— token accounting, duration calculation, stop reasons, pre-iterated messages, edge cases (no timestamps, empty file)_is_error_result,_check_block_error,_collect_errors) —is_errorflag,<error>tags,<tool_use_error>tags,_RESULT_ERROR_PATTERNSmatching, assistant keyword mentions, false positive checks_host_matches,_match_host,_match_http_entry) — exact match, parent-domain, case-insensitive, combined method/host filtersparse_sandbox_log— OCSF entry parsing, field extraction, denied entries, non-OCSF line skippingsummary,errors,audit,tools,conversation,search,network,network-searchin both text and JSON output modesskills/analyze-transcript/testdata/covering valid transcripts, OTLP telemetry, non-dict JSON, non-JSON lines, non-UTF-8 content, blank-heavy files, error patterns, and sandbox network logsscript-testtargetTesting
python3 -m pytest skills/analyze-transcript/analyze_transcript_test.py -v)Closes #830
Post-script verification
agent/830-analyze-transcript-tests)c887fc47c59d8b87b5282ca44044d2933d30df41..HEAD)