This commit is contained in:
Mateusz Gruszczyński
2026-09-16 09:04:43 +02:00
parent 3d69e74319
commit 0437ef7b6f
28 changed files with 1254 additions and 221 deletions
+18 -4
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
"""Developer smoke/integration tests for GREE Controller API 0.14.4.
"""Developer smoke/integration tests for GREE Controller API 0.14.8.
Default mode is read-only and safe to run against a real controller.
Use --settings-write to additionally round-trip all split settings resources and
@@ -26,7 +26,7 @@ from typing import Any, Callable, Iterable, Optional
DEFAULT_BASE_URL = os.environ.get("GREE_API_URL", "http://127.0.0.1:8787")
DEFAULT_TOKEN = os.environ.get("GREE_API_TOKEN", "")
DEFAULT_EXPECTED_VERSION = "0.14.4"
DEFAULT_EXPECTED_VERSION = "0.14.8"
SETTINGS_PATHS: dict[str, set[str]] = {
"/api/settings/application": {"simulator_enabled"},
@@ -368,6 +368,20 @@ def test_openapi(client: ApiClient, expected_version: str) -> str:
version = ((spec.get("info") or {}).get("version"))
if expected_version and version != expected_version:
raise TestFailure(f"OpenAPI info.version={version!r}, expected {expected_version!r}")
external_dependency_operations = [
("/api/integrations/home-assistant/test", "post"),
("/api/integrations/home-assistant/entity", "post"),
("/api/integrations/notifications/test", "post"),
("/api/integrations/gree-cloud/reconnect", "post"),
]
for path, method in external_dependency_operations:
responses = (((paths.get(path) or {}).get(method) or {}).get("responses") or {})
if "502" in responses:
raise TestFailure(f"{method.upper()} {path} must not document external dependency failures as 502")
if "424" not in responses:
raise TestFailure(f"{method.upper()} {path} is missing 424 Failed Dependency")
return f"paths={len(paths)}, version={version}"
@@ -579,7 +593,7 @@ def run_suite(args: argparse.Namespace) -> int:
print(f"Settings write tests: {'ENABLED' if args.settings_write else 'disabled'}\n")
runner.run("public health", lambda: test_health(client, args.expected_version))
runner.run("OpenAPI 0.14.4 contract", lambda: test_openapi(client, args.expected_version))
runner.run("OpenAPI 0.14.8 contract", lambda: test_openapi(client, args.expected_version))
runner.run("bootstrap snapshot contract", lambda: test_bootstrap_contract(client))
runner.run("protected API requires auth", lambda: test_protected_auth(client))
@@ -648,7 +662,7 @@ def run_suite(args: argparse.Namespace) -> int:
def parse_args(argv: Optional[Iterable[str]] = None) -> argparse.Namespace:
parser = argparse.ArgumentParser(
description="Developer smoke/integration tests for GREE Controller API 0.14.4.",
description="Developer smoke/integration tests for GREE Controller API 0.14.8.",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""Examples:
python3 scripts/api_dev_test.py