Yuan1z0825/nature-skills / skills/nature-academic-search
nature-academic-search
FlaggedSearch literature across sources, verify or manage citations, and build MeSH strategies or citation-impact audits. Use for 文献检索、引文核对、参考文献管理、严格他引 and evidence-backed citer profiles; not for translating a paper or drafting manuscript prose.
mcp-server/tests/test_citation_errors.py
View on GitHub"""Error and missing-data handling for citation output (no network access)."""
from __future__ import annotations
import json
from unittest.mock import MagicMock, patch
import pytest
from utils.errors import DataSourceError
def _crossref_config():
cfg = MagicMock()
cfg.crossref_mailto = "test@example.com"
cfg.crossref_timeout = 10
return cfg
@patch("sources.crossref.get_config")
@patch("sources.crossref.requests.get")
def test_crossref_404_raises_instead_of_returning_a_fake_citation(mock_get, mock_config):
mock_config.return_value = _crossref_config()
mock_get.return_value = MagicMock(status_code=404)
from sources.crossref import CrossRefSource
with pytest.raises(DataSourceError, match="10.9999/nope"):
CrossRefSource().get_citation("10.9999/nope", style="apa")
@patch("academic_search_server._crossref")
def test_get_citation_tool_reports_an_error_for_an_unknown_doi(mock_crossref):
mock_crossref.get_citation.side_effect = DataSourceError("crossref", "No citation found for DOI 10.9999/nope")
import academic_search_server
payload = json.loads(academic_search_server.get_citation("10.9999/nope", id_type="doi"))
assert "citation" not in payload
assert "error" in json.dumps(payload).lower()
def test_basic_citation_uses_nd_when_year_is_none():
import academic_search_server
paper = {"authors": ["Smith J"], "title": "T", "year": None, "journal": None, "doi": None, "pmid": "123"}
for style in ("apa", "vancouver", "ieee", "nature"):
citation = academic_search_server._format_basic_citation(paper, style)
assert "None" not in citation, (style, citation)
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |