mirror of
https://github.com/hanzoai/python-sdk.git
synced 2026-10-23 20:23:00 +00:00
pkg/hanzoai/cloud/ (2163 files) has existed on disk untracked and never shipped.
This commits it, so the operator surface cloud already serves is finally callable:
AdminApi.plugin_admin_plugins / _enable_plugin / _disable_plugin / _reload_plugin
Generated by hanzoai/openapi `generate.py python` from hanzo.yaml (1885 paths,
69 merged per-service specs). Consumed: cloud 8143fc0e, openapi f581a0e.
One driver, so delete the second one. scripts/generate.sh fetched the spec itself
and then did `rm -rf pkg/hanzoai` + copied generator output over it — which would
have deleted the hand-written config/mcp/protocols/session/zap/api_response
modules AND the new cloud/ tree. Nothing referenced it. hanzoai/openapi's
generate.py + sdks.yaml is the only way now; LLM.md records the pipeline.
`import hanzoai.cloud` raised ImportError as generated. hanzo.yaml has 23 tag
groups differing only by case; openapi-generator maps both spellings to one
module, and for AI/ai, API Keys/api-keys and MCP/mcp it then emits imports for
classes it never wrote (AiApi vs AIApi). Stripped those 9 dead lines. The same
collision silently drops 127 of the 411 operations in those groups — that one is
upstream and only a single tag spelling per service fixes it; noted in LLM.md.
Version: 3.1.1 -> 3.1.2, patch only. pkg/hanzoai/__init__.py said 1.0.0 (the
generator default) — now resolved from the installed distribution, same pattern
as hanzo_cli/hanzo_iam in f453dae8. uv.lock refreshed to match committed pkg
versions. test_smoke.py locks the cloud import, the four plugin ops, and that
__version__ equals the distribution: 6 passed.
Co-authored-by: Hanzo Dev <[email protected]>
75 lines
2.7 KiB
Python
75 lines
2.7 KiB
Python
"""Smoke tests for the generated `hanzoai` client.
|
|
|
|
The client is generated from hanzoai/openapi `hanzo.yaml` (openapi-generator,
|
|
urllib3). These assert the package imports and the unified api.hanzo.ai/v1
|
|
product surface is present — not network behaviour.
|
|
"""
|
|
import hanzoai
|
|
|
|
|
|
def test_client_constructs():
|
|
cfg = hanzoai.Configuration(host="https://api.hanzo.ai")
|
|
cfg.access_token = "hk-test"
|
|
client = hanzoai.ApiClient(cfg)
|
|
assert client is not None
|
|
assert cfg.host == "https://api.hanzo.ai"
|
|
|
|
|
|
def test_product_apis_present():
|
|
from hanzoai.api.tracker_projects_api import TrackerProjectsApi
|
|
from hanzoai.api.chat_agents_api import ChatAgentsApi
|
|
from hanzoai.api.crm_opportunities_api import CrmOpportunitiesApi
|
|
|
|
client = hanzoai.ApiClient(hanzoai.Configuration(host="https://api.hanzo.ai"))
|
|
for cls in (TrackerProjectsApi, ChatAgentsApi, CrmOpportunitiesApi):
|
|
assert cls(client) is not None
|
|
|
|
|
|
def test_full_surface_breadth():
|
|
import glob
|
|
import os
|
|
|
|
api_dir = os.path.dirname(hanzoai.api.__file__)
|
|
modules = glob.glob(os.path.join(api_dir, "*_api.py"))
|
|
# The full unified surface is hundreds of API groups, not the ~40 of the
|
|
# legacy LLM-gateway-only client.
|
|
assert len(modules) > 300, f"only {len(modules)} api modules — surface too small"
|
|
|
|
|
|
def test_version_is_single_sourced():
|
|
"""`hanzoai.__version__` must be the installed distribution, never a literal.
|
|
|
|
The generator writes `__version__ = "1.0.0"` (its default) into the package
|
|
__init__; that literal disagreed with pyproject for every release.
|
|
"""
|
|
from importlib.metadata import version
|
|
|
|
assert hanzoai.__version__ == version("hanzoai")
|
|
|
|
|
|
def test_cloud_package_imports():
|
|
"""`hanzoai.cloud` is the generated client — it must import cleanly.
|
|
|
|
Guards the upstream tag-casing collision in hanzo.yaml: tags that differ only
|
|
by case (`AI`/`ai`, `API Keys`/`api-keys`, `MCP`/`mcp`) make openapi-generator
|
|
emit imports for classes it never wrote, so `import hanzoai.cloud` raised
|
|
ImportError. Regenerating over an unfixed spec brings it straight back.
|
|
"""
|
|
import hanzoai.cloud
|
|
|
|
for name in ("AIApi", "APIKeysApi", "MCPApi", "AdminApi"):
|
|
assert hasattr(hanzoai.cloud, name), f"hanzoai.cloud.{name} missing"
|
|
|
|
|
|
def test_admin_plugin_operator_surface():
|
|
"""The /v1/admin/plugins operator surface must be reachable from the SDK."""
|
|
from hanzoai.cloud.api.admin_api import AdminApi
|
|
|
|
for op in (
|
|
"plugin_admin_plugins",
|
|
"plugin_admin_enable_plugin",
|
|
"plugin_admin_disable_plugin",
|
|
"plugin_admin_reload_plugin",
|
|
):
|
|
assert callable(getattr(AdminApi, op, None)), f"AdminApi.{op} missing"
|