from pathlib import Path
ROOT=Path(__file__).resolve().parents[1]
def read(x): return (ROOT/x).read_text()
def test_v023_router_ui_and_version():
 s=read('app/main.py'); assert 'v023_router' in s and '/saas-commercial' in s
 assert (ROOT/'app/static/saas-commercial.html').exists()
def test_v023_models_and_migration():
 s=read('app/models/entities.py')+read('migrations/023_saas_commercial_operations.sql')
 for token in ['saas_onboarding_applications_v023','billing_customers_v023','billing_invoices_v023','billing_webhook_events_v023','tenant_rate_limit_policies_v023','usage_reconciliation_runs_v023']: assert token in s
 for token in ['ROW LEVEL SECURITY','WITH CHECK','activation_token_hash','external_event_id']: assert token in s
def test_v023_commercial_security_and_reconciliation():
 s=read('app/services/saas_commercial.py')+read('app/api/v023.py')
 for token in ['compare_digest','sha256','activation_expires_at','expire_quota_reservations','idempotency','verify_webhook','X-Signature','create_invoice']: assert token in s
def test_v023_docs():
 for f in ['USER_GUIDE_V023.md','ADMIN_GUIDE_V023.md','HOMOLOGATION_V023.md']: assert (ROOT/f).exists()
