Skip to content

Commit 098ded0

Browse files
aarthy-dkclaude
andcommitted
test(mcp): update get_profiling_run test for count_for_run-based hygiene rendering (TG-1135)
get_profiling_run now reads the hygiene breakdown from HygieneIssue.count_for_run instead of the select_summary buckets, so the unit test mocks count_for_run and asserts the separated likelihood / Potential PII rendering. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HE8KakxW43wFn3pW5cqV5b
1 parent 2645433 commit 098ded0

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

tests/unit/mcp/test_tools_profiling.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pytest
66

77
from testgen.common.models.data_column import ColumnProfileDetail, ColumnProfileSummary, DataColumnChars
8+
from testgen.common.models.hygiene_issue import HygieneIssueCounts, IssueCounts, PotentialPiiCounts
89
from testgen.common.pii_masking import PII_REDACTED
910
from testgen.mcp.exceptions import MCPResourceNotAccessible, MCPUserError
1011
from testgen.mcp.permissions import ProjectPermissions
@@ -635,15 +636,21 @@ def test_list_profiling_runs_malformed_schedule_raises(mock_tg_cls, mock_run_cls
635636
# ----------------------------------------------------------------------
636637

637638

639+
@patch("testgen.mcp.tools.profiling.HygieneIssue")
638640
@patch("testgen.mcp.tools.profiling.ProfilingRun")
639-
def test_get_profiling_run_returns_detail(mock_run_cls, db_session_mock):
641+
def test_get_profiling_run_returns_detail(mock_run_cls, mock_hygiene_cls, db_session_mock):
640642
summary = _mock_profiling_run()
641643
mock_run_cls.select_summary.return_value = ([summary], 1)
642644
mock_run = MagicMock(project_code="demo")
643645
mock_run_cls.get.return_value = mock_run
644646
mock_run_cls.select_table_breakdown.return_value = [
645647
MagicMock(schema_name="demo", table_name="orders", record_ct=1000, column_ct=5, anomaly_ct=2),
646648
]
649+
mock_hygiene_cls.count_for_run.return_value = IssueCounts(
650+
hygiene_issues=HygieneIssueCounts(definite=2, likely=2, possible=4),
651+
potential_pii=PotentialPiiCounts(high=0, moderate=8),
652+
dismissed=0,
653+
)
647654

648655
with patch("testgen.mcp.permissions._compute_project_permissions") as mock_compute:
649656
mock_compute.return_value = ProjectPermissions(
@@ -659,6 +666,10 @@ def test_get_profiling_run_returns_detail(mock_run_cls, db_session_mock):
659666
assert "Completed" in result
660667
assert "Per-table breakdown" in result
661668
assert "orders" in result
669+
# Hygiene breakdown comes from count_for_run, keeping Potential PII separate from "possible".
670+
mock_hygiene_cls.count_for_run.assert_called_once_with(summary.profiling_run_id)
671+
assert "8 total — 2 definite, 2 likely, 4 possible" in result
672+
assert "Potential PII:** 0 high, 8 moderate" in result
662673

663674

664675
@patch("testgen.mcp.tools.profiling.ProfilingRun")

0 commit comments

Comments
 (0)