from __future__ import annotations

from django_anyllm.prompts import build_system_prompt
from django_anyllm.registry import ModelRegistry

from .models import Author


class TestBuildSystemPrompt:
    """Tests for build_system_prompt."""

    def test_includes_default_instructions(self):
        reg = ModelRegistry()
        prompt = build_system_prompt(reg)
        assert "Use the provided tools" in prompt

    def test_lists_registered_models(self):
        reg = ModelRegistry()
        reg.register(Author)
        prompt = build_system_prompt(reg)
        assert "tests.author" in prompt
        assert "A writer of books." in prompt

    def test_includes_permissions(self):
        reg = ModelRegistry()
        reg.register(Author, permissions={"read"})
        prompt = build_system_prompt(reg)
        assert "permissions: read" in prompt

    def test_extra_instructions(self):
        reg = ModelRegistry()
        prompt = build_system_prompt(reg, extra_instructions="Be concise.")
        assert "Be concise." in prompt
