Goon — self-hosted aggregator for adult-content scene metadata. Indexes scenes from TPDB, StashDB, and 30+ public adult tube sites. Cross-source deduplication via perceptual hash + Levenshtein distance. FastAPI backend + APScheduler worker + React Native (Expo) mobile client. FOSS, ad-free, donation-funded. See README for details.
28 lines
901 B
Python
28 lines
901 B
Python
"""Test idempotentności hashowania raw payloadu."""
|
|
from app.ingest import _canonical_json, _hash_raw
|
|
|
|
|
|
def test_hash_is_stable_across_key_order() -> None:
|
|
a = {"id": "x", "title": "T", "performers": [{"name": "Mia", "id": "1"}]}
|
|
b = {"performers": [{"id": "1", "name": "Mia"}], "title": "T", "id": "x"}
|
|
assert _hash_raw(a) == _hash_raw(b)
|
|
|
|
|
|
def test_hash_changes_when_value_changes() -> None:
|
|
a = {"id": "x", "title": "T"}
|
|
b = {"id": "x", "title": "Tt"}
|
|
assert _hash_raw(a) != _hash_raw(b)
|
|
|
|
|
|
def test_canonical_json_is_compact_and_sorted() -> None:
|
|
raw = _canonical_json({"b": 1, "a": 2})
|
|
assert raw == b'{"a":2,"b":1}'
|
|
|
|
|
|
def test_hash_handles_dates() -> None:
|
|
from datetime import date
|
|
|
|
a = {"d": date(2024, 1, 1)}
|
|
b = {"d": "2024-01-01"}
|
|
# default=str converts date to string identical to the literal version
|
|
assert _hash_raw(a) == _hash_raw(b)
|