gabriel / muse public
test_plugin_registry.py python
88 lines 3.4 KB
Raw
sha256:c0eba5ad689cec79f4a3fcdc4f5da78556cb4b8cb7b330f944634356c10379ed chore: pivot to nightly channel — bump version to 0.2.0.dev… Sonnet 5 patch 14 days ago
1 """Unit tests for muse.plugins.registry — resolve_plugin, read_domain, registered_domains."""
2
3 import json
4 import pathlib
5
6 import pytest
7
8 from muse._version import __version__
9 from muse.core.paths import muse_dir, repo_json_path
10 from muse.core.errors import MuseCLIError
11 from muse.domain import MuseDomainPlugin
12 from muse.plugins.code.plugin import CodePlugin
13 from muse.plugins.registry import read_domain, registered_domains, resolve_plugin
14
15
16 def _make_repo(tmp_path: pathlib.Path, domain: str = "code") -> pathlib.Path:
17 """Scaffold a minimal .muse/repo.json so registry helpers can run."""
18 dot_muse = muse_dir(tmp_path)
19 dot_muse.mkdir()
20 repo_json_path(tmp_path).write_text(
21 json.dumps({"repo_id": "test-id", "schema_version": __version__, "domain": domain})
22 )
23 return tmp_path
24
25
26 class TestReadDomain:
27 def test_returns_stored_domain(self, tmp_path: pathlib.Path) -> None:
28 root = _make_repo(tmp_path, domain="code")
29 assert read_domain(root) == "code"
30
31 def test_defaults_to_code_when_key_missing(self, tmp_path: pathlib.Path) -> None:
32 dot_muse = muse_dir(tmp_path)
33 dot_muse.mkdir()
34 repo_json_path(tmp_path).write_text(json.dumps({"repo_id": "x"}))
35 assert read_domain(tmp_path) == "code"
36
37 def test_defaults_to_code_when_repo_json_absent(self, tmp_path: pathlib.Path) -> None:
38 muse_dir(tmp_path).mkdir()
39 assert read_domain(tmp_path) == "code"
40
41 def test_defaults_to_code_when_muse_dir_absent(self, tmp_path: pathlib.Path) -> None:
42 assert read_domain(tmp_path) == "code"
43
44
45 class TestResolvePlugin:
46 def test_returns_code_plugin_for_code_domain(self, tmp_path: pathlib.Path) -> None:
47 root = _make_repo(tmp_path, domain="code")
48 plugin = resolve_plugin(root)
49 assert isinstance(plugin, CodePlugin)
50
51 def test_returned_plugin_satisfies_protocol(self, tmp_path: pathlib.Path) -> None:
52 root = _make_repo(tmp_path, domain="code")
53 plugin = resolve_plugin(root)
54 assert isinstance(plugin, MuseDomainPlugin)
55
56 def test_raises_for_unknown_domain(self, tmp_path: pathlib.Path) -> None:
57 root = _make_repo(tmp_path, domain="unknown-domain")
58 with pytest.raises(MuseCLIError, match="unknown-domain"):
59 resolve_plugin(root)
60
61 def test_raises_error_mentions_registered_domains(self, tmp_path: pathlib.Path) -> None:
62 root = _make_repo(tmp_path, domain="bogus")
63 with pytest.raises(MuseCLIError, match="code"):
64 resolve_plugin(root)
65
66 def test_defaults_to_code_plugin_when_no_domain_key(self, tmp_path: pathlib.Path) -> None:
67 dot_muse = muse_dir(tmp_path)
68 dot_muse.mkdir()
69 repo_json_path(tmp_path).write_text(json.dumps({"repo_id": "x"}))
70 plugin = resolve_plugin(tmp_path)
71 assert isinstance(plugin, CodePlugin)
72
73
74 class TestRegisteredDomains:
75 def test_includes_code(self) -> None:
76 assert "code" in registered_domains()
77
78 def test_midi_suspended(self) -> None:
79 """MIDI domain is temporarily suspended pending its own security audit."""
80 assert "midi" not in registered_domains()
81
82 def test_returns_sorted_list(self) -> None:
83 domains = registered_domains()
84 assert domains == sorted(domains)
85
86 def test_returns_list_of_strings(self) -> None:
87 domains = registered_domains()
88 assert all(isinstance(d, str) for d in domains)
File History 10 commits
sha256:c287f599c5429903a139eadf3c5db5d930520e57cb0c3c575d9570e953c3b2d6 chore: bump version to 0.2.0.dev2 — nightly.2 Sonnet 4.6 patch 13 days ago
sha256:8de4334a98c945aace420969d389ad678aa926d4ab4e886b2ac4c4241cb3bf2b revert: keep pyproject.toml in canonical PEP 440 form Sonnet 4.6 patch 16 days ago
sha256:50bb615c573aa4b928fca75b60f82ba2a659910066507cec6a95c412ae22ccb9 docs: add issue docs for push have-negotiation bug (#55) an… Sonnet 4.6 19 days ago
sha256:d90d175cded68aae1d4ffcf4858917854195d0cd8ce1fe73cee4dbc02541cb74 chore: trigger push to surface null-OID paths Sonnet 4.6 25 days ago
sha256:e452ad9a6ace6ccc6d875a35e06caf9da5576a970c1c36133b69a891ce5fefa8 chore: prebuild timing test Sonnet 4.6 35 days ago
sha256:0008ab6695e3e064b3e236b24fd19e538fef6a588eb0d211622f4466d919c0b1 merge: pull staging/dev — advance to 0.2.0rc12 Sonnet 4.6 patch 37 days ago
sha256:9c33d61749fff814c5226d5386aa2af7064c2c02788594a25fdd709358132eea fix: _PROPOSAL_PREFIX_RESOLVE_LIMIT 200 → 100 to match hub … Sonnet 4.6 48 days ago
sha256:36c3cb3e76619d4c30a6d9bf81b5ec4ff148e30dcfed913e3114ca7b43b81c7e fix: rename objects→blobs in push client and all stale test… Sonnet 4.6 patch 51 days ago
sha256:c06a9b9b9fee26c68ea725b44d54b2c0a171301ce9de746d5b656617b4463a9a fix: repair four test failures from post-migration audit Sonnet 4.6 patch 57 days ago
sha256:1900655993c83c4107067375548a7be823e471d2515830842f1a12cba4bd3cdf fix: unified object store migration — idempotent writes, JS… Sonnet 4.6 minor 58 days ago