"""Asserts the maintainer-only Catalog Console (catalog_console.py, catalog_review.py) is never bundled into the release binary. A signing/review tool shipping to end users would be an own-goal (issue #62): it has no reason to run on a user's machine, and its presence would be a confusing artefact of a build that's supposed to be a thin GUI over mcpServers config editing.""" from __future__ import annotations from pathlib import Path REPO_ROOT = Path(__file__).resolve().parent.parent SPEC_PATH = REPO_ROOT / "bcc.spec" _EXCLUDED_FILES = ("catalog_console.py", "catalog_review.py") def test_spec_file_exists(): assert SPEC_PATH.exists() def test_console_files_not_named_in_spec(): """The spec text must never reference either maintainer-only module -- not as the Analysis entry point, not in datas, not anywhere.""" spec_text = SPEC_PATH.read_text(encoding="utf-8") for filename in _EXCLUDED_FILES: assert filename not in spec_text, ( f"{filename} must never be referenced by bcc.spec -- it is a " "maintainer-only tool and must not ship to users." ) def test_spec_analysis_entry_point_is_bcc_py_only(): """PyInstaller's Analysis(...) call determines the dependency-scanned entry point(s); it must be bcc.py alone.""" spec_text = SPEC_PATH.read_text(encoding="utf-8") assert 'Analysis(\n ["bcc.py"],' in spec_text or 'Analysis(["bcc.py"]' in spec_text, ( "bcc.spec's Analysis(...) entry point changed shape -- re-verify by hand " "that catalog_console.py / catalog_review.py are still excluded." ) def test_console_modules_exist_but_are_standalone_top_level_files(): """Sanity check the files this test is guarding actually exist as top-level modules (not, say, silently moved into a package PyInstaller's Analysis would still pick up as an implicit import of bcc.py).""" for filename in _EXCLUDED_FILES: assert (REPO_ROOT / filename).exists() # bcc.py must not import them. bcc_text = (REPO_ROOT / "bcc.py").read_text(encoding="utf-8") module_name = filename.removesuffix(".py") assert f"import {module_name}" not in bcc_text assert f"from {module_name}" not in bcc_text def test_requirements_files_do_not_reference_console_only_needs(): """catalog_console.py's only import beyond the shipped stack is the optional `keyring` package, which is intentionally NOT added as a hard dependency anywhere a user install would pick it up.""" for req_file in ("requirements.txt", "requirements-dev.txt"): path = REPO_ROOT / req_file if not path.exists(): continue text = path.read_text(encoding="utf-8").lower() assert "keyring" not in text