"""Rendering review uses synthetic notes and never accepts private corpus fidelity."""
import hashlib
import json
import os
import subprocess
import sys
from pathlib import Path
from coulomb_social.apps.spaces.content import render_markdown
from coulomb_social.apps.spaces.rendering_audit import audit_body, review_card
def test_audit_uses_product_renderer_and_reports_custom_tags_attributes_and_schemes():
body = ('# Synthetic\n\nPlaceholder
Text\n'
'
'
'Unsafe')
audit, rendered = audit_body(body)
assert rendered == render_markdown(body)
assert audit["sanitization_changed_html"]
assert audit["markup_changed_by_sanitization"]
assert not audit["serialization_only_change"]
assert audit["removed_tag_counts"] == {"topic": 1}
assert {a["attribute"] for a in audit["removed_attributes"]} == {"onerror", "href"}
assert "assets/picture.png" in rendered and "
" in rendered
assert audit["body_sha256"] == hashlib.sha256(body.encode()).hexdigest()
assert not audit["original_bubble_render_compared"]
assert not audit["productive_fidelity_accepted"]
def test_serialized_line_break_difference_is_not_reported_as_lost_markup():
audit, _ = audit_body("First
Second")
assert audit["serialization_only_change"]
assert not audit["markup_changed_by_sanitization"]
assert not audit["visible_text_changed_by_sanitization"]
def test_review_card_escapes_source_and_blocks_resources_and_interaction():
body = '
'
audit, rendered = audit_body(body)
card = review_card("", body, rendered, audit,
source_id='a/"?b').decode()
assert "