added more API tests

This commit is contained in:
Proddy
2023-10-01 17:32:16 +02:00
parent e1ee83b907
commit d3b086a675

View File

@@ -1045,7 +1045,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
EMSESP::mqtt_.incoming("ems-esp/thermostat", "{\"cmd\":\"mode\",\"data\":\"heat\",\"id\":1}");
// MQTT bad tests
// MQTT bad tests - these should all fail
EMSESP::mqtt_.incoming("ems-esp/thermostate/mode", "auto"); // unknown device
EMSESP::mqtt_.incoming("ems-esp/thermostat/modee", "auto"); // unknown command
EMSESP::mqtt_.incoming("ems-esp/thermostat/mode/auto", "auto"); // invalid, not allowed
@@ -1124,18 +1124,25 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
request.url("/rest/writeDeviceValue");
EMSESP::webDataService.write_device_value(&request, json);
// write value from web - testing hc9/seltemp - should fail!
char data7[] = "{\"id\":2,\"devicevalue\":{\"v\":\"55\",\"u\":1,\"n\":\"hc2 selected room temperature\",\"c\":\"hc9/seltemp\"}";
// call reset command
char data7[] = "{\"device\":\"boiler\", \"cmd\":\"reset\",\"value\":\"error\"}";
deserializeJson(doc, data7);
json = doc.as<JsonVariant>();
request.url("/api");
EMSESP::webAPIService.webAPIService_post(&request, json);
emsesp::EMSESP::logger().warning("* these next ones should fail *");
// write value from web - testing hc9/seltemp - should fail!
char data8[] = "{\"id\":2,\"devicevalue\":{\"v\":\"55\",\"u\":1,\"n\":\"hc2 selected room temperature\",\"c\":\"hc9/seltemp\"}";
deserializeJson(doc, data8);
json = doc.as<JsonVariant>();
request.url("/rest/writeDeviceValue");
EMSESP::webDataService.write_device_value(&request, json);
// emsesp::EMSESP::logger().notice("*");
// should fail
char data8[] = "{}";
deserializeJson(doc, data8);
// should fail!
char data9[] = "{}";
deserializeJson(doc, data9);
json = doc.as<JsonVariant>();
request.url("/api/thermostat/mode/auto");
EMSESP::webAPIService.webAPIService_post(&request, json);