"""Todo8 r3 real-authority owner-summary binding tests."""

from __future__ import annotations

from dataclasses import replace
from datetime import date
from pathlib import Path

from checkin_cli.weekly_operations_owner_binding import (
    bind_weekly_summary_for_owner_draft,
)
from checkin_cli.weekly_operations_summary import build_weekly_operations_summary
from tests._weekly_operations_summary_support import approved_synthetic_week


def test_bound_owner_summary_rebuilds_exact_registered_authorities(tmp_path: Path) -> None:
    fixture = approved_synthetic_week(tmp_path)
    try:
        summary = build_weekly_operations_summary(
            fixture.canonical.source, fixture.sidecar.store, date(2026, 8, 17),
        )
        bound = bind_weekly_summary_for_owner_draft(
            fixture.canonical.source, fixture.sidecar.store, summary,
        )
        assert bound.verify() is True
        object.__setattr__(bound, "summary", replace(summary, submitted_count=3))
        assert bound.verify() is False
    finally:
        fixture.close()
