codeflash-agent/evals/templates/crossdomain-hard/tests/test_aggregator.py
Kevin Turcios 33faedf427
Add Unstructured report, rewrite statusline, format evals/scripts (#20)
* Add Unstructured engagement report as uv workspace member

Three-tier Plotly Dash app (Executive Brief, Engineering Team, Full
Detail) with data in JSON, theme constants in theme.py, and Dash
production improvements (Google Fonts, clientside callbacks, meta tags).

Also: add .playwright-mcp/ to .gitignore, add reports/* ruff overrides,
remove tracked .codeflash/observability/read-tracker.

* Rewrite statusline to derive context from git state

Detects active area from changed files (reports, packages, plugin,
.codeflash, case-studies, evals), falls back to branch name convention
(perf/*, feat/*, fix/*), shows dirty indicator. Uses whoami for
cross-platform user detection.

* Add pre-push lint rule to commit guidelines

* Exclude .codeflash/ from ruff linting

Benchmark and profiling scripts in .codeflash/ are scratch work, not
package source. Excluding them prevents CI failures from ad-hoc scripts.

* Run ruff format across packages, scripts, evals, and plugin refs

* Fix github-app async test failures in CI

Add asyncio_mode = "auto" to root pytest config so async tests
are detected when running from the repo root via uv run pytest packages/.
2026-04-15 03:06:16 -05:00

32 lines
1.1 KiB
Python

from pipeline.aggregator import aggregate_by_category
def test_aggregate_basic():
events = [
{"category": "web", "source": "s1", "value": 10.0},
{"category": "web", "source": "s2", "value": 20.0},
{"category": "api", "source": "s1", "value": 5.0},
{"category": "api", "source": "s1", "value": 15.0},
]
result = aggregate_by_category(events)
assert len(result) == 2
assert result["web"]["count"] == 2
assert result["api"]["count"] == 2
def test_aggregate_large_batch():
"""Large event batch — uses too much memory for production volumes."""
categories = [f"cat-{i}" for i in range(500)]
sources = [f"source-{i}" for i in range(50)]
events = []
for i in range(200_000):
events.append(
{
"category": categories[i % len(categories)],
"source": sources[i % len(sources)],
"value": float(i % 1000),
}
)
result = aggregate_by_category(events)
assert len(result) == 500
assert all(r["count"] == 400 for r in result.values())