Skip to content

Add unit tests for sync_from_registry.py and build_site.py; make the manifest-count test independent of local clones #124

Closed

Description

@TMHSDigital

Why it matters

sync_from_registry.py writes every derived artifact and backs a required check. site-template/build_site.py builds GitHub Pages for every tool repo. Neither has unit tests. The escaping bugs in the sync script (see the separate issue) would have been caught by basic tests.

Separately, one existing test is non-deterministic: its result depends on whatever sibling repos happen to be checked out locally.

Evidence

  • Neither sync_from_registry nor build_site is imported anywhere in tests/. The sync script only runs in CI as --check against current files, which proves "no drift today" but exercises no edge cases.
  • pytest -q currently gives 258 passed, 1 failed, 1 skipped. The failure is tests/test_registry_manifest_counts.py::test_registry_mcptools_matches_local_manifests, which reads sibling checkouts under the parent directory, so a stale local clone fails the suite.
  • The --fix path in scripts/drift_check/cli.py (_apply_fixes_live, scripts/add_frontmatter.py, scripts/add_comment_marker.py) has no tests either.
    • Its docstring (cli.py:~470) says "missing or malformed" signals are fixable, but both helpers only rewrite an existing marker and return 1 when it is absent.
    • add_frontmatter.py:16 _FRONTMATTER_RE is unused.

Suggested approach

  • sync script: add fixture-based tests that call sync_all(root=tmp, check=...) on a minimal catalog. Cover marker replacement, backslashes, embedded-JSON escaping, --check drift detection and idempotency.
  • build_site.py: add tests with a minimal plugin fixture and a minimal mcp-server fixture. Assert the HTML renders, escapes content, and includes the expected sections.
  • Manifest-count test: gate it behind an env flag (for example DTD_SIBLING_REPOS=1) or skip it when siblings are missing. Better, move it to a scheduled job that fetches upstream manifests.
  • --fix: either implement insert-if-missing or correct the docstring, then add tests. Delete the dead regex.

Done when

  • Both scripts have meaningful coverage.
  • pytest is green on a fresh clone.
  • --fix behaves as documented.

Activity

  1. added
    priority: medium
    testing
    on Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: mediumtesting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions