import json

from src.types.motion_types import SimilarityNeighbor, to_json, from_json


def test_similarity_neighbor_json_roundtrip():
    neighbors = [
        SimilarityNeighbor(motion_id="m1", score=0.9),
        SimilarityNeighbor(motion_id="m2", score=0.75),
    ]

    # Serialize to JSON string
    json_str = to_json(neighbors)
    assert isinstance(json_str, str)

    # Ensure it's valid JSON
    parsed = json.loads(json_str)
    assert isinstance(parsed, list)

    # Deserialize back to objects
    recovered = from_json(json_str)
    assert recovered == neighbors
