"""Envelope tests for content-grep 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 TestContentGrepEnvelope: def test_content_grep_has_envelope(self) -> None: # Search for something that exists in the repo source r = runner.invoke(None, ["content-grep", "def ", "--json"]) assert r.exit_code == 0, r.output _check(json.loads(r.output))