from fmatch.saas.operators.classify_revenue_band import classify_revenue_band


def test_classify_revenue_band_uses_suffix_aware_employee_parser():
    result = classify_revenue_band({"employees": "10K"})
    assert result["source"] == "employee_estimate"
    assert result["code"] == "fortune_500"
    assert result["revenue_estimate"] == 2_000_000_000
    assert result["revenue_per_employee"] == 200000


def test_classify_revenue_band_infers_shared_suffix_for_employee_ranges():
    result = classify_revenue_band({"employees": "10-50K"})
    assert result["source"] == "employee_estimate"
    assert result["code"] == "fortune_500"
    assert result["revenue_per_employee"] == 66666


def test_classify_revenue_band_treats_employee_like_raw_string_as_headcount():
    result = classify_revenue_band("100-250 employees")
    assert result["source"] == "employee_estimate"
    assert result["code"] == "mid_market"
    assert result["revenue_estimate"] == 20_000_000


def test_classify_revenue_band_reports_ambiguous_employee_ranges():
    result = classify_revenue_band({"employees": "10K-1M"})
    assert result["value"] is None
    assert result["code"] == "unknown"
    assert result["reason"] == "ambiguous_employee_count"
