Fix: Implement add() method in BaseFileKnowledgeSource to solve PDFKnowledgeSource instantiation error

Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
Devin AI
2025-04-16 12:05:39 +00:00
parent 409892d65f
commit 205e778d74
2 changed files with 26 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
from pathlib import Path
import pytest
from unittest.mock import patch
from crewai.knowledge.source.pdf_knowledge_source import PDFKnowledgeSource
@patch('crewai.knowledge.source.base_file_knowledge_source.BaseFileKnowledgeSource.validate_content')
@patch('crewai.knowledge.source.pdf_knowledge_source.PDFKnowledgeSource.load_content')
def test_pdf_knowledge_source_instantiation(mock_load_content, mock_validate_content, tmp_path):
"""Test that PDFKnowledgeSource can be instantiated without errors."""
mock_load_content.return_value = {}
pdf_path = tmp_path / "test.pdf"
pdf_path.touch() # Create the file
pdf_source = PDFKnowledgeSource(file_paths=[pdf_path])
assert isinstance(pdf_source, PDFKnowledgeSource)