Phase 4: planetary interaction reads (#29)
Add read-only PI tools: get_planets (colonies), get_planet_layout (pins/links/routes), get_corp_customs_offices. ESI exposes no PI write endpoint despite the manage_planets scope name, so these are reads. Closes #29. 132 tests, coverage 90%, 84 tools. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
3 files changed
+119
No files matched your search
@@ -0,0 +1,53 @@
|
||||
"""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
|
||||
Reference in new issue
Block a user