"""Hypothesis strategies for mgf-test-supervisor property tests (TS-13)."""

from __future__ import annotations

from hypothesis import strategies as st

from mgf.test_supervisor import records as _records

_text = st.text(alphabet=st.characters(min_codepoint=32, max_codepoint=126), max_size=80)


@st.composite
def record_strategy(draw):
    """A Hypothesis strategy yielding valid TestRecord instances."""
    outcome = draw(st.sampled_from(sorted(_records.OUTCOMES)))
    return _records.TestRecord(
        test_id=draw(_text.filter(lambda s: s != "")),
        outcome=outcome,
        severity=_records.severity_for_outcome(outcome),
        duration_ms=draw(st.integers(min_value=0, max_value=10**7)),
        tier=draw(st.integers(min_value=0, max_value=5)),
        markers=tuple(draw(st.lists(_text, max_size=4))),
        code=draw(st.none() | _text),
        summary=draw(st.none() | _text),
        run_id=draw(_text),
    )
