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
+12
View File
@@ -0,0 +1,12 @@
from __future__ import annotations
from openherbarium_mcp import __version__
from openherbarium_mcp.server import mcp
def test_package_version() -> None:
assert __version__ == "0.1.0"
def test_fastmcp_server_exists() -> None:
assert mcp.name == "OpenHerbarium MCP"
+45
View File
@@ -0,0 +1,45 @@
from __future__ import annotations
import httpx
import pytest
from openherbarium_mcp.http import BotanicalHTTPClient
from openherbarium_mcp.wikimedia import WikimediaClient
@pytest.mark.asyncio
async def test_wikimedia_image_sources_include_license_author_and_url() -> None:
async def handler(request: httpx.Request) -> httpx.Response:
assert request.url.path == "/w/api.php"
return httpx.Response(
200,
json={
"query": {
"pages": {
"123": {
"pageid": 123,
"title": "File:Plant.jpg",
"imageinfo": [
{
"url": "https://upload.wikimedia.org/Plant.jpg",
"descriptionurl": "https://commons.wikimedia.org/wiki/File:Plant.jpg",
"user": "Example author",
"extmetadata": {
"LicenseShortName": {"value": "CC BY-SA 4.0"},
"Artist": {"value": "Example artist"},
},
}
],
}
}
}
},
)
transport = httpx.MockTransport(handler)
async with BotanicalHTTPClient(transport=transport) as http:
records = await WikimediaClient(http).image_sources("Goeppertia warscewiczii")
assert records[0]["image_url"]["value"].endswith("Plant.jpg")
assert records[0]["license"]["value"] == "CC BY-SA 4.0"
assert records[0]["author"]["value"] == "Example artist"