Add read-only tools: faction-warfare stats (char + corp), freelance jobs (char + corp), corp projects, character activities, and access lists. FW endpoints are stable; the newer projects/freelance/activities/access paths are best-effort and flagged for live confirmation. Closes #34, #35, #36. 106 tests, coverage 91%. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
70 lines
2.1 KiB
Python
70 lines
2.1 KiB
Python
"""Remaining read tools: FW, projects, freelance, activities, access."""
|
|
|
|
import asyncio
|
|
|
|
import pytest
|
|
|
|
from conftest import route
|
|
from familiar import auth, misc
|
|
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_fw_stats(mock_esi, fake_auth):
|
|
mock_esi(lambda r: route(r, {"/fw/stats/": {"kills": {"total": 10}}}))
|
|
res = asyncio.run(misc.get_fw_stats())
|
|
assert res["characters"][0]["stats"]["kills"]["total"] == 10
|
|
|
|
|
|
def test_corp_fw_stats(mock_esi, fake_auth):
|
|
fixtures = {"/fw/stats/": {"pilots": 5}, "/characters/": {"corporation_id": 2000}}
|
|
mock_esi(lambda r: route(r, fixtures))
|
|
res = asyncio.run(misc.get_corp_fw_stats())
|
|
assert res["characters"][0]["corporation_id"] == 2000
|
|
assert res["characters"][0]["stats"]["pilots"] == 5
|
|
|
|
|
|
def test_freelance_jobs(mock_esi, fake_auth):
|
|
mock_esi(lambda r: route(r, {"/freelance/jobs/": [{"job_id": 1}]}))
|
|
res = asyncio.run(misc.get_freelance_jobs())
|
|
assert res["characters"][0]["count"] == 1
|
|
|
|
|
|
def test_corp_projects(mock_esi, fake_auth):
|
|
fixtures = {"/projects/": [{"id": 1}, {"id": 2}], "/characters/": {"corporation_id": 2000}}
|
|
mock_esi(lambda r: route(r, fixtures))
|
|
res = asyncio.run(misc.get_corp_projects())
|
|
assert res["characters"][0]["count"] == 2
|
|
|
|
|
|
def test_access_lists(mock_esi, fake_auth):
|
|
mock_esi(lambda r: route(r, {"/access/": {"lists": [1, 2]}}))
|
|
res = asyncio.run(misc.get_access_lists())
|
|
assert res["characters"][0]["access"]["lists"] == [1, 2]
|
|
|
|
|
|
def test_misc_tools_registered():
|
|
tools = {t.name for t in asyncio.run(mcp.list_tools())}
|
|
assert {
|
|
"get_fw_stats",
|
|
"get_corp_fw_stats",
|
|
"get_freelance_jobs",
|
|
"get_corp_freelance_jobs",
|
|
"get_corp_projects",
|
|
"get_activities",
|
|
"get_access_lists",
|
|
} <= tools
|