Add maintenance API endpoints

This commit is contained in:
2026-06-07 10:31:41 -06:00
parent d87080d23f
commit 6cc93667ab
11 changed files with 576 additions and 123 deletions
+39 -2
View File
@@ -39,7 +39,11 @@ def test_firmware_registers_current_http_contract_routes():
expected_routes = {
("/api/v1/status", "ANY"),
("/api/v1/health", "HTTP_GET"),
("/api/v1/capabilities", "HTTP_GET"),
("/api/v1/config", "HTTP_GET"),
("/api/v1/config/export", "HTTP_GET"),
("/api/v1/config/import", "HTTP_POST"),
("/api/v1/relay/set", "HTTP_POST"),
("/api/v1/config/wifi", "HTTP_GET"),
("/api/v1/config/wifi", "HTTP_POST"),
@@ -155,10 +159,42 @@ def test_status_fixture_matches_dashboard_contract_shape():
def test_config_fixture_matches_current_config_response_shape():
payload = load_fixture("config_response.json")
assert_keys(payload, ["device_name", "relays", "bms", "temperature_sensors"])
assert_keys(payload, [
"device_name",
"relays",
"bms",
"temperature_sensor_count",
"temperature_sensors",
])
assert_keys(payload["relays"][0], ["id", "name", "pin", "enabled"])
assert_keys(payload["bms"], ["enabled", "name", "address", "address_type"])
assert_keys(payload["temperature_sensors"][0], ["id", "name", "address", "enabled"])
assert_keys(payload["temperature_sensors"][0], [
"id",
"name",
"address",
"enabled",
"weather",
])
def test_health_and_capabilities_contracts_are_registered():
source = firmware_source()
assert '"health_response"' in source
assert '"capabilities_response"' in source
assert '"GET /api/v1/health"' in source
assert '"GET /api/v1/capabilities"' in source
assert '"config_backup_restore"' in source
def test_config_backup_restore_contract_is_registered():
source = firmware_source()
assert 'API_V1("/config/export")' in source
assert 'API_V1("/config/import")' in source
assert '"config_export_response"' in source
assert '"password"' in source
assert '"invalid_config"' in source
def test_relay_set_contract_fixtures_and_firmware_errors():
@@ -236,6 +272,7 @@ def test_http_error_fixture_and_known_error_codes_are_stable():
for error_code in [
"invalid_json",
"invalid_config",
"unknown_relay",
"unknown_temp_sensor",
"invalid_temp_selection",