def test_citation_marker_context_formatting(self, mock_search_results):
        """Test context formatting with citation markers."""
        # Add citation IDs to search results
        for i, result in enumerate(mock_search_results["chunk_search_results"]):
            result["metadata"]["citation_id"] = f"cit{i}"

        # Function to format context with citation markers
        def format_context_with_citations(search_results):
            context_items = []
            for i, result in enumerate(search_results["chunk_search_results"]):
                citation_id = result.get("metadata", {}).get("citation_id")
                text = result["text"]

                if citation_id:
                    context_items.append(f"[{i+1}] {text} [{citation_id}]")
                else:
                    context_items.append(f"[{i+1}] {text}")

            return "\n\n".join(context_items)

        # Format context
        context = format_context_with_citations(mock_search_results)

        # Check formatting
        assert "[cit0]" in context
        assert "[cit1]" in context
        assert "[cit2]" in context
Test context formatting with citation markers.
py/tests/unit/retrieval/test_rag_processing.py