This commit is contained in:
@@ -10,8 +10,10 @@ from traderai.uex_client import UEXClient
|
||||
class FakeUEX:
|
||||
def __init__(self):
|
||||
self.posts = []
|
||||
self.get_calls = []
|
||||
|
||||
async def get(self, path, params=None, authenticated=False):
|
||||
self.get_calls.append({"path": path, "params": params, "authenticated": authenticated})
|
||||
if path == "commodities_prices_history":
|
||||
return {
|
||||
"status": "ok",
|
||||
@@ -80,6 +82,34 @@ class FakeUEX:
|
||||
},
|
||||
],
|
||||
}
|
||||
if path == "marketplace_trends":
|
||||
return {
|
||||
"status": "ok",
|
||||
"data": [
|
||||
{
|
||||
"id_item": 2791,
|
||||
"item_name": "\"Quantanium\" Water Bottle",
|
||||
"item_slug": "quantanium-water-bottle",
|
||||
"currency": "UEC",
|
||||
"price_avg_sell": "937500",
|
||||
"price_avg_month_sell": "1072222",
|
||||
"price_min_sell": "750000",
|
||||
"price_max_sell": "1200000",
|
||||
"listings_count_sell": 4,
|
||||
"price_avg_buy": "500000",
|
||||
"price_avg_month_buy": "525000",
|
||||
"price_min_buy": "450000",
|
||||
"price_max_buy": "550000",
|
||||
"listings_count_buy": 2,
|
||||
"total_listings_count": 6,
|
||||
"negotiations_count": 18,
|
||||
"negotiations_open": 7,
|
||||
"negotiations_success": 9,
|
||||
"link_prices": "https://uexcorp.space/marketplace/home/?id_item=2791&mode=list",
|
||||
"link_prices_history": "https://uexcorp.space/marketplace/averages/?id_item=2791&quality_tier=q0&unit=unit",
|
||||
}
|
||||
],
|
||||
}
|
||||
assert path == "marketplace_listings"
|
||||
return {
|
||||
"data": [
|
||||
@@ -259,6 +289,85 @@ class FakeCornerstone:
|
||||
}
|
||||
|
||||
|
||||
class FakeSCWiki:
|
||||
base_url = "https://starcitizen.tools"
|
||||
api_base_url = "https://api.star-citizen.wiki"
|
||||
|
||||
async def search_pages(self, query, limit=5):
|
||||
assert query == "Carrack"
|
||||
return [
|
||||
{
|
||||
"pageid": 415,
|
||||
"title": "Carrack",
|
||||
"description": "Deep-space multi-crew explorer manufactured by Anvil Aerospace",
|
||||
"extract": "The Anvil Carrack is a multi-crew explorer.",
|
||||
"thumbnail": "https://media.starcitizen.tools/carrack.webp",
|
||||
"url": "https://starcitizen.tools/Carrack",
|
||||
}
|
||||
][:limit]
|
||||
|
||||
async def get_page_summary(self, title=None, pageid=None, chars=700):
|
||||
assert title == "Carrack" or pageid == 415
|
||||
return {
|
||||
"pageid": 415,
|
||||
"title": "Carrack",
|
||||
"description": "Deep-space multi-crew explorer manufactured by Anvil Aerospace",
|
||||
"extract": "The Anvil Carrack is a multi-crew explorer.",
|
||||
"thumbnail": "https://media.starcitizen.tools/carrack.webp",
|
||||
"url": "https://starcitizen.tools/Carrack",
|
||||
}
|
||||
|
||||
async def search_verse(self, query):
|
||||
assert query == "Carrack"
|
||||
return [
|
||||
{
|
||||
"type": "vehicles",
|
||||
"label": "Vehicles",
|
||||
"results": [
|
||||
{
|
||||
"name": "Anvil Carrack",
|
||||
"class_name": "ANVL_Carrack",
|
||||
"extra_label": "Exploration",
|
||||
"web_url": "https://api.star-citizen.wiki/vehicles/anvl-carrack",
|
||||
"api_url": "https://api.star-citizen.wiki/api/vehicles/anvl-carrack",
|
||||
}
|
||||
],
|
||||
}
|
||||
]
|
||||
|
||||
async def get_vehicle(self, slug):
|
||||
assert slug == "anvl-carrack"
|
||||
return {
|
||||
"name": "Carrack",
|
||||
"game_name": "Anvil Carrack",
|
||||
"slug": "anvl-carrack",
|
||||
"manufacturer": {"name": "Anvil Aerospace"},
|
||||
"career": "Exploration",
|
||||
"role": "Expedition",
|
||||
"size_class": 5,
|
||||
"cargo_capacity": 456,
|
||||
"crew": {"min": 6, "max": 6},
|
||||
"msrp": 600,
|
||||
"pledge_url": "https://robertsspaceindustries.com/pledge/ships/carrack/Carrack",
|
||||
"uex_prices": {
|
||||
"purchase": [
|
||||
{
|
||||
"price_buy": 34398000,
|
||||
"terminal_name": "Astro Armada - Area 18",
|
||||
"starmap_location": {"name": "Area18", "parent_name": "ArcCorp", "star_system_name": "Stanton"},
|
||||
"game_version": "4.8.1-LIVE.11952564",
|
||||
"date_updated": "2026-05-20T18:39:37-04:00",
|
||||
"uex_link": "https://uexcorp.space/vehicles/home/list/in_game_sell/?id_terminal=148",
|
||||
}
|
||||
]
|
||||
},
|
||||
"description": {"en_EN": "The Anvil Carrack features reinforced fuel tanks for long-duration flight."},
|
||||
"web_url": "https://api.star-citizen.wiki/vehicles/anvl-carrack",
|
||||
"updated_at": "2026-06-08T00:34:00Z",
|
||||
"version": "4.8.1-LIVE.11952564",
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_search_marketplace_listings_filters_locally():
|
||||
registry = ToolRegistry(FakeUEX())
|
||||
@@ -333,6 +442,65 @@ async def test_uex_get_projects_and_limits_results():
|
||||
assert result["items"] == [{"id": 10, "commodity_name": "Gold", "price_buy": 4120}]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_uex_get_marketplace_listings_accepts_item_and_operation_filters():
|
||||
fake = FakeUEX()
|
||||
registry = ToolRegistry(fake)
|
||||
|
||||
result = await registry.execute(
|
||||
"get_uex_marketplace_listings",
|
||||
{
|
||||
"id_item": 2791,
|
||||
"operation": "sell",
|
||||
"fields": ["id", "slug", "operation"],
|
||||
},
|
||||
)
|
||||
|
||||
assert result["params"] == {"id_item": 2791, "operation": "sell"}
|
||||
assert fake.get_calls[-1]["path"] == "marketplace_listings"
|
||||
assert fake.get_calls[-1]["params"] == {"id_item": 2791, "operation": "sell"}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_marketplace_trends_returns_compact_wts_wtb_and_negotiation_metrics():
|
||||
fake = FakeUEX()
|
||||
registry = ToolRegistry(fake)
|
||||
|
||||
result = await registry.get_marketplace_trends(item_name="Quantanium", currency="UEC", quality_tier=0)
|
||||
|
||||
assert result["status"] == "ok"
|
||||
assert result["count"] == 1
|
||||
assert result["filters"] == {"item_name": "Quantanium", "currency": "UEC", "quality_tier": 0}
|
||||
assert fake.get_calls[-1]["path"] == "marketplace_trends"
|
||||
assert fake.get_calls[-1]["params"] == {"id_item": None, "item_name": "Quantanium", "item_slug": None, "id_category": None, "currency": "UEC", "quality_tier": 0}
|
||||
assert result["trends"][0] == {
|
||||
"id_item": 2791,
|
||||
"item_name": "\"Quantanium\" Water Bottle",
|
||||
"item_slug": "quantanium-water-bottle",
|
||||
"currency": "UEC",
|
||||
"sell": {
|
||||
"avg_price": "937500",
|
||||
"avg_price_month": "1072222",
|
||||
"min_price": "750000",
|
||||
"max_price": "1200000",
|
||||
"listings_count": 4,
|
||||
},
|
||||
"buy": {
|
||||
"avg_price": "500000",
|
||||
"avg_price_month": "525000",
|
||||
"min_price": "450000",
|
||||
"max_price": "550000",
|
||||
"listings_count": 2,
|
||||
},
|
||||
"total_listings_count": 6,
|
||||
"negotiations_count": 18,
|
||||
"negotiations_open": 7,
|
||||
"negotiations_success": 9,
|
||||
"link_prices": "https://uexcorp.space/marketplace/home/?id_item=2791&mode=list",
|
||||
"link_prices_history": "https://uexcorp.space/marketplace/averages/?id_item=2791&quality_tier=q0&unit=unit",
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_uex_api_catalog_exposes_resources_without_live_call():
|
||||
registry = ToolRegistry(FakeUEX())
|
||||
@@ -368,6 +536,7 @@ def test_schemas_expose_specific_uex_tools_instead_of_generic_api_tool():
|
||||
|
||||
assert "get_uex_commodities_prices" in names
|
||||
assert "get_uex_vehicles" in names
|
||||
assert "get_marketplace_trends" in names
|
||||
assert "draft_uex_marketplace_advertise" in names
|
||||
assert "delete_uex_marketplace_listings" in names
|
||||
assert "uex_get" not in names
|
||||
@@ -395,6 +564,17 @@ def test_schemas_expose_cornerstone_item_tools():
|
||||
assert "draft_marketplace_listing_with_cornerstone_image" in names
|
||||
|
||||
|
||||
def test_schemas_expose_scwiki_tools():
|
||||
registry = ToolRegistry(FakeUEX(), scwiki=FakeSCWiki())
|
||||
|
||||
names = {schema["function"]["name"] for schema in registry.schemas}
|
||||
|
||||
assert "search_scwiki_pages" in names
|
||||
assert "get_scwiki_page" in names
|
||||
assert "search_scwiki_vehicles" in names
|
||||
assert "get_scwiki_vehicle" in names
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_search_scmdb_missions_returns_reward_summary():
|
||||
registry = ToolRegistry(FakeUEX(), scmdb=FakeSCMDB())
|
||||
@@ -469,6 +649,43 @@ async def test_get_cornerstone_item_media_returns_absolute_image_urls():
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_search_scwiki_pages_returns_general_knowledge_matches():
|
||||
registry = ToolRegistry(FakeUEX(), scwiki=FakeSCWiki())
|
||||
|
||||
result = await registry.search_scwiki_pages(query="Carrack")
|
||||
|
||||
assert result["source"] == "https://starcitizen.tools"
|
||||
assert result["matched"] == 1
|
||||
assert result["pages"][0]["title"] == "Carrack"
|
||||
assert result["pages"][0]["url"] == "https://starcitizen.tools/Carrack"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_scwiki_vehicle_returns_ship_prices_and_store_context():
|
||||
registry = ToolRegistry(FakeUEX(), scwiki=FakeSCWiki())
|
||||
|
||||
result = await registry.get_scwiki_vehicle(query="Carrack")
|
||||
|
||||
assert result["source"] == "https://api.star-citizen.wiki"
|
||||
vehicle = result["vehicle"]
|
||||
assert vehicle["name"] == "Carrack"
|
||||
assert vehicle["manufacturer"] == "Anvil Aerospace"
|
||||
assert vehicle["msrp"] == 600
|
||||
assert vehicle["purchase_locations"] == [
|
||||
{
|
||||
"price_buy": 34398000,
|
||||
"terminal_name": "Astro Armada - Area 18",
|
||||
"location": "Area18",
|
||||
"parent_location": "ArcCorp",
|
||||
"star_system": "Stanton",
|
||||
"game_version": "4.8.1-LIVE.11952564",
|
||||
"date_updated": "2026-05-20T18:39:37-04:00",
|
||||
"uex_link": "https://uexcorp.space/vehicles/home/list/in_game_sell/?id_terminal=148",
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_draft_marketplace_listing_with_cornerstone_image_adds_image_data_and_redacts_display():
|
||||
registry = ToolRegistry(FakeUEX(), cornerstone=FakeCornerstone())
|
||||
|
||||
Reference in New Issue
Block a user