"""Tests for extraction prompt — lean prompt + directed contribution."""

from lib.extraction_prompt import build_extraction_prompt


class TestBuildExtractionPrompt:
    def test_undirected_prompt(self):
        prompt = build_extraction_prompt(
            "source.md", "source content", "internet-finance", "rio", "- claim1.md: claim one",
        )
        assert "rio" in prompt
        assert "internet-finance" in prompt
        assert "source content" in prompt
        assert "Contributor Directive" not in prompt

    def test_directed_prompt_with_rationale(self):
        prompt = build_extraction_prompt(
            "source.md", "source content", "internet-finance", "rio", "- claim1.md: claim one",
            rationale="I think futarchy fails in thin liquidity",
            intake_tier="directed",
            proposed_by="@naval",
        )
        assert "Contributor Directive" in prompt
        assert "I think futarchy fails in thin liquidity" in prompt
        assert "@naval" in prompt
        assert "contributor_thesis_extractable" in prompt
        assert "spotlight, not a filter" in prompt

    def test_challenge_directive(self):
        prompt = build_extraction_prompt(
            "source.md", "source content", "internet-finance", "rio", "- claim1.md: claim one",
            rationale="I disagree with your futarchy claim because this data shows manipulation is easy",
            intake_tier="challenge",
            proposed_by="challenger123",
        )
        assert "Contributor Directive" in prompt
        assert "disagree" in prompt
        assert "challenges" in prompt.lower()

    def test_empty_rationale_no_directive(self):
        prompt = build_extraction_prompt(
            "source.md", "source content", "health", "vida", "- claim1.md: claim one",
            rationale="",
        )
        assert "Contributor Directive" not in prompt

    def test_output_format_includes_thesis_field(self):
        prompt = build_extraction_prompt(
            "source.md", "content", "health", "vida", "index",
        )
        assert "contributor_thesis_extractable" in prompt

    def test_sourcer_field_in_output(self):
        prompt = build_extraction_prompt(
            "source.md", "content", "health", "vida", "index",
        )
        assert "sourcer" in prompt
