Spaces:
Runtime error
Runtime error
Nikhil Pravin Pise
feat: production upgrade — agentic RAG, OpenSearch, Redis, Langfuse, Docker, Gradio, Telegram
1e732dd Download tests/test_pdf_parser.py from T0X1N/Agentic-RagBot: direct link, hf CLI and curl.
- Browser
- Download file 1.3 kB
-
https://huggingface.co/spaces/T0X1N/Agentic-RagBot/resolve/9699bea9d646520bb68c26ef02b87ec4bcedcfbf/tests/test_pdf_parser.py
- Command line
-
hf download hf://spaces/T0X1N/Agentic-RagBot@9699bea9d646520bb68c26ef02b87ec4bcedcfbf/tests/test_pdf_parser.py
-
curl -L -o test_pdf_parser.py https://huggingface.co/spaces/T0X1N/Agentic-RagBot/resolve/9699bea9d646520bb68c26ef02b87ec4bcedcfbf/tests/test_pdf_parser.py
1.3 kB
| """ | |
| Tests for src/services/pdf_parser/service.py — PDF parsing. | |
| """ | |
| from pathlib import Path | |
| import pytest | |
| from src.services.pdf_parser.service import PDFParserService, ParsedDocument | |
| def parser(): | |
| return PDFParserService() | |
| def test_missing_file(parser: PDFParserService): | |
| """Should return error for missing files.""" | |
| result = parser.parse(Path("/nonexistent/fake.pdf")) | |
| assert isinstance(result, ParsedDocument) | |
| assert result.error is not None | |
| assert "not found" in result.error.lower() | |
| def test_parse_directory_empty(parser: PDFParserService, tmp_path: Path): | |
| """Empty directory should return empty list.""" | |
| results = parser.parse_directory(tmp_path) | |
| assert results == [] | |
| def test_parse_directory_with_pdf(parser: PDFParserService, tmp_path: Path): | |
| """Should parse PDFs found in a directory.""" | |
| # Check if there are any real PDFs in data/medical_pdfs | |
| pdf_dir = Path("data/medical_pdfs") | |
| if pdf_dir.exists() and list(pdf_dir.glob("*.pdf")): | |
| results = parser.parse_directory(pdf_dir) | |
| assert len(results) > 0 | |
| for doc in results: | |
| assert isinstance(doc, ParsedDocument) | |
| assert doc.filename.endswith(".pdf") | |
| else: | |
| pytest.skip("No medical PDFs available for testing") | |