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:
|
try:
|
||||||
file_size = await _write_upload_to_disk(upload, temp_path)
|
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)
|
markdown, truncated = _truncate_markdown(markdown)
|
||||||
return ConversionResult(
|
return ConversionResult(
|
||||||
file_id=uuid.uuid4().hex,
|
file_id=uuid.uuid4().hex,
|
||||||
@ -94,7 +94,7 @@ async def _convert_upload_to_markdown(upload: UploadFile) -> ConversionResult:
|
|||||||
truncated=truncated,
|
truncated=truncated,
|
||||||
)
|
)
|
||||||
except Exception as exc: # noqa: BLE001
|
except Exception as exc: # noqa: BLE001
|
||||||
logger.error("Attachment conversion failed: %s", exc)
|
logger.error(f"Attachment conversion failed: {exc}")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -123,8 +123,7 @@ async def test_convert_upload_to_markdown_returns_conversion_result(
|
|||||||
tmp_path,
|
tmp_path,
|
||||||
monkeypatch: pytest.MonkeyPatch,
|
monkeypatch: pytest.MonkeyPatch,
|
||||||
):
|
):
|
||||||
async def _fake_aparse(source: str, params=None, source_type: str = "file") -> str:
|
async def _fake_aparse(source: str, params=None) -> str:
|
||||||
assert source_type == "file"
|
|
||||||
return "converted markdown"
|
return "converted markdown"
|
||||||
|
|
||||||
monkeypatch.setattr(svc, "_ensure_workdir", lambda: tmp_path)
|
monkeypatch.setattr(svc, "_ensure_workdir", lambda: tmp_path)
|
||||||
@ -147,8 +146,7 @@ async def test_convert_upload_to_markdown_truncates_content(
|
|||||||
tmp_path,
|
tmp_path,
|
||||||
monkeypatch: pytest.MonkeyPatch,
|
monkeypatch: pytest.MonkeyPatch,
|
||||||
):
|
):
|
||||||
async def _fake_aparse(source: str, params=None, source_type: str = "file") -> str:
|
async def _fake_aparse(source: str, params=None) -> str:
|
||||||
assert source_type == "file"
|
|
||||||
return "x" * (svc.MAX_ATTACHMENT_MARKDOWN_CHARS + 200)
|
return "x" * (svc.MAX_ATTACHMENT_MARKDOWN_CHARS + 200)
|
||||||
|
|
||||||
monkeypatch.setattr(svc, "_ensure_workdir", lambda: tmp_path)
|
monkeypatch.setattr(svc, "_ensure_workdir", lambda: tmp_path)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user