from rights_filter.admin.knowledge_base_handlers import register_manual_entry
from rights_filter.domain.records import (
    InMemoryRightsFilterRepository,
    KnowledgeEntryType,
    KnowledgeProvenance,
)


def test_operator_can_register_manual_celebrity_entry():
    repo = InMemoryRightsFilterRepository()

    entry = register_manual_entry(
        repo,
        entry_type=KnowledgeEntryType.CELEBRITY,
        name="IU",
        aliases=["Lee Ji-eun"],
        related_keywords=["album cover"],
        policy_memo="Reject unless rights evidence is supplied.",
        sample_fingerprints=["phash:iu"],
    )

    assert entry.provenance == KnowledgeProvenance.MANUAL
    assert entry.aliases == ["Lee Ji-eun"]
    assert repo.active_knowledge_entries() == [entry]


def test_manual_entry_rejects_biometric_template_payload():
    repo = InMemoryRightsFilterRepository()

    try:
        register_manual_entry(
            repo,
            entry_type=KnowledgeEntryType.CELEBRITY,
            name="IU",
            biometric_template=[0.1, 0.2],
        )
    except ValueError as error:
        assert "biometric template" in str(error)
    else:
        raise AssertionError("expected biometric template rejection")
