mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-10 01:39:54 +03:00
add API test
This commit is contained in:
@@ -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");
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user