"""
Tests for OdtExporter._add_footer() in exporters/odt_exporter.py

Tests cover:
- Footer appended to content
- Footer contains GitHub link
- Footer starts with separator
- Empty content input
- Content with trailing newlines
- Footer attribution text present
"""

import pytest

from local_deep_research.exporters.odt_exporter import ODTExporter


@pytest.fixture
def exporter():
    """Create a real ODTExporter — no __init__ args needed."""
    return ODTExporter()


class TestAddFooter:
    """Tests for _add_footer()."""

    def test_basic_append(self, exporter):
        """Footer is appended to markdown content."""
        result = exporter._add_footer("Hello world")
        assert result.startswith("Hello world")
        assert len(result) > len("Hello world")

    def test_footer_contains_github_link(self, exporter):
        """Footer includes the GitHub repository URL."""
        result = exporter._add_footer("Content")
        assert "github.com/LearningCircuit/local-deep-research" in result

    def test_footer_has_separator(self, exporter):
        """Footer includes a horizontal rule separator (---)."""
        result = exporter._add_footer("Content")
        footer_part = result[len("Content") :]
        assert "---" in footer_part

    def test_empty_content(self, exporter):
        """Empty content still gets a footer."""
        result = exporter._add_footer("")
        assert "---" in result
        assert "local-deep-research" in result

    def test_content_with_trailing_newlines(self, exporter):
        """Content with trailing newlines gets footer appended after them."""
        result = exporter._add_footer("Content\n\n")
        assert result.startswith("Content\n\n")
        assert "---" in result

    def test_footer_mentions_ldr(self, exporter):
        """Footer contains LDR or Local Deep Research attribution."""
        result = exporter._add_footer("Test")
        assert "Local Deep Research" in result
