#!/usr/bin/env python3
"""Template dictionary evidence differs from empty personnel export evidence."""
import hashlib
import json
import subprocess
from pathlib import Path
import integrate_20261010 as tool
from integrate_20261011_batches46_48 import item
PYTHON = '/Users/wiscourper/.cache/codex-runtimes/codex-primary-runtime/dependencies/python/bin/python3'

def verify():
    p = Path('/Users/wiscourper/Documents/workspace/local/dm8-independent-20261013/session-store-nutrition/verify-export761-762.py')
    q = tool.ROOT.parent / 'worktrees/dm8-compat-20261012/private-prepay-harness/review-s1-export761-762/verify_independent.py'
    assert hashlib.sha256(p.read_bytes()).hexdigest() == '72f2a630b826ad75f30da9516183997f3629a852083b3ae97d6512b9750bcd45'
    assert hashlib.sha256(q.read_bytes()).hexdigest() == '421746ad935e0ac09b9344d2b7ff511257e657724c4d16647bc7e25a4b9108ce'
    a = json.loads(subprocess.check_output([PYTHON, '-B', str(p)]))
    b = json.loads(subprocess.check_output([PYTHON, '-B', str(q)]))
    assert a['offline'] and a['checks'] == 5295 and not a['business_code_changed']
    assert b['passed'] and b['checks'] == 940 and not b['original_Excel_UI_tested'] and not b['nonempty_export_tested']

if __name__ == '__main__':
    audit = Path(__file__).with_name('integration-20261013-staff-export-files.json')
    assert not audit.exists(), 'Never replay main'
    report = tool.STORE + 'parallel-staff-export-files-20261013/ROOT_REVIEW.md'
    rows = [item('store', 'GET', '/p/staff/downTemplate', '', evidence=report,
        success_case='partial-evidence-original-dictionary-query-and-XLSX-template-structure',
        readback='tested-pass-per-side-identity-dictionary-validation-formula-and-original-file',
        parity='partial-evidence-static-cells-types-equal-different-dictionary-data-source-verified'),
        item('store', 'GET', '/p/staff/export', '', evidence=report,
            mysql_state='partial-evidence-empty-personnel-query-and-original-XLS-only',
            dm_state='partial-evidence-empty-personnel-query-and-original-XLS-only',
            success_case='partial-evidence-limited-empty-export-no-personnel-data-rows',
            readback='partial-evidence-own-three-fixture-rows-unchanged-runtime-DML0',
            parity='partial-evidence-limited-11-string-XLS-headers-original-errors-retained')]
    tool.main(rows, audit, verify)
