"""TS-13 — property tests for the round-trip code paths (Hypothesis)."""

from __future__ import annotations

import json

from hypothesis import given, settings
from hypothesis import strategies as st

from mgf.test_supervisor import records as _records
from mgf.test_supervisor.tiers import parse_tier_range
from tests.unit._strategies import record_strategy


@given(rec=record_strategy())
@settings(max_examples=150)
def test_testrecord_jsonl_round_trips(rec) -> None:
    d = json.loads(rec.to_json())
    d["markers"] = tuple(d["markers"])
    assert _records.TestRecord(**d) == rec


@given(a=st.integers(0, 3), b=st.integers(0, 3))
@settings(max_examples=80)
def test_parse_tier_range_round_trips(a: int, b: int) -> None:
    lo, hi = sorted((a, b))
    assert parse_tier_range(f"{lo}-{hi}") == set(range(lo, hi + 1))
    assert parse_tier_range(str(a)) == {a}
