Skip to content

removed unlink of pdf files #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/arxiv_mcp_server/resources/papers.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ async def store_paper(self, paper_id: str, pdf_url: str) -> bool:
async with aiofiles.open(paper_md_path, "w", encoding="utf-8") as f:
await f.write(markdown)

paper_pdf_path.unlink() # Remove PDF after conversion
return True

except StopIteration:
Expand Down
1 change: 0 additions & 1 deletion src/arxiv_mcp_server/tools/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ def convert_pdf_to_markdown(paper_id: str, pdf_path: Path) -> None:
status.completed_at = datetime.now()

# Clean up PDF after successful conversion
pdf_path.unlink()
logger.info(f"Conversion completed for {paper_id}")

except Exception as e:
Expand Down
15 changes: 8 additions & 7 deletions tests/prompts/test_prompt_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,40 @@
import pytest
from arxiv_mcp_server.prompts.handlers import list_prompts, get_prompt


@pytest.mark.asyncio
async def test_server_list_prompts():
"""Test server list_prompts endpoint."""
prompts = await list_prompts()
assert len(prompts) == 1

# Check that all prompts have required fields
for prompt in prompts:
assert prompt.name
assert prompt.description
assert prompt.arguments is not None


@pytest.mark.asyncio
async def test_server_get_analysis_prompt():
"""Test server get_prompt endpoint with analysis prompt."""
result = await get_prompt(
"deep-paper-analysis",
{"paper_id": "2401.00123"}
)

result = await get_prompt("deep-paper-analysis", {"paper_id": "2401.00123"})

assert len(result.messages) == 1
message = result.messages[0]
assert message.role == "user"
assert "2401.00123" in message.content.text


@pytest.mark.asyncio
async def test_server_get_prompt_invalid_name():
"""Test server get_prompt endpoint with invalid prompt name."""
with pytest.raises(ValueError, match="Prompt not found"):
await get_prompt("invalid-prompt", {})


@pytest.mark.asyncio
async def test_server_get_prompt_missing_args():
"""Test server get_prompt endpoint with missing required arguments."""
with pytest.raises(ValueError, match="Missing required argument"):
await get_prompt("deep-paper-analysis", {})
await get_prompt("deep-paper-analysis", {})
18 changes: 10 additions & 8 deletions tests/prompts/test_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,49 @@
from arxiv_mcp_server.prompts.handlers import list_prompts, get_prompt
from mcp.types import GetPromptResult, PromptMessage, TextContent


@pytest.mark.asyncio
async def test_list_prompts():
"""Test listing available prompts."""
prompts = await list_prompts()
assert len(prompts) == 1

prompt_names = {p.name for p in prompts}
expected_names = {"deep-paper-analysis"}
assert prompt_names == expected_names


@pytest.mark.asyncio
async def test_get_paper_analysis_prompt():
"""Test getting paper analysis prompt."""
result = await get_prompt(
"deep-paper-analysis",
{"paper_id": "2401.00123"}
)

result = await get_prompt("deep-paper-analysis", {"paper_id": "2401.00123"})

assert isinstance(result, GetPromptResult)
assert len(result.messages) == 1
message = result.messages[0]

assert isinstance(message, PromptMessage)
assert message.role == "user"
assert isinstance(message.content, TextContent)
assert "2401.00123" in message.content.text


@pytest.mark.asyncio
async def test_get_prompt_with_invalid_name():
"""Test getting prompt with invalid name."""
with pytest.raises(ValueError, match="Prompt not found"):
await get_prompt("invalid-prompt", {})


@pytest.mark.asyncio
async def test_get_prompt_with_no_arguments():
"""Test getting prompt with no arguments."""
with pytest.raises(ValueError, match="No arguments provided"):
await get_prompt("deep-paper-analysis", None)


@pytest.mark.asyncio
async def test_get_prompt_with_missing_required_argument():
"""Test getting prompt with missing required argument."""
with pytest.raises(ValueError, match="Missing required argument"):
await get_prompt("deep-paper-analysis", {})
await get_prompt("deep-paper-analysis", {})