def test_source_attribution_context_formatting(self, mock_search_results):
        """Test context formatting with source attribution."""
        # Function to format context with source attribution
        def format_context_with_sources(search_results):
            context_items = []
            for result in search_results["chunk_search_results"]:
                source = result.get("metadata", {}).get("source", "Unknown source")
                title = result.get("metadata", {}).get("title", "Unknown title")

                context_items.append(f"From {source} ({title}):\n{result['text']}")

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

        # Format context
        context = format_context_with_sources(mock_search_results)

        # Check formatting
        assert "From source-0" in context
        assert "Document 0" in context
        assert "From source-1" in context
Test context formatting with source attribution.
py/tests/unit/retrieval/test_rag_processing.py