async def test_document_embedding_generation(mock_document_handler, sample_document):
    """Test embedding generation for document chunks."""
    from core.main.services.documents import DocumentProcessingService

    # Setup mock embedding provider
    mock_embedding_provider = AsyncMock()
    mock_embedding_provider.async_get_embedding = AsyncMock(
        return_value=[0.1, 0.2, 0.3, 0.4]
    )

    # Setup document processing service
    service = DocumentProcessingService(
        document_handler=mock_document_handler,
        embedding_provider=mock_embedding_provider
    )

    # Process document with embedding generation
    processed_doc = await service.process_document(
        sample_document,
        generate_embeddings=True
    )

    # Verify embedding provider was called for each chunk
    assert mock_embedding_provider.async_get_embedding.call_count == len(sample_document.chunks)

    # Check that embeddings were stored with chunks
    for chunk in processed_doc.chunks:
        assert hasattr(chunk, "embedding")
        assert chunk.embedding == [0.1, 0.2, 0.3, 0.4]
Test embedding generation for document chunks.
py/tests/unit/document/test_document_processing.py