"""Envelope tests for cat-object command.""" from __future__ import annotations 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 TestCatObjectEnvelope: def test_cat_object_info_has_envelope(self) -> None: # Get a real object ID from the repo r = runner.invoke(None, ["ls-files", "--json"]) assert r.exit_code == 0, r.output files = json.loads(r.output)["files"] assert files, "need at least one tracked file" obj_id = files[0]["object_id"] r2 = runner.invoke(None, ["cat-object", obj_id, "--json"]) assert r2.exit_code == 0, r2.output _check(json.loads(r2.output))