Skip to content

Commit

Permalink
add API test
Browse files Browse the repository at this point in the history
  • Loading branch information
proddy committed Sep 20, 2021
1 parent 769301c commit 6d12fff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 11 additions & 2 deletions src/test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -948,11 +948,20 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) {
if (command == "api") {
#if defined(EMSESP_STANDALONE)
shell.printfln(F("Testing RESTful API..."));
Mqtt::ha_enabled(false);
Mqtt::ha_enabled(true);
Mqtt::enabled(false);
run_test("general");
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
request.method(HTTP_GET);
request.url("/api/thermostat/seltemp");
Expand Down Expand Up @@ -994,7 +1003,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) {
EMSESP::webAPIService.webAPIService_post(&request, json);

// 3
char data3[] = "{\"device\":\"thermostat\", \"name\":\"temp\",\"value\":11}";
char data3[] = "{\"device\":\"thermostat\", \"name\":\"temp\",\"value\":13}";
deserializeJson(doc, data3);
json = doc.as<JsonVariant>();
request.url("/api");
Expand Down
4 changes: 2 additions & 2 deletions src/test/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ namespace emsesp {
// #define EMSESP_DEBUG_DEFAULT "boiler"
// #define EMSESP_DEBUG_DEFAULT "mqtt2"
// #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 "shower_alert"
// #define EMSESP_DEBUG_DEFAULT "310"
// #define EMSESP_DEBUG_DEFAULT "render"
// #define EMSESP_DEBUG_DEFAULT "api"
#define EMSESP_DEBUG_DEFAULT "api"
// #define EMSESP_DEBUG_DEFAULT "crash"

class Test {
Expand Down

0 comments on commit 6d12fff

Please sign in to comment.