feat: add smdb intergration
This commit is contained in:
@@ -121,6 +121,98 @@ class FakeUEX:
|
||||
return {"status": "ok", "posted": self.posts[-1]}
|
||||
|
||||
|
||||
class FakeSCMDB:
|
||||
base_url = "https://scmdb.test"
|
||||
|
||||
async def list_versions(self):
|
||||
return [
|
||||
{"version": "4.8.0-ptu.1", "file": "merged-4.8.0-ptu.1.json"},
|
||||
{"version": "4.7.2-live.1", "file": "merged-4.7.2-live.1.json"},
|
||||
]
|
||||
|
||||
async def get_data(self, version=None, channel="live"):
|
||||
return {
|
||||
"version": version or "4.7.2-live.1",
|
||||
"factions": {
|
||||
"fac-haul": {"name": "Covalex"},
|
||||
"fac-bounty": {"name": "Bounty Hunters Guild"},
|
||||
},
|
||||
"scopes": {
|
||||
"scope-rep": {"scopeName": "FactionReputation"},
|
||||
},
|
||||
"factionRewardsPools": [
|
||||
[{"factionGuid": "fac-haul", "scopeGuid": "scope-rep", "amount": 125}],
|
||||
[{"factionGuid": "fac-bounty", "scopeGuid": "scope-rep", "amount": 250}],
|
||||
],
|
||||
"partialRewardPayoutPools": [
|
||||
[],
|
||||
[{"minPercentage": 50, "maxPercentage": 99, "currencyRewardMultiplier": 0.75, "reputationMultipliers": None}],
|
||||
],
|
||||
"resourcePools": {
|
||||
"res-tungsten": {"name": "Tungsten"},
|
||||
},
|
||||
"blueprintPools": {
|
||||
"bp-pool": {
|
||||
"name": "Ship Salvage Rewards",
|
||||
"blueprints": [{"name": "Abrade Scraper Module"}],
|
||||
},
|
||||
},
|
||||
"locationPools": {
|
||||
"loc-a18": {"name": "Area18"},
|
||||
"loc-baijini": {"name": "Baijini Point"},
|
||||
},
|
||||
"contracts": [
|
||||
{
|
||||
"id": "mission-haul",
|
||||
"debugName": "Haul_Tungsten_Test",
|
||||
"title": "Move Tungsten",
|
||||
"description": "Move Tungsten to Baijini Point.",
|
||||
"missionType": "Hauling",
|
||||
"category": "career",
|
||||
"factionGuid": "fac-haul",
|
||||
"rewardUEC": 50250,
|
||||
"factionRewardsIndex": 0,
|
||||
"partialRewardPayoutIndex": 1,
|
||||
"haulingOrders": [{"resource": "res-tungsten", "minSCU": 6, "maxSCU": 6, "maxContainerSize": 1}],
|
||||
"locations": ["loc-a18"],
|
||||
"destinations": ["loc-baijini"],
|
||||
"systems": ["Stanton"],
|
||||
"illegal": False,
|
||||
"canBeShared": False,
|
||||
},
|
||||
{
|
||||
"id": "mission-bounty",
|
||||
"debugName": "Bounty_Blueprint_Test",
|
||||
"title": "Ambush Op",
|
||||
"description": "Clean out targets.",
|
||||
"missionType": "Bounty Hunter",
|
||||
"factionGuid": "fac-bounty",
|
||||
"rewardUEC": 120000,
|
||||
"factionRewardsIndex": 1,
|
||||
"partialRewardPayoutIndex": 0,
|
||||
"itemRewards": [{"name": "Council Scrip", "amount": 5}],
|
||||
"blueprintRewards": [{"blueprintPool": "bp-pool", "chance": 1, "trigger": "complete"}],
|
||||
"systems": ["Pyro"],
|
||||
"illegal": True,
|
||||
"canBeShared": True,
|
||||
},
|
||||
],
|
||||
"legacyContracts": [
|
||||
{
|
||||
"id": "legacy-delivery",
|
||||
"debugName": "Legacy_Delivery_Test",
|
||||
"title": "Old Box Run",
|
||||
"missionType": "Delivery",
|
||||
"factionGuid": "fac-haul",
|
||||
"rewardUEC": 1000,
|
||||
"factionRewardsIndex": 0,
|
||||
"partialRewardPayoutIndex": 0,
|
||||
"systems": ["Stanton"],
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_search_marketplace_listings_filters_locally():
|
||||
registry = ToolRegistry(FakeUEX())
|
||||
@@ -236,6 +328,46 @@ def test_schemas_expose_specific_uex_tools_instead_of_generic_api_tool():
|
||||
assert "uex_draft_post" not in names
|
||||
|
||||
|
||||
def test_schemas_expose_scmdb_mission_tools():
|
||||
registry = ToolRegistry(FakeUEX(), scmdb=FakeSCMDB())
|
||||
|
||||
names = {schema["function"]["name"] for schema in registry.schemas}
|
||||
|
||||
assert "list_scmdb_versions" in names
|
||||
assert "search_scmdb_missions" in names
|
||||
assert "get_scmdb_mission_rewards" in names
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_search_scmdb_missions_returns_reward_summary():
|
||||
registry = ToolRegistry(FakeUEX(), scmdb=FakeSCMDB())
|
||||
|
||||
result = await registry.search_scmdb_missions(query="tungsten", mission_type="hauling")
|
||||
|
||||
assert result["version"] == "4.7.2-live.1"
|
||||
assert result["matched"] == 1
|
||||
mission = result["missions"][0]
|
||||
assert mission["title"] == "Move Tungsten"
|
||||
assert mission["rewards"]["uec"] == 50250
|
||||
assert mission["rewards"]["reputation"] == [{"faction": "Covalex", "scope": "FactionReputation", "amount": 125}]
|
||||
assert mission["rewards"]["hauling"] == [
|
||||
{"resource": "Tungsten", "min_scu": 6, "max_scu": 6, "max_container_size_scu": 1}
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_scmdb_mission_rewards_enriches_items_blueprints_and_locations():
|
||||
registry = ToolRegistry(FakeUEX(), scmdb=FakeSCMDB())
|
||||
|
||||
result = await registry.get_scmdb_mission_rewards(debug_name="Bounty_Blueprint_Test")
|
||||
|
||||
mission = result["mission"]
|
||||
assert mission["title"] == "Ambush Op"
|
||||
assert mission["faction"] == "Bounty Hunters Guild"
|
||||
assert mission["rewards"]["items"] == [{"name": "Council Scrip", "amount": 5}]
|
||||
assert mission["rewards"]["blueprints"][0]["blueprints"] == ["Abrade Scraper Module"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_search_uex_api_index_finds_history_tools():
|
||||
registry = ToolRegistry(FakeUEX())
|
||||
|
||||
Reference in New Issue
Block a user