| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- """Import and packaging smoke tests. Do not require a running daemon."""
- from __future__ import annotations
- def test_import_package():
- import hth_sdk
- assert hth_sdk.__version__ == "0.3.0"
- def test_public_symbols():
- import hth_sdk
- assert hth_sdk.__all__ == ["HTH", "State", "Control", "Result", "HTHError"]
- for name in hth_sdk.__all__:
- assert hasattr(hth_sdk, name)
- assert "ActionBatch" not in hth_sdk.__all__
- assert "HthClient" not in hth_sdk.__all__
- assert "ControlLease" not in hth_sdk.__all__
- def test_sdk_does_not_import_heavy_deps():
- import ast
- from pathlib import Path
- import hth_sdk
- banned = {"numpy", "pandas", "torch", "tensorflow"}
- root = Path(hth_sdk.__file__).resolve().parent
- for path in root.rglob("*.py"):
- if "generated" in path.parts:
- continue
- tree = ast.parse(path.read_text(encoding="utf-8"))
- for node in ast.walk(tree):
- names: list[str] = []
- if isinstance(node, ast.Import):
- names = [n.name.split(".", 1)[0] for n in node.names]
- elif isinstance(node, ast.ImportFrom) and node.module:
- names = [node.module.split(".", 1)[0]]
- for name in names:
- assert name not in banned, f"{path} imports {name}"
|