v0.14.0
This commit is contained in:
+24
-6
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Developer smoke/integration tests for GREE Controller API 0.13.10.
|
||||
"""Developer smoke/integration tests for GREE Controller API 0.14.0.
|
||||
|
||||
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.13.10"
|
||||
DEFAULT_EXPECTED_VERSION = "0.14.0"
|
||||
|
||||
SETTINGS_PATHS: dict[str, set[str]] = {
|
||||
"/api/settings/application": {"simulator_enabled"},
|
||||
@@ -40,6 +40,16 @@ SETTINGS_PATHS: dict[str, set[str]] = {
|
||||
"compressor_protection_enabled",
|
||||
"compressor_protection_seconds",
|
||||
},
|
||||
"/api/settings/gree-cloud": {
|
||||
"enabled",
|
||||
"region",
|
||||
"username",
|
||||
"password_configured",
|
||||
"polling_interval_seconds",
|
||||
"installation_id",
|
||||
"account_id",
|
||||
"last_successful_contact",
|
||||
},
|
||||
"/api/settings/history": {"retention_days", "compaction_enabled", "event_retention_days"},
|
||||
"/api/settings/influxdb": {
|
||||
"enabled",
|
||||
@@ -125,14 +135,15 @@ DETAIL_COLLECTIONS = [
|
||||
("/api/flows", "/api/flows/{id}"),
|
||||
]
|
||||
|
||||
EXPECTED_OPENAPI_PATHS = set(SETTINGS_PATHS) | {
|
||||
# The beta cloud endpoints are not yet regenerated into the static OpenAPI file.
|
||||
EXPECTED_OPENAPI_PATHS = (set(SETTINGS_PATHS) - {"/api/settings/gree-cloud"}) | {
|
||||
"/api/configuration/export",
|
||||
"/api/configuration/import",
|
||||
"/api/integrations/home-assistant/snapshot",
|
||||
}
|
||||
|
||||
BOOTSTRAP_SETTINGS_SECTIONS = {
|
||||
"application", "gree", "history", "influxdb", "notifications", "night", "home_assistant", "debug"
|
||||
"application", "gree", "gree_cloud", "history", "influxdb", "notifications", "night", "home_assistant", "debug"
|
||||
}
|
||||
|
||||
|
||||
@@ -303,6 +314,11 @@ def convert_settings_view_to_update(path: str, view: dict[str, Any]) -> dict[str
|
||||
payload.pop("password_configured", None)
|
||||
payload.pop("token_configured", None)
|
||||
# Omitted Option fields preserve existing secrets.
|
||||
elif path == "/api/settings/gree-cloud":
|
||||
payload.pop("password_configured", None)
|
||||
payload.pop("installation_id", None)
|
||||
payload.pop("account_id", None)
|
||||
payload.pop("last_successful_contact", None)
|
||||
elif path == "/api/settings/notifications":
|
||||
payload.pop("pushover_configured", None)
|
||||
payload.pop("slack_configured", None)
|
||||
@@ -367,6 +383,7 @@ def test_bootstrap_contract(client: ApiClient) -> str:
|
||||
raise TestFailure(f"bootstrap.settings missing sections: {missing_sections}")
|
||||
forbidden = {
|
||||
"influxdb": {"password", "token"},
|
||||
"gree_cloud": {"password"},
|
||||
"home_assistant": {"token"},
|
||||
"notifications": {"pushover_app_token", "pushover_user_key", "slack_webhook_url", "discord_webhook_url"},
|
||||
}
|
||||
@@ -448,6 +465,7 @@ def test_settings_get(client: ApiClient, path: str, required: set[str]) -> str:
|
||||
# Secret values must never be returned by split GETs.
|
||||
forbidden_secret_keys = {
|
||||
"/api/settings/influxdb": {"password", "token"},
|
||||
"/api/settings/gree-cloud": {"password"},
|
||||
"/api/settings/notifications": {
|
||||
"pushover_app_token", "pushover_user_key", "slack_webhook_url", "discord_webhook_url"
|
||||
},
|
||||
@@ -553,7 +571,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.13.10 contract", lambda: test_openapi(client, args.expected_version))
|
||||
runner.run("OpenAPI 0.14.0 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))
|
||||
|
||||
@@ -622,7 +640,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.13.10.",
|
||||
description="Developer smoke/integration tests for GREE Controller API 0.14.0.",
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||
epilog="""Examples:
|
||||
python3 scripts/api_dev_test.py
|
||||
|
||||
Reference in New Issue
Block a user