mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
updated API tests
This commit is contained in:
@@ -445,7 +445,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) {
|
||||
// Mqtt::nested_format(1);
|
||||
Mqtt::nested_format(2);
|
||||
|
||||
// run_test("boiler");
|
||||
run_test("boiler");
|
||||
run_test("thermostat");
|
||||
// run_test("solar");
|
||||
// run_test("mixer");
|
||||
@@ -933,6 +933,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) {
|
||||
#if defined(EMSESP_STANDALONE)
|
||||
shell.printfln(F("Testing RESTful API..."));
|
||||
Mqtt::ha_enabled(false);
|
||||
Mqtt::enabled(false);
|
||||
run_test("general");
|
||||
AsyncWebServerRequest request;
|
||||
|
||||
@@ -950,11 +951,39 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) {
|
||||
request.url("/api/boiler/info");
|
||||
EMSESP::webAPIService.webAPIService_get(&request);
|
||||
|
||||
request.url("/api/boiler/wwcurflow");
|
||||
EMSESP::webAPIService.webAPIService_get(&request);
|
||||
|
||||
// POST
|
||||
request.method(HTTP_POST);
|
||||
|
||||
request.url("/api/system/commands");
|
||||
EMSESP::webAPIService.webAPIService_get(&request);
|
||||
|
||||
DynamicJsonDocument doc(2000);
|
||||
JsonVariant json;
|
||||
|
||||
// 1
|
||||
char data1[] = "{\"name\":\"temp\",\"value\":11}";
|
||||
deserializeJson(doc, data1);
|
||||
json = doc.as<JsonVariant>();
|
||||
request.url("/api/thermostat");
|
||||
EMSESP::webAPIService.webAPIService_post(&request, json);
|
||||
|
||||
// 2
|
||||
char data2[] = "{\"value\":12}";
|
||||
deserializeJson(doc, data2);
|
||||
json = doc.as<JsonVariant>();
|
||||
request.url("/api/thermostat/temp");
|
||||
EMSESP::webAPIService.webAPIService_post(&request, json);
|
||||
|
||||
// 3
|
||||
char data3[] = "{\"device\":\"thermostat\", \"name\":\"temp\",\"value\":11}";
|
||||
deserializeJson(doc, data3);
|
||||
json = doc.as<JsonVariant>();
|
||||
request.url("/api");
|
||||
EMSESP::webAPIService.webAPIService_post(&request, json);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user