import pandas as pd
from src.fmatch.saas.services.engine_client import EngineClient


def test_progressive_annotation_tags_stage():
    ec = EngineClient()
    df = pd.DataFrame([
        {
            'score': 0.92,
            'field_score_details': [{'algorithm': 'Exact', 'field': 'Email', 'score_contrib': 0.92}],
        },
        {
            'score': 0.76,
            'field_score_details': [{'algorithm': 'WRatio', 'field': 'Name', 'score_contrib': 0.76}],
        },
    ])
    out = ec._annotate_progressive_details(df, threshold=0.7)
    assert 'stage_hit' in out.columns
    assert out.loc[0, 'stage_hit'] in ('exact_keys', 'name_normalized_exact')
    assert out.loc[1, 'stage_hit'] in ('fuzzy_a', 'fuzzy_b')

