"""Planetary interaction read tools.""" import asyncio import pytest from conftest import route from familiar import auth, planets from familiar.server import mcp CHARS = [{"character_id": 99, "character_name": "Alpha", "scopes": []}] @pytest.fixture def fake_auth(monkeypatch): monkeypatch.setattr(auth, "list_characters", lambda: list(CHARS)) async def get_auth(cid, **kw): return f"token-{cid}", cid monkeypatch.setattr(auth, "get_auth", get_auth) monkeypatch.setattr(auth, "resolve_character", lambda i: 99) return CHARS def test_get_planets(mock_esi, fake_auth): cols = [{"planet_id": 40000001, "planet_type": "barren", "upgrade_level": 3}] mock_esi(lambda r: route(r, {"/planets/": cols})) res = asyncio.run(planets.get_planets()) assert res["characters"][0]["count"] == 1 def test_get_planet_layout(mock_esi, fake_auth): layout = {"pins": [{}, {}], "links": [{}], "routes": [{}, {}, {}]} mock_esi(lambda r: route(r, {"/planets/40000001/": layout})) res = asyncio.run(planets.get_planet_layout(99, 40000001)) assert res["pins"] == 2 assert res["routes"] == 3 def test_corp_customs_offices(mock_esi, fake_auth): fixtures = { "/customs_offices/": [{"office_id": 1}], "/characters/": {"corporation_id": 2000}, } mock_esi(lambda r: route(r, fixtures)) res = asyncio.run(planets.get_corp_customs_offices()) assert res["characters"][0]["count"] == 1 def test_planets_tools_registered(): tools = {t.name for t in asyncio.run(mcp.list_tools())} assert {"get_planets", "get_planet_layout", "get_corp_customs_offices"} <= tools