"""Envelope tests for fetch command.""" from __future__ import annotations import json import pytest from tests.cli_test_helper import CliRunner runner = CliRunner() _FIELDS = ("muse_version", "schema", "timestamp", "warnings") def _check(d: dict) -> None: for f in _FIELDS: assert f in d, f"missing {f}" assert "schema_version" not in d class TestFetchEnvelope: def test_fetch_no_remote_has_envelope(self): # fetch with an unconfigured remote exits non-zero but still emits JSON envelope r = runner.invoke(None, ["fetch", "nonexistent_remote_xyz", "--json"]) assert r.exit_code != 0 # runner captures stdout + stderr; first line is the JSON envelope _check(json.loads(r.output.splitlines()[0]))