add API test

This commit is contained in:
proddy
2021-09-20 21:41:29 +02:00
parent 769301c804
commit 6d12fff4fe
2 changed files with 13 additions and 4 deletions

View File

@@ -948,11 +948,20 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) {
if (command == "api") { if (command == "api") {
#if defined(EMSESP_STANDALONE) #if defined(EMSESP_STANDALONE)
shell.printfln(F("Testing RESTful API...")); shell.printfln(F("Testing RESTful API..."));
Mqtt::ha_enabled(false); Mqtt::ha_enabled(true);
Mqtt::enabled(false); Mqtt::enabled(false);
run_test("general"); run_test("general");
AsyncWebServerRequest request; AsyncWebServerRequest request;
request.url("/api/boiler/id");
EMSESP::webAPIService.webAPIService_get(&request);
request.url("/api/thermostat");
EMSESP::webAPIService.webAPIService_get(&request);
request.url("/api/thermostat/hamode");
EMSESP::webAPIService.webAPIService_get(&request);
// GET // GET
request.method(HTTP_GET); request.method(HTTP_GET);
request.url("/api/thermostat/seltemp"); request.url("/api/thermostat/seltemp");
@@ -994,7 +1003,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) {
EMSESP::webAPIService.webAPIService_post(&request, json); EMSESP::webAPIService.webAPIService_post(&request, json);
// 3 // 3
char data3[] = "{\"device\":\"thermostat\", \"name\":\"temp\",\"value\":11}"; char data3[] = "{\"device\":\"thermostat\", \"name\":\"temp\",\"value\":13}";
deserializeJson(doc, data3); deserializeJson(doc, data3);
json = doc.as<JsonVariant>(); json = doc.as<JsonVariant>();
request.url("/api"); request.url("/api");

View File

@@ -34,12 +34,12 @@ namespace emsesp {
// #define EMSESP_DEBUG_DEFAULT "boiler" // #define EMSESP_DEBUG_DEFAULT "boiler"
// #define EMSESP_DEBUG_DEFAULT "mqtt2" // #define EMSESP_DEBUG_DEFAULT "mqtt2"
// #define EMSESP_DEBUG_DEFAULT "mqtt_nested" // #define EMSESP_DEBUG_DEFAULT "mqtt_nested"
#define EMSESP_DEBUG_DEFAULT "ha" // #define EMSESP_DEBUG_DEFAULT "ha"
// #define EMSESP_DEBUG_DEFAULT "board_profile" // #define EMSESP_DEBUG_DEFAULT "board_profile"
// #define EMSESP_DEBUG_DEFAULT "shower_alert" // #define EMSESP_DEBUG_DEFAULT "shower_alert"
// #define EMSESP_DEBUG_DEFAULT "310" // #define EMSESP_DEBUG_DEFAULT "310"
// #define EMSESP_DEBUG_DEFAULT "render" // #define EMSESP_DEBUG_DEFAULT "render"
// #define EMSESP_DEBUG_DEFAULT "api" #define EMSESP_DEBUG_DEFAULT "api"
// #define EMSESP_DEBUG_DEFAULT "crash" // #define EMSESP_DEBUG_DEFAULT "crash"
class Test { class Test {