test_plugin_registry.py
python
sha256:81ae324db5ad375fbfe4834c6fcb378312cafad3cc92dec5d3e5c427306621a2
fix: remove commit_exists filter from have anchors — server…
Sonnet 4.6
patch
21 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
4 commits
sha256:81ae324db5ad375fbfe4834c6fcb378312cafad3cc92dec5d3e5c427306621a2
fix: remove commit_exists filter from have anchors — server…
Sonnet 4.6
patch
21 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