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
+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"