from __future__ import annotations import logging from io import StringIO import pytest from sync_state_machine.pipeline.summary_report import print_pipeline_summary class _FakeBindingManager: async def get_all_records(self, node_type: str) -> list[dict]: return [] class _FakeDataSource: def get_action_summary(self) -> dict: return {} class _FakeCollection: def filter(self, *, node_type: str) -> list: return [] @pytest.mark.asyncio async def test_pipeline_summary_omits_diff_schemas_column() -> None: stream = StringIO() logger = logging.getLogger("tests.summary_report") logger.handlers.clear() logger.setLevel(logging.INFO) logger.propagate = False handler = logging.StreamHandler(stream) handler.setFormatter(logging.Formatter("%(message)s")) logger.addHandler(handler) try: await print_pipeline_summary( logger=logger, node_types=["project"], binding_manager=_FakeBindingManager(), local_datasource=_FakeDataSource(), remote_datasource=_FakeDataSource(), local_collection=_FakeCollection(), remote_collection=_FakeCollection(), consistency_by_type={ "project": { "checked_pairs": 1, "mismatch_count": 1, "fields": [ { "field_name": "actual_production_date", "mismatch_count": 1, "total_count": 1, "schema_refs": ["ProjectResponseBase", "ProjectBaseInfoUpdate"], "samples": [{"local": None, "remote": "2025-11-14"}], } ], } }, stats={ "loaded": 1, "synced": 0, "failed": 0, "post_check_passed": True, }, ) finally: logger.removeHandler(handler) output = stream.getvalue() assert "diff_schemas" not in output assert "ProjectResponseBase" not in output assert "ProjectBaseInfoUpdate" not in output assert "field mismatch/total samples" in output assert "actual_production_date" in output assert "None/'2025-11-14'" in output