# retoor <retoor@molodetz.nl>

from devplacepy.services.jobs.deepsearch.phases import (
    PHASE_ANALYSIS,
    PHASE_CRAWLING,
    PHASE_INDEXING,
    PHASE_LABELS,
    PHASE_ORDER,
    PHASE_PLANNING,
    PHASE_SEARCHING,
    PHASE_SYNTHESIS,
    TOTAL_PHASES,
    phase_index,
)


def test_phase_order_is_full_pipeline_in_sequence():
    assert PHASE_ORDER == [
        PHASE_PLANNING,
        PHASE_SEARCHING,
        PHASE_CRAWLING,
        PHASE_INDEXING,
        PHASE_ANALYSIS,
        PHASE_SYNTHESIS,
    ]
    assert TOTAL_PHASES == len(PHASE_ORDER)


def test_phase_index_matches_position():
    assert phase_index(PHASE_PLANNING) == 0
    assert phase_index(PHASE_INDEXING) == 3
    assert phase_index(PHASE_SYNTHESIS) == TOTAL_PHASES - 1


def test_phase_index_unknown_falls_back_to_zero():
    assert phase_index("not-a-phase") == 0
    assert phase_index("") == 0


def test_every_phase_has_a_label():
    for phase in PHASE_ORDER:
        assert PHASE_LABELS.get(phase)
