docs: add setup guide and test coverage

This commit is contained in:
Hermes Agent
2026-08-02 17:08:56 +02:00
parent 974cbe6c68
commit 26431a4e26
6 changed files with 357 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
from __future__ import annotations
import httpx
import pytest
from openherbarium_mcp.gbif import GBIFClient
from openherbarium_mcp.http import BotanicalHTTPClient
@pytest.mark.asyncio
async def test_gbif_match_wraps_identity_with_evidence() -> None:
async def handler(request: httpx.Request) -> httpx.Response:
if request.url.path == "/v1/species/match":
return httpx.Response(
200,
json={
"usageKey": 1,
"acceptedUsageKey": 2,
"scientificName": "Calathea warscewiczii (L.Mathieu ex Planch.) Planch. & Linden",
"canonicalName": "Calathea warscewiczii",
"species": "Goeppertia warscewiczii",
"family": "Marantaceae",
"genus": "Goeppertia",
"rank": "SPECIES",
"status": "SYNONYM",
"confidence": 98,
},
)
if request.url.path in {"/v1/species/2/vernacularNames", "/v1/species/2/synonyms"}:
return httpx.Response(200, json={"results": []})
raise AssertionError(f"unexpected request path: {request.url.path}")
transport = httpx.MockTransport(handler)
async with BotanicalHTTPClient(transport=transport) as http:
result = await GBIFClient(http).match_plant("Calathea warscewiczii")
assert result["usage_key"] == 2
assert result["accepted_scientific_name"]["value"] == "Goeppertia warscewiczii"
assert result["accepted_scientific_name"]["source"] == "GBIF Backbone Taxonomy"
assert result["family"]["value"] == "Marantaceae"
assert result["external_ids"]["value"]["gbif_accepted_usage_key"] == 2