test_smoke.py•1.94 kB
"""Smoke tests for the SAP OCC MCP project."""
from __future__ import annotations
import asyncio
import pytest
from app.occ_client import OccClient
from app.server import DOCS_PATH, mcp
from app.settings import settings
def test_docs_path_exists() -> None:
"""Ensure the OCC OpenAPI specification file is present."""
assert DOCS_PATH.exists(), f"Expected OCC spec at {DOCS_PATH}"
def test_tools_registered() -> None:
"""Validate that required tools are registered on the FastMCP server."""
tool_names = set(asyncio.run(mcp.get_tools()).keys())
expected = {
"basesites.list",
"catalogs.list",
"catalogs.get",
"catalogVersions.get",
"categories.products",
"stores.list",
"stores.get",
"products.get",
"products.stock",
"products.stockCount",
"asm.customer360",
"asm.customers.create",
"asm.customers.search",
"asm.customers.suggest",
"carts.list",
"carts.create",
"carts.get",
"carts.delete",
"cartEntries.list",
"cartEntries.add",
"cartEntries.get",
"cartEntries.update",
"cartEntries.patch",
"cartEntries.delete",
}
missing = expected - tool_names
assert not missing, f"Missing tool registrations: {sorted(missing)}"
@pytest.mark.asyncio
@pytest.mark.skipif(not settings.accepts_json, reason="Smoke test expects JSON responses")
async def test_live_basesites_request() -> None:
"""Hit the live OCC endpoint and ensure base sites are returned."""
client = OccClient()
try:
payload = await client.get_basesites(fields=None)
finally:
await client.aclose()
assert isinstance(payload, dict), "Expected OCC payload to be a JSON object"
assert "baseSites" in payload, "OCC response missing 'baseSites'"
assert payload["baseSites"], "OCC response returned no base sites"