"""Envelope tests for config command.""" from __future__ import annotations import pathlib from collections.abc import Mapping import json import pytest from tests.cli_test_helper import CliRunner runner = CliRunner() _FIELDS = ("muse_version", "schema", "timestamp", "warnings") def _check(d: Mapping[str, object]) -> None: for f in _FIELDS: assert f in d, f"missing {f}" assert "schema_version" not in d class TestConfigCmdEnvelope: def test_config_read_has_envelope(self, muse_repo: pathlib.Path) -> None: r = runner.invoke(None, ["config", "read", "--json"], cwd=muse_repo) assert r.exit_code == 0, r.output _check(json.loads(r.output)) def test_config_set_has_envelope(self, muse_repo: pathlib.Path) -> None: r = runner.invoke(None, ["config", "set", "hub.url", "https://localhost:1337", "--json"], cwd=muse_repo) assert r.exit_code == 0, r.output _check(json.loads(r.output)) def test_config_get_has_envelope(self, muse_repo: pathlib.Path) -> None: r = runner.invoke(None, ["config", "get", "hub.url", "--json"], cwd=muse_repo) assert r.exit_code == 0, r.output _check(json.loads(r.output))