"""Tests para build_entity_schema_prompt."""

from build_entity_schema_prompt import build_entity_schema_prompt


def test_lista_con_varios_presets():
    presets = [
        {
            "type_ref": "osint_person_go_cybersecurity",
            "label": "Person",
            "metadata_fields": ["full_name", "alias", "nationality", "dob", "risk_score"],
        },
        {
            "type_ref": "osint_organization_go_cybersecurity",
            "label": "Organization",
            "metadata_fields": ["legal_name", "country", "sector", "founded", "risk_score"],
        },
    ]
    result = build_entity_schema_prompt(presets)
    assert "Entity types available for extraction:" in result
    assert "1. Person (type_ref: osint_person_go_cybersecurity)" in result
    assert "   Attributes: full_name, alias, nationality, dob, risk_score" in result
    assert "2. Organization (type_ref: osint_organization_go_cybersecurity)" in result
    assert "   Attributes: legal_name, country, sector, founded, risk_score" in result


def test_lista_vacia_retorna_string_vacio():
    result = build_entity_schema_prompt([])
    assert result == ""


def test_preset_sin_metadata_fields():
    presets = [
        {
            "type_ref": "osint_person_go_cybersecurity",
            "label": "Person",
        }
    ]
    result = build_entity_schema_prompt(presets)
    assert "1. Person (type_ref: osint_person_go_cybersecurity)" in result
    assert "Attributes:" not in result
