Files
character-mcp/tests/test_wiki_fetch.py
Aodhan Collins d4d6788d26 Add 13 new Fandom wiki sources and integration tests
Expand franchise wiki mappings to cover Uma Musume, Fire Emblem,
Senran Kagura, Vocaloid, Dragon Ball, League of Legends, Street Fighter,
Sonic, Spy x Family, Zelda, The Witcher, Metroid, and Pokemon. Also
expand Final Fantasy aliases to cover all numbered titles I–XVI with
both arabic and roman numeral variants.

Adds parametrized integration tests that verify each wiki endpoint
returns valid CharacterData with a description and Fandom source URL.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-19 21:41:53 +00:00

52 lines
1.8 KiB
Python

"""
Integration tests — hit each Fandom wiki endpoint and verify we get
meaningful character data back.
These tests make real HTTP requests, so they require network access.
"""
import pytest
import pytest_asyncio
from character_details.fetcher import fetch_character
from character_details.models import CharacterData
CHARACTERS = [
("Tifa Lockhart", "Final Fantasy VII"),
("Y'shtola Rhul", "Final Fantasy XIV"),
("Princess Peach", "Super Mario"),
("Sucy Manbavaran", "Little Witch Academia"),
("Rice Shower", "Uma Musume"),
("Camilla", "Fire Emblem"),
("Shiki", "Senran Kagura"),
("Hatsune Miku", "Vocaloid"),
("Android 18", "Dragon Ball"),
("Jinx", "League of Legends"),
("Chun-Li", "Street Fighter"),
("Rouge the Bat", "Sonic"),
("Yor Briar", "Spy x Family"),
("Princess Zelda", "The Legend of Zelda"),
("Ciri", "The Witcher"),
("Zero Suit Samus", "Metroid"),
("Nessa", "Pokemon"),
]
@pytest.mark.asyncio
@pytest.mark.parametrize("name,franchise", CHARACTERS, ids=[f"{n} ({f})" for n, f in CHARACTERS])
async def test_fetch_character(name: str, franchise: str):
"""Each wiki should return a CharacterData with at least a name, franchise, description, and source URL."""
result = await fetch_character(name, franchise)
assert isinstance(result, CharacterData)
assert result.name == name
assert result.franchise == franchise
assert result.description, f"No description returned for {name} ({franchise})"
assert len(result.sources) >= 1, f"No sources returned for {name} ({franchise})"
# At least one source should be a Fandom URL (not just Wikipedia)
fandom_sources = [s for s in result.sources if "fandom.com" in s]
assert fandom_sources, (
f"No Fandom source for {name} ({franchise}) — got: {result.sources}"
)