from src.seo.autofill import ALLOWED_TAGS, DEFAULT_TAG, _coerce, _system_prompt BASE = { "meta_title": "t", "meta_description": "d", "custom_excerpt": "e", "image_query": "q", "image_context": "c", } def test_coerce_es_drops_invented_tags(): obj = dict(BASE, tags=["uap", "humanoides", "Desclasificados", "investigacion-2"]) out = _coerce(obj, "es") assert out["tags"] == ["uap", "desclasificados"] def test_coerce_es_falls_back_to_default(): obj = dict(BASE, tags=["pentagono", "encuentros-cercanos"]) out = _coerce(obj, "es") assert out["tags"] == [DEFAULT_TAG["es"]] def test_coerce_en_still_constrained(): obj = dict(BASE, tags=["uap", "investigacion"]) out = _coerce(obj, "en") assert out["tags"] == ["uap"] def test_system_prompt_lists_allowed_tags_per_lang(): es = _system_prompt("es") en = _system_prompt("en") for tag in ALLOWED_TAGS["es"]: assert tag in es # La regla anti-legacy 'never use "investigacion"' es solo para EN: en ES # "investigacion" es el tag canĂ³nico del allow-list. assert 'never use "investigacion"' in en assert 'never use "investigacion"' not in es assert "ONLY from this exact list" in es