fix: 移除_parser_方法中的source_type参数,并更新相关测试用例
This commit is contained in:
parent
8804c7446c
commit
78f2ae2a03
@ -83,7 +83,7 @@ async def _convert_upload_to_markdown(upload: UploadFile) -> ConversionResult:
|
||||
|
||||
try:
|
||||
file_size = await _write_upload_to_disk(upload, temp_path)
|
||||
markdown = await Parser.aparse(str(temp_path), source_type="file")
|
||||
markdown = await Parser.aparse(str(temp_path))
|
||||
markdown, truncated = _truncate_markdown(markdown)
|
||||
return ConversionResult(
|
||||
file_id=uuid.uuid4().hex,
|
||||
@ -94,7 +94,7 @@ async def _convert_upload_to_markdown(upload: UploadFile) -> ConversionResult:
|
||||
truncated=truncated,
|
||||
)
|
||||
except Exception as exc: # noqa: BLE001
|
||||
logger.error("Attachment conversion failed: %s", exc)
|
||||
logger.error(f"Attachment conversion failed: {exc}")
|
||||
raise
|
||||
|
||||
|
||||
|
||||
@ -123,8 +123,7 @@ async def test_convert_upload_to_markdown_returns_conversion_result(
|
||||
tmp_path,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
):
|
||||
async def _fake_aparse(source: str, params=None, source_type: str = "file") -> str:
|
||||
assert source_type == "file"
|
||||
async def _fake_aparse(source: str, params=None) -> str:
|
||||
return "converted markdown"
|
||||
|
||||
monkeypatch.setattr(svc, "_ensure_workdir", lambda: tmp_path)
|
||||
@ -147,8 +146,7 @@ async def test_convert_upload_to_markdown_truncates_content(
|
||||
tmp_path,
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
):
|
||||
async def _fake_aparse(source: str, params=None, source_type: str = "file") -> str:
|
||||
assert source_type == "file"
|
||||
async def _fake_aparse(source: str, params=None) -> str:
|
||||
return "x" * (svc.MAX_ATTACHMENT_MARKDOWN_CHARS + 200)
|
||||
|
||||
monkeypatch.setattr(svc, "_ensure_workdir", lambda: tmp_path)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user