"""Sanity: normalize_scene propaguje fingerprints i cross_source_refs (M3)."""
from __future__ import annotations

import json
from pathlib import Path

import pytest

from app.connectors.stashdb import _parse_scene as parse_stashdb
from app.normalize.scenes import normalize_scene


@pytest.fixture
def stashdb_raw() -> dict:
    return json.loads(
        (Path(__file__).parent / "fixtures" / "stashdb_scene.json").read_text()
    )


def test_normalize_carries_fingerprints(stashdb_raw: dict) -> None:
    raw = parse_stashdb(stashdb_raw)
    assert raw is not None
    norm = normalize_scene(raw)
    kinds = {kind for kind, _ in norm.fingerprints}
    assert kinds == {"phash", "oshash"}


def test_normalize_carries_cross_source_refs(stashdb_raw: dict) -> None:
    raw = parse_stashdb(stashdb_raw)
    assert raw is not None
    norm = normalize_scene(raw)
    assert norm.cross_source_refs == {"tpdb": "11111111-1111-4111-8111-111111111111"}
