Download tests_python/test_harness.py from build-small-hackathon/agent-swarm-workbench: direct link, hf CLI and curl.
- Browser
- Download file 1.57 kB
-
https://huggingface.co/spaces/build-small-hackathon/agent-swarm-workbench/resolve/main/tests_python/test_harness.py
- Command line
-
hf download hf://spaces/build-small-hackathon/agent-swarm-workbench/tests_python/test_harness.py
-
curl -L -o test_harness.py https://huggingface.co/spaces/build-small-hackathon/agent-swarm-workbench/resolve/main/tests_python/test_harness.py
1.57 kB
| import json | |
| import zipfile | |
| from arena.harness import main, run_harness | |
| def test_run_harness_completes_run_and_writes_zip(tmp_path) -> None: | |
| result = run_harness( | |
| prompt="Build a tiny CLI", | |
| criteria=["README explains the project"], | |
| user_tests=["test -f README.md"], | |
| archive_root=tmp_path / "archives", | |
| output_dir=tmp_path / "out", | |
| ) | |
| assert result.mode == "swarm" | |
| assert result.run.status == "completed" | |
| assert result.run.validation_report is not None | |
| assert result.run.validation_report.passed is True | |
| assert result.zip_path is not None | |
| with zipfile.ZipFile(result.zip_path) as zipped: | |
| assert {"README.md", "app.py", "harness_result.json", "pyproject.toml"}.issubset( | |
| set(zipped.namelist()) | |
| ) | |
| payload = json.loads(zipped.read("harness_result.json")) | |
| assert payload["run_id"] == result.run.id | |
| assert payload["workspace_dir"] == "/workspace" | |
| def test_harness_cli_prints_json_summary_and_zip_path(tmp_path, capsys) -> None: | |
| exit_code = main([ | |
| "--prompt", | |
| "Build docs", | |
| "--criteria", | |
| "docs exist", | |
| "--test", | |
| "test -f harness_result.json", | |
| "--output-dir", | |
| str(tmp_path), | |
| ]) | |
| captured = capsys.readouterr() | |
| payload = json.loads(captured.out) | |
| assert exit_code == 0 | |
| assert payload["mode"] == "swarm" | |
| assert payload["run"]["status"] == "completed" | |
| assert payload["run"]["validation_report"]["passed"] is True | |
| assert payload["zip_path"].endswith(".zip") | |