gabriel / muse public
test_fetch_envelope.py python
60 lines 1.9 KB
Raw
sha256:81ae324db5ad375fbfe4834c6fcb378312cafad3cc92dec5d3e5c427306621a2 fix: remove commit_exists filter from have anchors — server… Sonnet 4.6 patch 20 days ago
1 """Envelope tests for fetch command."""
2 from __future__ import annotations
3 from collections.abc import Mapping
4 import argparse
5 import json
6 import pytest
7 from tests.cli_test_helper import CliRunner
8
9 runner = CliRunner()
10
11 _FIELDS = ("muse_version", "schema", "timestamp", "warnings")
12
13
14 def _check(d: Mapping[str, object]) -> None:
15 for f in _FIELDS:
16 assert f in d, f"missing {f}"
17 assert "schema_version" not in d
18
19
20 class TestFetchEnvelope:
21 def test_fetch_no_remote_has_envelope(self) -> None:
22 # fetch with an unconfigured remote exits non-zero but still emits JSON envelope
23 r = runner.invoke(None, ["fetch", "nonexistent_remote_xyz", "--json"])
24 assert r.exit_code != 0
25 # runner captures stdout + stderr; first line is the JSON envelope
26 _check(json.loads(r.output.splitlines()[0]))
27
28
29 # ---------------------------------------------------------------------------
30 # TestRegisterFlags — argparse-level verification
31 # ---------------------------------------------------------------------------
32
33
34 class TestRegisterFlags:
35 """Verify that register() wires --json / -j correctly."""
36
37 def _make_parser(self) -> "argparse.ArgumentParser":
38 import argparse
39 from muse.cli.commands.fetch import register
40 ap = argparse.ArgumentParser()
41 subs = ap.add_subparsers()
42 register(subs)
43 return ap
44
45 def test_json_flag_long(self) -> None:
46 ns = self._make_parser().parse_args(["fetch", "--json"])
47 assert ns.json_out is True
48
49 def test_j_alias(self) -> None:
50 ns = self._make_parser().parse_args(["fetch", "-j"])
51 assert ns.json_out is True
52
53 def test_default_is_text(self) -> None:
54 ns = self._make_parser().parse_args(["fetch"])
55 assert ns.json_out is False
56
57 def test_dest_is_json_out(self) -> None:
58 ns = self._make_parser().parse_args(["fetch", "-j"])
59 assert hasattr(ns, "json_out")
60 assert not hasattr(ns, "fmt")
File History 4 commits
sha256:81ae324db5ad375fbfe4834c6fcb378312cafad3cc92dec5d3e5c427306621a2 fix: remove commit_exists filter from have anchors — server… Sonnet 4.6 patch 20 days ago
sha256:36c3cb3e76619d4c30a6d9bf81b5ec4ff148e30dcfed913e3114ca7b43b81c7e fix: rename objects→blobs in push client and all stale test… Sonnet 4.6 patch 22 days ago
sha256:c06a9b9b9fee26c68ea725b44d54b2c0a171301ce9de746d5b656617b4463a9a fix: repair four test failures from post-migration audit Sonnet 4.6 patch 28 days ago
sha256:1900655993c83c4107067375548a7be823e471d2515830842f1a12cba4bd3cdf fix: unified object store migration — idempotent writes, JS… Sonnet 4.6 minor 29 days ago