test_agent_config_envelope.py
python
sha256:b636f72dcba9e190afb980bece906fa5b717fbde014b76ef023df8cb96e01eb9
docs: expand cache plan with all seven testing tiers and do…
Sonnet 4.6
133 days ago
| 1 | """Envelope tests for ``muse agent-config`` subcommands.""" |
| 2 | from __future__ import annotations |
| 3 | import json, os, pathlib |
| 4 | import pytest |
| 5 | from tests.cli_test_helper import CliRunner |
| 6 | |
| 7 | runner = CliRunner() |
| 8 | |
| 9 | def _invoke(repo, args): |
| 10 | saved = os.getcwd() |
| 11 | try: |
| 12 | os.chdir(repo) |
| 13 | return runner.invoke(None, args) |
| 14 | finally: |
| 15 | os.chdir(saved) |
| 16 | |
| 17 | @pytest.fixture() |
| 18 | def repo(tmp_path): |
| 19 | saved = os.getcwd() |
| 20 | try: |
| 21 | os.chdir(tmp_path) |
| 22 | runner.invoke(None, ["init"]) |
| 23 | finally: |
| 24 | os.chdir(saved) |
| 25 | return tmp_path |
| 26 | |
| 27 | _CMDS = ["init", "status", "inspect"] |
| 28 | |
| 29 | class TestAgentConfigEnvelope: |
| 30 | def _check(self, r): |
| 31 | assert r.exit_code == 0, r.output |
| 32 | d = json.loads(r.output) |
| 33 | for field in ("muse_version", "schema", "timestamp", "warnings"): |
| 34 | assert field in d, f"missing {field}" |
| 35 | assert "schema_version" not in d |
| 36 | return d |
| 37 | |
| 38 | def test_init_envelope(self, repo): |
| 39 | self._check(_invoke(repo, ["agent-config", "init", "-j"])) |
| 40 | |
| 41 | def test_status_envelope(self, repo): |
| 42 | _invoke(repo, ["agent-config", "init"]) |
| 43 | self._check(_invoke(repo, ["agent-config", "status", "-j"])) |
| 44 | |
| 45 | def test_inspect_envelope(self, repo): |
| 46 | _invoke(repo, ["agent-config", "init"]) |
| 47 | self._check(_invoke(repo, ["agent-config", "inspect", "-j"])) |
| 48 | |
| 49 | def test_sync_envelope(self, repo): |
| 50 | _invoke(repo, ["agent-config", "init"]) |
| 51 | self._check(_invoke(repo, ["agent-config", "sync", "-j"])) |
| 52 | |
| 53 | def test_read_envelope(self, repo): |
| 54 | _invoke(repo, ["agent-config", "init"]) |
| 55 | self._check(_invoke(repo, ["agent-config", "read", "-j"])) |
File History
2 commits
sha256:b636f72dcba9e190afb980bece906fa5b717fbde014b76ef023df8cb96e01eb9
docs: expand cache plan with all seven testing tiers and do…
Sonnet 4.6
133 days ago
sha256:7f9e2ef5286aedad9c1e6011b4c46ca27f39dbdad6e3409357e36b26e46b3b7c
docs: docstring sprint for-each-ref→hotspots — idiomatic ru…
Sonnet 4.6
patch
139 days ago