ux: LBC Styling, feat: thinking, feat: more tools:
This commit is contained in:
@@ -8,6 +8,28 @@ from traderai.uex_client import UEXClient
|
||||
|
||||
class FakeUEX:
|
||||
async def get(self, path, params=None, authenticated=False):
|
||||
if path == "commodities_prices":
|
||||
return {
|
||||
"status": "ok",
|
||||
"data": [
|
||||
{
|
||||
"id": 10,
|
||||
"commodity_name": "Gold",
|
||||
"terminal_name": "Port Tressler",
|
||||
"price_buy": 4120,
|
||||
"price_sell": 5020,
|
||||
"scu_buy": 1200,
|
||||
"verbose_note": "x" * 300,
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"commodity_name": "Beryl",
|
||||
"terminal_name": "Area18",
|
||||
"price_buy": 2500,
|
||||
"price_sell": 3100,
|
||||
},
|
||||
],
|
||||
}
|
||||
assert path == "marketplace_listings"
|
||||
return {
|
||||
"data": [
|
||||
@@ -42,6 +64,9 @@ class FakeUEX:
|
||||
]
|
||||
}
|
||||
|
||||
async def delete(self, path, params=None, authenticated=True):
|
||||
return {"status": "ok", "deleted": {"path": path, "params": params, "authenticated": authenticated}}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_search_marketplace_listings_filters_locally():
|
||||
@@ -83,6 +108,68 @@ def test_uex_client_uses_bearer_and_secret_headers():
|
||||
assert headers["Authorization"] == "Bearer bearer"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_uex_get_projects_and_limits_results():
|
||||
registry = ToolRegistry(FakeUEX())
|
||||
|
||||
result = await registry.execute(
|
||||
"get_uex_commodities_prices",
|
||||
{
|
||||
"commodity_name": "Gold",
|
||||
"ignored": "drop",
|
||||
"fields": ["id", "commodity_name", "price_buy"],
|
||||
"limit": 1,
|
||||
},
|
||||
)
|
||||
|
||||
assert result["resource"] == "commodities_prices"
|
||||
assert result["params"] == {"commodity_name": "Gold"}
|
||||
assert result["returned"] == 1
|
||||
assert result["truncated"] is True
|
||||
assert result["items"] == [{"id": 10, "commodity_name": "Gold", "price_buy": 4120}]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_uex_api_catalog_exposes_resources_without_live_call():
|
||||
registry = ToolRegistry(FakeUEX())
|
||||
|
||||
result = await registry.uex_api_catalog(group="vehicles")
|
||||
|
||||
resources = [item["resource"] for item in result["get"]["vehicles"]]
|
||||
assert "vehicles" in resources
|
||||
assert "vehicles_prices" in resources
|
||||
assert "wallet_add" in result["post"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_draft_delete_approves_with_delete_method():
|
||||
registry = ToolRegistry(FakeUEX())
|
||||
result = await registry.execute("delete_uex_marketplace_listings", {"id": 123, "label": "Remove listing"})
|
||||
action_id = result["pending_action"]["id"]
|
||||
|
||||
approved = await registry.approve(action_id)
|
||||
|
||||
assert result["pending_action"]["method"] == "DELETE"
|
||||
assert approved["deleted"] == {
|
||||
"path": "marketplace_listings",
|
||||
"params": {"id": 123},
|
||||
"authenticated": True,
|
||||
}
|
||||
|
||||
|
||||
def test_schemas_expose_specific_uex_tools_instead_of_generic_api_tool():
|
||||
registry = ToolRegistry(FakeUEX())
|
||||
|
||||
names = {schema["function"]["name"] for schema in registry.schemas}
|
||||
|
||||
assert "get_uex_commodities_prices" in names
|
||||
assert "get_uex_vehicles" in names
|
||||
assert "draft_uex_marketplace_advertise" in names
|
||||
assert "delete_uex_marketplace_listings" in names
|
||||
assert "uex_get" not in names
|
||||
assert "uex_draft_post" not in names
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@respx.mock
|
||||
async def test_uex_client_get_user_normalizes_user_payload():
|
||||
|
||||
Reference in New Issue
Block a user