"""Tests for LangChain prompt templates."""
from __future__ import annotations


class TestCodeValidationPrompt:
    def test_renders_system_message(self) -> None:
        from claim_validator.chains.prompts.code_validation import CODE_VALIDATION_PROMPT
        messages = CODE_VALIDATION_PROMPT.format_messages(claim_data='{"diagnosis_codes": [{"code": "J06.9"}]}', history=[])
        assert len(messages) == 2
        assert messages[0].type == "system"
        assert "medical coding auditor" in messages[0].content
        assert "{format_instructions}" not in messages[0].content

    def test_renders_human_message(self) -> None:
        from claim_validator.chains.prompts.code_validation import CODE_VALIDATION_PROMPT
        messages = CODE_VALIDATION_PROMPT.format_messages(claim_data="test claim data", history=[])
        assert messages[1].type == "human"
        assert "test claim data" in messages[1].content


class TestPriorAuthPrompt:
    def test_renders(self) -> None:
        from claim_validator.chains.prompts.prior_auth import PRIOR_AUTH_PROMPT
        messages = PRIOR_AUTH_PROMPT.format_messages(claim_data="test", history=[])
        assert "prior authorization" in messages[0].content.lower()


class TestCoverageCheckPrompt:
    def test_renders(self) -> None:
        from claim_validator.chains.prompts.coverage_check import COVERAGE_CHECK_PROMPT
        messages = COVERAGE_CHECK_PROMPT.format_messages(claim_data="test", history=[])
        assert "coverage" in messages[0].content.lower()


class TestEligibilityInterpreterPrompt:
    def test_renders_with_correct_input_key(self) -> None:
        from claim_validator.chains.prompts.eligibility_interpreter import ELIGIBILITY_INTERPRETER_PROMPT
        messages = ELIGIBILITY_INTERPRETER_PROMPT.format_messages(eligibility_response="test response", history=[])
        assert "test response" in messages[1].content


class TestPAInterpreterPrompt:
    def test_renders_with_correct_input_key(self) -> None:
        from claim_validator.chains.prompts.pa_interpreter import PA_INTERPRETER_PROMPT
        messages = PA_INTERPRETER_PROMPT.format_messages(pa_response="test response", history=[])
        assert "test response" in messages[1].content


class TestRejectionSummaryPrompt:
    def test_renders(self) -> None:
        from claim_validator.chains.prompts.rejection_summary import REJECTION_SUMMARY_PROMPT
        messages = REJECTION_SUMMARY_PROMPT.format_messages(findings_text="- [ERROR] MISSING_NPI", history=[])
        assert "MISSING_NPI" in messages[1].content


class TestPreSubmissionPrompt:
    def test_renders(self) -> None:
        from claim_validator.chains.prompts.pre_submission import PRE_SUBMISSION_PROMPT
        messages = PRE_SUBMISSION_PROMPT.format_messages(workflow_status="Eligibility: PASSED", history=[])
        assert "Eligibility: PASSED" in messages[1].content
