Skip to content

test: raise coverage from 62.8% to 97% with comprehensive new test suite - #1

Merged
denisecase merged 1 commit into
mainfrom
copilot/analyze-test-coverage
May 30, 2026
Merged

test: raise coverage from 62.8% to 97% with comprehensive new test suite#1
denisecase merged 1 commit into
mainfrom
copilot/analyze-test-coverage

Conversation

Copilot AI commented May 30, 2026

Copy link
Copy Markdown
Contributor

Test coverage was at 62.8% (barely above the 55% hard floor), with several modules at 17–38% — primarily the graph subsystem and role-capability-map validation, which were effectively untested.

New test files

  • test_graph_diagnostics.py — all GraphDiagnostic.render() branches (root-relative paths, missing fields, string root)
  • test_graph_load.py — full coverage of manifest discovery helpers (_string_value, _contains_contiguous_parts, _is_excluded_manifest_path, _discover_manifest_paths, _dependency_edges_from_items) and load_manifest_graph
  • test_graph_validate.py — SI01–SI04 invariants: cycle detection, unresolved deps, missing artifacts, class registry
  • test_graph_report.pyrender_markdown_report across empty/populated/diagnostic scenarios
  • test_validate_role_capability_map.py — all validation paths for validate_role_capability_map_data/file (missing sections, missing fields, empty values, unknown roles, malformed TOML)
  • tests/commands/test_validate_role_capability_map.py — command run() pass/fail/file-not-found paths
  • test_verify_graph.py_looks_like_schema_repo, _find_schema_repo, all _resolve_* helpers, and run() with pass/fail/report-write cases

Supplemental coverage in existing tests

  • test_load.pyget_git_tag success + CalledProcessError paths, find_manifest_path, repo_root_schema_path; packaged_schema_text gracefully skipped in editable installs
  • test_validate_manifest.py — missing repo.class/repo.name, None section/field definitions, contract section as non-dict
  • test_validate_schema.py — custom type registry (kind="record", missing fields key), invalid items in allowed_filenames/contract_roles.allowed, optional/forbidden sections with unknown refs

@denisecase
denisecase marked this pull request as ready for review May 30, 2026 17:53
Copilot AI review requested due to automatic review settings May 30, 2026 17:53
@denisecase
denisecase merged commit 99f8285 into main May 30, 2026
1 of 3 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds comprehensive unit tests to improve branch coverage for manifest graph verification, schema/manifest validation, and role-capability-map validation.

Changes:

  • Introduces new test suites for graph loading, validation, diagnostics rendering, report rendering, and the verify-graph command.
  • Expands existing schema/manifest/load tests to cover additional branches and error cases.
  • Adds command-level tests for validating role-capability-map files.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/test_verify_graph.py New tests covering schema repo/path resolution helpers and verify-graph command execution.
tests/test_validate_schema.py Adds additional branch-coverage tests for schema validation helpers and edge cases.
tests/test_validate_role_capability_map.py New tests for role-capability-map data/file validation.
tests/test_validate_manifest.py Adds additional branch-coverage tests for manifest validation error/skip paths.
tests/test_load.py Adds tests for git tag retrieval, manifest path discovery/loading, and packaged/repo-root schema helpers.
tests/test_graph_validate.py New tests for SI invariant validation behavior and diagnostics emitted.
tests/test_graph_report.py New tests for Markdown report rendering across empty/edge/diagnostic cases.
tests/test_graph_load.py New tests for graph loading helpers and graph construction from manifests.
tests/test_graph_diagnostics.py New tests for GraphDiagnostic.render() formatting and root-relative path rendering.
tests/commands/test_validate_role_capability_map.py New tests for CLI command return codes for role-capability-map validation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +108 to +119
def test_file_valid_returns_no_errors(tmp_path: Path) -> None:
import tomllib, io

# Write valid TOML from the data dict
data = _minimal_valid_data()
# Build a simple TOML string manually for only the top-level keys
# Use the actual project file instead
project_root = Path(__file__).parent.parent
real_path = project_root / "data" / "schema" / "role-capability-map.toml"
if real_path.exists():
errors = validate_role_capability_map_file(real_path)
assert errors == [], "\n".join(errors)
Comment on lines +28 to +33
def test_run_against_real_file_returns_0() -> None:
project_root = Path(__file__).parent.parent.parent
real_path = project_root / "data" / "schema" / "role-capability-map.toml"
if real_path.exists():
result = run(path=real_path)
assert result == 0
Comment on lines +3 to +5
from pathlib import Path
from typing import Any
from unittest.mock import patch
Comment on lines +6 to +8
import pytest

from se_manifest_schema.graph.diagnostics import GraphDiagnostic
Comment thread tests/test_graph_load.py

from pathlib import Path
from typing import Any
from unittest.mock import patch
Comment thread tests/test_load.py
import subprocess
from pathlib import Path
from unittest.mock import patch
from unittest.mock import MagicMock, patch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants