Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -6,11 +6,12 @@ from loguru import logger
|
||||
import sys
|
||||
import os
|
||||
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
|
||||
PROJECT_ROOT = os.path.dirname(os.path.dirname(__file__))
|
||||
sys.path.insert(0, os.path.join(PROJECT_ROOT, "backend"))
|
||||
|
||||
from src.services.parser.pdf_parser import PDFParser, parse_pdf_to_markdown
|
||||
from src.services.parser.docx_parser import DocxParser, parse_docx_to_markdown
|
||||
from src.services.parser.mineru_parser import MinerUParser, ParserOrchestrator
|
||||
from app.services.parser.pdf_parser import PDFParser, parse_pdf_to_markdown
|
||||
from app.services.parser.docx_parser import DocxParser, parse_docx_to_markdown
|
||||
from app.services.parser.mineru_parser import MinerUParser, ParserOrchestrator
|
||||
|
||||
|
||||
class TestPDFParser:
|
||||
@@ -60,14 +61,14 @@ class TestChunker:
|
||||
|
||||
def test_chunker_initialization(self):
|
||||
"""测试分块器初始化"""
|
||||
from src.services.embedding.text_chunker import RegulationChunker
|
||||
from app.services.embedding.text_chunker import RegulationChunker
|
||||
|
||||
chunker = RegulationChunker(chunk_size=512)
|
||||
assert chunker is not None
|
||||
|
||||
def test_chunk_sample_text(self):
|
||||
"""测试分块示例文本"""
|
||||
from src.services.embedding.text_chunker import RegulationChunker
|
||||
from app.services.embedding.text_chunker import RegulationChunker
|
||||
|
||||
sample_text = """
|
||||
# 测试法规文档
|
||||
@@ -106,7 +107,7 @@ class TestFullPipeline:
|
||||
|
||||
def test_pipeline_without_files(self):
|
||||
"""测试流程初始化(无文件)"""
|
||||
from src.services.document_processor import DocumentProcessor
|
||||
from app.services.document_processor import DocumentProcessor
|
||||
|
||||
processor = DocumentProcessor()
|
||||
assert processor is not None
|
||||
@@ -115,4 +116,4 @@ class TestFullPipeline:
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main([__file__, "-v"])
|
||||
pytest.main([__file__, "-v"])
|
||||
|
||||
Reference in New Issue
Block a user