Add read-only corp tools: wallets, assets, mining observers, facilities, starbases — all corp-level (need corp roles). Closes #33 and completes the remaining corp items of #20. 100 tests, coverage 91%. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
3 files changed
+164
No files matched your search
@@ -0,0 +1,76 @@
|
||||
"""Corp economy & facilities tools (auth & ESI mocked)."""
|
||||
|
||||
import asyncio
|
||||
|
||||
import pytest
|
||||
|
||||
from conftest import route
|
||||
from familiar import auth, corp_economy
|
||||
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_corp_wallets(mock_esi, fake_auth):
|
||||
fixtures = {
|
||||
"/wallets/": [{"division": 1, "balance": 1000.0}],
|
||||
"/characters/": {"corporation_id": 2000},
|
||||
}
|
||||
mock_esi(lambda r: route(r, fixtures))
|
||||
res = asyncio.run(corp_economy.get_corp_wallets())
|
||||
entry = res["characters"][0]
|
||||
assert entry["corporation_id"] == 2000
|
||||
assert entry["wallets"][0]["balance"] == 1000.0
|
||||
|
||||
|
||||
def test_corp_assets_paginated(mock_esi, fake_auth):
|
||||
fixtures = {
|
||||
"/assets/": [{"item_id": 1}, {"item_id": 2}],
|
||||
"/characters/": {"corporation_id": 2000},
|
||||
}
|
||||
mock_esi(lambda r: route(r, fixtures))
|
||||
res = asyncio.run(corp_economy.get_corp_assets())
|
||||
assert res["characters"][0]["count"] == 2
|
||||
|
||||
|
||||
def test_corp_mining(mock_esi, fake_auth):
|
||||
fixtures = {
|
||||
"/mining/observers/": [{"observer_id": 5}],
|
||||
"/characters/": {"corporation_id": 2000},
|
||||
}
|
||||
mock_esi(lambda r: route(r, fixtures))
|
||||
res = asyncio.run(corp_economy.get_corp_mining())
|
||||
assert res["characters"][0]["count"] == 1
|
||||
|
||||
|
||||
def test_corp_facilities_and_starbases(mock_esi, fake_auth):
|
||||
fixtures = {
|
||||
"/facilities/": [{"facility_id": 1}],
|
||||
"/characters/": {"corporation_id": 2000},
|
||||
}
|
||||
mock_esi(lambda r: route(r, fixtures))
|
||||
res = asyncio.run(corp_economy.get_corp_facilities())
|
||||
assert res["characters"][0]["count"] == 1
|
||||
|
||||
|
||||
def test_corp_economy_tools_registered():
|
||||
tools = {t.name for t in asyncio.run(mcp.list_tools())}
|
||||
assert {
|
||||
"get_corp_wallets",
|
||||
"get_corp_assets",
|
||||
"get_corp_mining",
|
||||
"get_corp_facilities",
|
||||
"get_corp_starbases",
|
||||
} <= tools
|
||||
Reference in new issue
Block a user