From 5050d115555cddf377b7cf19290394b1bf6ced1c Mon Sep 17 00:00:00 2001 From: proddy Date: Sat, 3 Aug 2024 13:22:24 +0200 Subject: [PATCH] add Unity unit tests --- platformio.ini | 5 +- src/system.cpp | 17 +- src/test/test.cpp | 112 ---------- src/test/test.h | 2 +- test/test_api/test_api.cpp | 330 +++++++++++++++++++++-------- test/test_api/test_api.h | 422 +++++++++++++++++++++++++++++++++++++ 6 files changed, 688 insertions(+), 200 deletions(-) create mode 100644 test/test_api/test_api.h diff --git a/platformio.ini b/platformio.ini index a76ebc2d9..ebb6b4feb 100644 --- a/platformio.ini +++ b/platformio.ini @@ -261,12 +261,15 @@ lib_ignore = Module EMS-ESP-Modules ; unit tests ; pio run -e native-test -t exec ; works on Linux, Windows, and MacOS +; to auto generate the API exepected test results, compile with -DUNITY_CREATE and capture the output, and paste into the test_api.cpp file [env:native-test] platform = native test_build_src = true build_flags = -DARDUINOJSON_ENABLE_ARDUINO_STRING=1 - -DEMSESP_STANDALONE -DEMSESP_TEST -DUNITY_INCLUDE_CONFIG_H + -DEMSESP_STANDALONE -DEMSESP_TEST + -DUNITY_INCLUDE_CONFIG_H + ; -DUNITY_CREATE -DEMSESP_DEFAULT_LOCALE=\"en\" -DEMSESP_DEFAULT_TX_MODE=8 -DEMSESP_DEFAULT_VERSION=\"3.7.0-dev.0\" -DEMSESP_DEFAULT_BOARD_PROFILE=\"S32\" -std=gnu++14 -Os -ggdb -Wall -Wextra -Werror -lgcov --coverage -fprofile-arcs -ftest-coverage diff --git a/src/system.cpp b/src/system.cpp index 4bfc484e4..2f97793a8 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -1541,9 +1541,16 @@ bool System::command_info(const char * value, const int8_t id, JsonObject output } // API Status - node = output["api"].to(); + node = output["api"].to(); + +// if we're generating test data for Unit Tests we dont want to count these API calls as it will pollute the data response +#if defined(UNITY_INCLUDE_CONFIG_H) + node["APICalls"] = 0; + node["APIFails"] = 0; +#else node["APICalls"] = WebAPIService::api_count(); node["APIFails"] = WebAPIService::api_fails(); +#endif // EMS Bus Status node = output["bus"].to(); @@ -1611,8 +1618,12 @@ bool System::command_info(const char * value, const int8_t id, JsonObject output node["analogEnabled"] = settings.analog_enabled; node["telnetEnabled"] = settings.telnet_enabled; node["maxWebLogBuffer"] = settings.weblog_buffer; - node["webLogBuffer"] = EMSESP::webLogService.num_log_messages(); - node["modbusEnabled"] = settings.modbus_enabled; +#if defined(UNITY_INCLUDE_CONFIG_H) + node["webLogBuffer"] = 0; +#else + node["webLogBuffer"] = EMSESP::webLogService.num_log_messages(); +#endif + node["modbusEnabled"] = settings.modbus_enabled; }); // Devices - show EMS devices if we have any diff --git a/src/test/test.cpp b/src/test/test.cpp index d8089b9d6..d3ac94cd8 100644 --- a/src/test/test.cpp +++ b/src/test/test.cpp @@ -1209,117 +1209,6 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const test("boiler"); test("thermostat"); - AsyncWebServerRequest requestX; - JsonDocument docX; - JsonVariant jsonX; - - requestX.method(HTTP_GET); - - /* - requestX.url("/api"); // should fail - EMSESP::webAPIService.webAPIService(&requestX); - return; - */ - - /* - requestX.url("/api/thermostat/seltemp"); - EMSESP::webAPIService.webAPIService(&requestX); - return; - */ - - /* - requestX.url("/api/thermostat/mode/auto"); - EMSESP::webAPIService.webAPIService(&requestX); - return; - */ - - /* - requestX.url("/api/thermostat"); // check if defaults to info - EMSESP::webAPIService.webAPIService(&requestX); - requestX.url("/api/thermostat/info"); - EMSESP::webAPIService.webAPIService(&requestX); - requestX.url("/api/thermostat/values"); - EMSESP::webAPIService.webAPIService(&requestX); - return; - - requestX.url("/api/thermostat/mode"); - EMSESP::webAPIService.webAPIService(&requestX); - return; - */ - - /* - requestX.url("/api/system"); // check if defaults to info - EMSESP::webAPIService.webAPIService(&requestX); - emsesp::EMSESP::logger().notice("*"); - - requestX.url("/api/system/info"); - EMSESP::webAPIService.webAPIService(&requestX); - emsesp::EMSESP::logger().notice("*"); - - requestX.url("/api/thermostat"); // check if defaults to values - EMSESP::webAPIService.webAPIService(&requestX); - emsesp::EMSESP::logger().notice("*"); - - requestX.url("/api/thermostat/info"); - EMSESP::webAPIService.webAPIService(&requestX); - emsesp::EMSESP::logger().notice("*"); - - requestX.url("/api/thermostat/seltemp"); - EMSESP::webAPIService.webAPIService(&requestX); - return; - */ - - /* - requestX.url("/api/system/restart"); - EMSESP::webAPIService.webAPIService(&requestX); - return; - */ - - /* - requestX.url("/api/temperaturesensor/xxxx"); - EMSESP::webAPIService.webAPIService(&requestX); - emsesp::EMSESP::logger().notice("****"); - requestX.url("/api/temperaturesensor/info"); - EMSESP::webAPIService.webAPIService(&requestX); - return; - */ - - /* - requestX.url("/api"); // should fail - EMSESP::webAPIService.webAPIService(&requestX); - */ - - requestX.method(HTTP_POST); - - /* - char dataX[] = "{\"device\":\"system\", \"entity\":\"settings\"}"; - deserializeJson(docX, dataX); - jsonX = docX.as(); - requestX.url("/api"); - EMSESP::webAPIService.webAPIService(&requestX, jsonX); - return; - */ - - /* - // char dataX[] = "{\"value\":\"0B 88 19 19 02\"}"; - char dataX[] = "{\"name\":\"temp\",\"value\":11}"; - deserializeJson(docX, dataX); - jsonX = docX.as(); - // requestX.url("/api/system/send"); - requestX.url("/api/thermostat"); - EMSESP::webAPIService.webAPIService(&requestX, jsonX); - return; - */ - - /* - char dataX[] = "{}"; - deserializeJson(docX, dataX); - jsonX = docX.as(); - requestX.url("/api/thermostat/mode/auto"); // should fail - EMSESP::webAPIService.webAPIService(&requestX, jsonX); - return; - */ - // test command parse int8_t id_n; const char * ncmd; @@ -1379,7 +1268,6 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const // Web API TESTS AsyncWebServerRequest request; - request.method(HTTP_GET); request.url("/api/thermostat"); // check if defaults to info diff --git a/src/test/test.h b/src/test/test.h index 93fa81e01..5f672358f 100644 --- a/src/test/test.h +++ b/src/test/test.h @@ -41,7 +41,7 @@ namespace emsesp { // #define EMSESP_DEBUG_DEFAULT "310" // #define EMSESP_DEBUG_DEFAULT "render" // #define EMSESP_DEBUG_DEFAULT "api" -#define EMSESP_DEBUG_DEFAULT "api3" +// #define EMSESP_DEBUG_DEFAULT "api3" // #define EMSESP_DEBUG_DEFAULT "crash" // #define EMSESP_DEBUG_DEFAULT "dv" // #define EMSESP_DEBUG_DEFAULT "lastcode" diff --git a/test/test_api/test_api.cpp b/test/test_api/test_api.cpp index 04c40dd95..d701fca88 100644 --- a/test/test_api/test_api.cpp +++ b/test/test_api/test_api.cpp @@ -1,4 +1,23 @@ +/* + * EMS-ESP - https://github.com/emsesp/EMS-ESP + * Copyright 2020-2024 Paul Derbyshire + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #include + #include #include @@ -8,12 +27,28 @@ using namespace emsesp; -AsyncWebServer * webServer; -ESP8266React * esp8266React; -WebAPIService * webAPIService; -AsyncWebServerRequest request; -EMSESP application; -FS dummyFS; +AsyncWebServer * webServer; +ESP8266React * esp8266React; +WebAPIService * webAPIService; +EMSESP application; +FS dummyFS; + +// forward declarations +void run_tests(); +const char * call_url(const char * url); + +// load the tests +// this is generated from this file when compiled with -DUNITY_CREATE +// copy the output to the test_api.h file +#include "test_api.h" // generated test functions + +// Unity's setup call - is called before each test +void setUp() { +} + +// Unity's teardown call - is called after each test +void tearDown() { +} // simulates a telegram straight from UART, but without the CRC which is added automatically void uart_telegram(const std::vector & rx_data) { @@ -28,6 +63,7 @@ void uart_telegram(const std::vector & rx_data) { EMSESP::incoming_telegram(data, i + 1); } +// simulates a telegram from a "string" of hex values void uart_telegram(const char * rx_data) { // since the telegram data is a const, make a copy. add 1 to grab the \0 EOS char telegram[(EMS_MAX_TELEGRAM_LENGTH * 3) + 1]; @@ -66,25 +102,13 @@ void uart_telegram(const char * rx_data) { EMSESP::incoming_telegram(data, count + 2); } +// add an EMS device and regiser it void add_device(uint8_t device_id, uint8_t product_id) { uart_telegram({device_id, 0x0B, EMSdevice::EMS_TYPE_VERSION, 0, product_id, 1, 0}); } -void setUp() { - JsonDocument doc; - JsonVariant json; - - webServer = new AsyncWebServer(80); - esp8266React = new ESP8266React(webServer, &dummyFS); - webAPIService = new WebAPIService(webServer, esp8266React->getSecurityManager()); - - application.start(); // calls begin() - - EMSESP::webCustomEntityService.test(); // custom entities - EMSESP::webCustomizationService.test(); // set customizations - this will overwrite any settings in the FS - EMSESP::temperaturesensor_.test(); // add temperature sensors - EMSESP::webSchedulerService.test(); // run scheduler tests, and conditions - +// add our EMS test devices +void add_devices() { // // boiler // @@ -114,84 +138,224 @@ void setUp() { EMSESP::rxservice_.loop(); } -void tearDown() { -} - -void get_url(const char * url) { +// call the endpoint and get the response, GET +const char * call_url(const char * url) { + AsyncWebServerRequest request; request.method(HTTP_GET); request.url(url); webAPIService->webAPIService(&request); + + return webAPIService->getResponse(); } -void test1() { - get_url("/api/system"); +// call the endpoint and get the response, using a POST +const char * call_url(const char * url, const char * data) { + JsonDocument doc; + JsonVariant json; - // escape strings with https://dolitools.com/text-tools/escape-unescape-string/ - auto response = - "[{\"system\":{\"version\":\"3.7.0-dev.29\",\"uptime\":\"000+00:00:00.000\",\"uptimeSec\":0,\"resetReason\":\"Unknown / " - "Unknown\"},\"network\":{\"network\":\"WiFi\",\"hostname\":\"ems-esp\",\"RSSI\":-23,\"TxPowerSetting\":0,\"staticIP\":false,\"lowBandwidth\":false," - "\"disableSleep\":false,\"enableMDNS\":true,\"enableCORS\":false},\"ntp\":{},\"mqtt\":{\"MQTTStatus\":\"disconnected\",\"MQTTPublishes\":0," - "\"MQTTQueued\":" - "0,\"MQTTPublishFails\":0,\"MQTTConnects\":1,\"enabled\":true,\"clientID\":\"ems-esp\",\"keepAlive\":60,\"cleanSession\":false,\"entityFormat\":1," - "\"base\":" - "\"ems-esp\",\"discoveryPrefix\":\"homeassistant\",\"discoveryType\":0,\"nestedFormat\":1,\"haEnabled\":true,\"mqttQos\":0,\"mqttRetain\":false," - "\"publishTimeHeartbeat\":60,\"publishTimeBoiler\":10,\"publishTimeThermostat\":10,\"publishTimeSolar\":10,\"publishTimeMixer\":10," - "\"publishTimeWater\":0," - "\"publishTimeOther\":10,\"publishTimeSensor\":10,\"publishSingle\":false,\"publish2command\":false,\"sendResponse\":false},\"syslog\":{\"enabled\":" - "false}," - "\"sensor\":{\"temperatureSensors\":2,\"temperatureSensorReads\":0,\"temperatureSensorFails\":0,\"analogSensors\":2,\"analogSensorReads\":0," - "\"analogSensorFails\":0},\"api\":{\"APICalls\":0,\"APIFails\":0},\"bus\":{\"busStatus\":\"connected\",\"busProtocol\":\"Buderus\"," - "\"busTelegramsReceived\":8,\"busReads\":0,\"busWrites\":0,\"busIncompleteTelegrams\":0,\"busReadsFailed\":0,\"busWritesFailed\":0," - "\"busRxLineQuality\":" - "100,\"busTxLineQuality\":100},\"settings\":{\"boardProfile\":\"S32\",\"locale\":\"en\",\"txMode\":8,\"emsBusID\":11,\"showerTimer\":false," - "\"showerMinDuration\":180,\"showerAlert\":false,\"hideLed\":false,\"noTokenApi\":false,\"readonlyMode\":false,\"fahrenheit\":false,\"dallasParasite\":" - "false,\"boolFormat\":1,\"boolDashboard\":1,\"enumFormat\":1,\"analogEnabled\":true,\"telnetEnabled\":true,\"maxWebLogBuffer\":50,\"webLogBuffer\":33," - "\"modbusEnabled\":false},\"devices\":[{\"type\":\"boiler\",\"name\":\"Custom " - "Name!!\",\"deviceID\":\"0x08\",\"productID\":123,\"brand\":\"\",\"version\":\"01.00\",\"entities\":37,\"handlersReceived\":\"0x18\"," - "\"handlersFetched\":" - "\"0x14 0x33\",\"handlersPending\":\"0xBF 0x10 0x11 0xC2 0x15 0x1C 0x19 0x1A 0x35 0x34 0x2A 0xD1 0xE3 0xE4 0xE5 0xE9 0x2E " - "0x3B\"},{\"type\":\"thermostat\",\"name\":\"FW120\",\"deviceID\":\"0x10\",\"productID\":192,\"brand\":\"\",\"version\":\"01.00\",\"entities\":15," - "\"handlersReceived\":\"0x016F\",\"handlersFetched\":\"0x0170 0x0171\",\"handlersPending\":\"0xA3 0x06 0xA2 0x12 0x13 0x0172 0x0165 0x0168\"}]}]"; + deserializeJson(doc, data); + json = doc.as(); - TEST_ASSERT_EQUAL_STRING(response, webAPIService->getResponse()); + AsyncWebServerRequest request; + request.method(HTTP_POST); + request.url(url); + webAPIService->webAPIService(&request, json); + + return webAPIService->getResponse(); } -void test_custom1() { - get_url("/api/custom"); - auto response = "[{\"test_custom\":0.00,\"test_read_only\":0.00,\"test_ram\":\"14\",\"seltemp\":\"14\"}]"; - TEST_ASSERT_EQUAL_STRING(response, webAPIService->getResponse()); +// capture the response and print it out as a test, auto-generates the test functions +// use with -DUNITY_CREATE in the platformio build flags +// only needs to be done once +void capture(const char * url = nullptr) { + static uint8_t count = 1; + + if (count == 1) { + Serial.println(); + Serial.println("// ---------- START - CUT HERE ----------"); + Serial.println(); + } + + if (url) { + // call API, find and replace all double quotes with escaped quotes + std::string escaped_response = call_url(url); + + size_t pos = 0; + while ((pos = escaped_response.find("\"", pos)) != std::string::npos) { + escaped_response.replace(pos, 1, "\\\""); + pos += 2; + } + + Serial.printf("void test_%d() {\n", count++); + Serial.printf(" auto expected_response = \"%s\";\n", escaped_response.c_str()); + Serial.printf(" TEST_ASSERT_EQUAL_STRING(expected_response, call_url(\"%s\"));\n", url); + Serial.println("}"); + Serial.println(); + } else { + // no args means last call, create the run_tests function + Serial.println("void run_tests() {"); + for (uint8_t i = 1; i < count; i++) { + Serial.printf(" RUN_TEST(test_%d);\n", i); + } + Serial.println("}"); + Serial.println(); + Serial.println("// ---------- END - CUT HERE ----------"); + Serial.println(); + Serial.println(); + } } -void test_custom2() { - get_url("/api/custom/seltemp"); - auto response = "[{\"name\":\"seltemp\",\"storage\":\"ram\",\"type\":\"number\",\"readable\":true,\"writeable\":true,\"visible\":true,\"value\":\"14\"}]"; - TEST_ASSERT_EQUAL_STRING(response, webAPIService->getResponse()); +// Functions for backup, just in case we don't have generated functions yet +// void test1() { +// TEST_ASSERT(expected_response != nullptr); +// } +// void run_tests() { +// RUN_TEST(test1); +// } + +void manual_test1() { + auto expected_response = "[{}]"; // empty is good + char data[] = "{\"cmd\":\"send\",\"data\":\"0B 90 FF 13 01 01 B9 01\"}"; + + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/system", data)); } +void manual_test2() { + auto expected_response = "[{}]"; // empty is good + char data[] = "{\"value\":12}"; + + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/thermostat/seltemp", data)); +} + +void manual_test3() { + auto expected_response = "[{}]"; // empty is good + char data[] = "{\"device\":\"thermostat\", \"cmd\":\"hc2.seltemp\",\"value\":14}"; + + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api", data)); +} + +void manual_test4() { + auto expected_response = "[{}]"; // empty is good + char data[] = "{\"entity\":\"seltemp\",\"value\":11}"; + + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/thermostat", data)); +} + +void run_manual_tests() { + RUN_TEST(manual_test1); + RUN_TEST(manual_test2); + RUN_TEST(manual_test3); + RUN_TEST(manual_test4); +} + +// Main entry point int main() { + webServer = new AsyncWebServer(80); + esp8266React = new ESP8266React(webServer, &dummyFS); + webAPIService = new WebAPIService(webServer, esp8266React->getSecurityManager()); + + application.start(); // calls begin() + + EMSESP::webCustomEntityService.test(); // custom entities + EMSESP::webCustomizationService.test(); // set customizations - this will overwrite any settings in the FS + EMSESP::temperaturesensor_.test(); // add temperature sensors + EMSESP::webSchedulerService.test(); // run scheduler tests, and conditions + + add_devices(); // add devices + +#if defined(UNITY_CREATE) + + // These tests should all pass.... + + capture("/api/boiler"); + capture("/api/boiler/commands"); + capture("/api/boiler/values"); + capture("/api/boiler/info"); + // capture("/api/boiler/entities"); // skipping since payload is too large + capture("/api/boiler/comfort"); + capture("/api/boiler/comfort/value"); + capture("/api/boiler/comfort/fullname"); + capture("/api/boiler/outdoortemp"); + capture("/api/boiler/dhw/chargetype"); + capture("/api/boiler/dhw.chargetype/writeable"); + capture("/api/boiler/flamecurr/value"); + + // thermostat + capture("/api/thermostat"); + capture("/api/thermostat/hc1/values"); + capture("/api/thermostat/hc1/seltemp"); + capture("/api/thermostat/hc2/seltemp"); + + // custom + capture("/api/custom"); + capture("/api/custom/info"); + capture("/api/custom/seltemp"); + + // system + capture("/api/system"); + capture("/api/system/info"); + capture("/api/system/settings/locale"); + capture("/api/system/fetch"); + capture("api/system/network/values"); + + // scheduler + capture("/api/scheduler"); + capture("/api/scheduler/info"); + capture("/api/scheduler/test_scheduler"); + + // temperaturesensor + capture("/api/temperaturesensor"); + capture("/api/temperaturesensor/info"); + capture("/api/temperaturesensor/test_sensor2"); + capture("/api/temperaturesensor/0B_0C0D_0E0F_1011"); + capture("/api/temperaturesensor/test_sensor2/value"); + + // analogsensor + capture("/api/analogsensor"); + capture("/api/analogsensor/info"); + capture("/api/analogsensor/test_analog1"); + capture("/api/analogsensor/test_analog1/offset"); + + // these tests should all fail... + capture("/api/boiler2"); + capture("/api/boiler/bad/value"); + capture("/api/boiler/comfort/valu"); + + // system + capture("/api/system/settings/locale2"); + capture("/api/system/settings2"); + capture("/api/system/settings2/locale2"); + + + // scheduler + capture("/api/scheduler/test_scheduler2"); + capture("/api/scheduler/test_scheduler/val"); + capture("/api/scheduler/test_scheduler2/val2"); + + // custom + capture("/api/custom/seltemp2"); + capture("/api/custom/seltemp/val"); + + // temperaturesensor + capture("/api/temperaturesensor/test_sensor20"); + capture("/api/temperaturesensor/0B_0C0D_0E0F_XXXX"); + capture("/api/temperaturesensor/test_sensor2/bad"); + + // analogsensor + capture("/api/analogsensor/test_analog1/bad"); + capture("/api/analogsensor/test_analog10"); + capture("/api/analogsensor/test_analog10/bad2"); + + // ************************************************************************************************** + // Finish + capture(); // always end with this, this will create the run_test() function +#endif + + // always run the tests UNITY_BEGIN(); - RUN_TEST(test1); - RUN_TEST(test_custom1); - RUN_TEST(test_custom2); - - // TODO add all the remaining tests from test.cpp "api3" - // and Michaels' tests... - - /* -api/device -api/device/info -api/device/value -api/device/entities -api/device/commands -api/thermostat/hc2/values (info/entities) to get single circuit info -api/system/network/values (info/entities) to get single circuit info same as for ems devices -api/device/name -api/device/name/attribute -api/device/circuit/name -api/device/circuit/name/attribute -*/ - + run_tests(); // execute the generated tests + run_manual_tests(); // execute some other manual tests from this file return UNITY_END(); } diff --git a/test/test_api/test_api.h b/test/test_api/test_api.h new file mode 100644 index 000000000..3452fe9b8 --- /dev/null +++ b/test/test_api/test_api.h @@ -0,0 +1,422 @@ +// ************************************************************************************************** +// +// Compile with -DUNITY_CREATE to generate the test functions +// and copy the output and paste below. +// +// TODO: convert output to JSON and compare, showing differences +// +// You can also manually compare the differences using https://www.diffchecker.com/text-compare/ +// +// ************************************************************************************************** + +// ---------- START - CUT HERE ---------- + +void test_1() { + auto expected_response = + "[{\"reset\":\"\",\"heatingoff\":\"off\",\"heatingactive\":\"off\",\"tapwateractive\":\"on\",\"selflowtemp\":0,\"curflowtemp\":60.2,\"rettemp\":48.1," + "\"syspress\":1.4,\"burngas\":\"on\",\"burngas2\":\"off\",\"flamecurr\":37.4,\"fanwork\":\"on\",\"ignwork\":\"off\",\"oilpreheat\":\"off\"," + "\"heatingpump\":\"on\",\"selburnpow\":115,\"curburnpow\":61,\"ubauptime\":3940268,\"servicecode\":\"=H\",\"servicecodenumber\":201,\"nompower\":0," + "\"nrgtotal\":0.0,\"nrgheat\":0.0,\"dhw\":{\"seltemp\":52,\"comfort\":\"hot\",\"flowtempoffset\":40,\"circpump\":\"off\",\"chargetype\":\"3-way " + "valve\",\"hyston\":-5,\"hystoff\":0,\"disinfectiontemp\":70,\"circmode\":\"off\",\"circ\":\"off\",\"storagetemp1\":53.8,\"activated\":\"on\"," + "\"3wayvalve\":\"on\",\"nrg\":0.0}}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/boiler")); +} + +void test_2() { + auto expected_response = + "[{\"info\":\"list all values (verbose)\",\"values\":\"list all values\",\"commands\":\"list all commands\",\"entities\":\"list all " + "entities\",\"boil2hystoff\":\"hysteresis stage 2 off temperature\",\"boil2hyston\":\"hysteresis stage 2 on temperature\",\"boilhystoff\":\"hysteresis " + "off temperature\",\"boilhyston\":\"hysteresis on temperature\",\"burnmaxpower\":\"burner max power\",\"burnminperiod\":\"burner min " + "period\",\"burnminpower\":\"burner min power\",\"coldshot\":\"send a cold shot of water\",\"curvebase\":\"heatingcurve " + "base\",\"curveend\":\"heatingcurve end\",\"curveon\":\"heatingcurve on\",\"dhw[n].activated\":\"activated\",\"dhw[n].chargeoptimization\":\"charge " + "optimization\",\"dhw[n].circ\":\"circulation active\",\"dhw[n].circmode\":\"circulation pump mode\",\"dhw[n].circpump\":\"circulation pump " + "available\",\"dhw[n].comfort\":\"comfort\",\"dhw[n].comfort1\":\"comfort " + "mode\",\"dhw[n].disinfecting\":\"disinfecting\",\"dhw[n].disinfectiontemp\":\"disinfection temperature\",\"dhw[n].flowtempoffset\":\"flow temperature " + "offset\",\"dhw[n].hystoff\":\"hysteresis off temperature\",\"dhw[n].hyston\":\"hysteresis on temperature\",\"dhw[n].maxpower\":\"max " + "power\",\"dhw[n].maxtemp\":\"maximum temperature\",\"dhw[n].nrg\":\"energy\",\"dhw[n].onetime\":\"one time charging\",\"dhw[n].seltemp\":\"selected " + "temperature\",\"dhw[n].seltemplow\":\"selected lower temperature\",\"dhw[n].seltempsingle\":\"single charge " + "temperature\",\"dhw[n].tapactivated\":\"turn on/off\",\"dhw[n].tempecoplus\":\"selected eco+ temperature\",\"emergencyops\":\"emergency " + "operation\",\"emergencytemp\":\"emergency temperature\",\"heatingactivated\":\"heating activated\",\"heatingoff\":\"force heating " + "off\",\"heatingtemp\":\"heating temperature\",\"maintenance\":\"maintenance scheduled\",\"maintenancedate\":\"next maintenance " + "date\",\"maintenancetime\":\"time to next maintenance\",\"nofrostmode\":\"nofrost mode\",\"nofrosttemp\":\"nofrost " + "temperature\",\"nompower\":\"nominal Power\",\"nrgheat\":\"energy heating\",\"pumpcharacter\":\"boiler pump characteristic\",\"pumpdelay\":\"pump " + "delay\",\"pumpmode\":\"boiler pump mode\",\"pumpmodmax\":\"boiler pump max power\",\"pumpmodmin\":\"boiler pump min " + "power\",\"reset\":\"reset\",\"selburnpow\":\"burner selected max power\",\"selflowtemp\":\"selected flow temperature\",\"summertemp\":\"summer " + "temperature\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/boiler/commands")); +} + +void test_3() { + auto expected_response = + "[{\"reset\":\"\",\"heatingoff\":\"off\",\"heatingactive\":\"off\",\"tapwateractive\":\"on\",\"selflowtemp\":0,\"curflowtemp\":60.2,\"rettemp\":48.1," + "\"syspress\":1.4,\"burngas\":\"on\",\"burngas2\":\"off\",\"flamecurr\":37.4,\"fanwork\":\"on\",\"ignwork\":\"off\",\"oilpreheat\":\"off\"," + "\"heatingpump\":\"on\",\"selburnpow\":115,\"curburnpow\":61,\"ubauptime\":3940268,\"servicecode\":\"=H\",\"servicecodenumber\":201,\"nompower\":0," + "\"nrgtotal\":0.0,\"nrgheat\":0.0,\"dhw\":{\"seltemp\":52,\"comfort\":\"hot\",\"flowtempoffset\":40,\"circpump\":\"off\",\"chargetype\":\"3-way " + "valve\",\"hyston\":-5,\"hystoff\":0,\"disinfectiontemp\":70,\"circmode\":\"off\",\"circ\":\"off\",\"storagetemp1\":53.8,\"activated\":\"on\"," + "\"3wayvalve\":\"on\",\"nrg\":0.0}}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/boiler/values")); +} + +void test_4() { + auto expected_response = + "[{\"reset (reset)\":\"\",\"force heating off (heatingoff)\":\"off\",\"is my heating on? (heatingactive)\":\"off\",\"tapwater active " + "(tapwateractive)\":\"on\",\"selected flow temperature (selflowtemp)\":0,\"current flow temperature (curflowtemp)\":60.2,\"return temperature " + "(rettemp)\":48.1,\"system pressure (syspress)\":1.4,\"gas (burngas)\":\"on\",\"gas stage 2 (burngas2)\":\"off\",\"flame current " + "(flamecurr)\":37.4,\"fan (fanwork)\":\"on\",\"ignition (ignwork)\":\"off\",\"oil preheating (oilpreheat)\":\"off\",\"heating pump " + "(heatingpump)\":\"on\",\"burner selected max power (selburnpow)\":115,\"burner current power (curburnpow)\":61,\"total UBA operating time " + "(ubauptime)\":\"2736 days 7 hours 8 minutes\",\"service code (servicecode)\":\"=H\",\"service code number (servicecodenumber)\":201,\"dhw selected " + "temperature (seltemp)\":52,\"dhw comfort (comfort)\":\"hot\",\"dhw flow temperature offset (flowtempoffset)\":40,\"dhw circulation pump available " + "(circpump)\":\"off\",\"dhw charging type (chargetype)\":\"3-way valve\",\"dhw hysteresis on temperature (hyston)\":-5,\"dhw hysteresis off " + "temperature (hystoff)\":0,\"dhw disinfection temperature (disinfectiontemp)\":70,\"dhw circulation pump mode (circmode)\":\"off\",\"dhw circulation " + "active (circ)\":\"off\",\"dhw storage intern temperature (storagetemp1)\":53.8,\"dhw activated (activated)\":\"on\",\"dhw 3-way valve active " + "(3wayvalve)\":\"on\",\"nominal Power (nompower)\":0,\"total energy (nrgtotal)\":0.0,\"energy heating (nrgheat)\":0.0,\"dhw energy (nrg)\":0.0}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/boiler/info")); +} + +void test_5() { + auto expected_response = "[{\"name\":\"comfort\",\"fullname\":\"dhw " + "comfort\",\"circuit\":\"dhw\",\"index\":0,\"enum\":[\"hot\",\"eco\",\"intelligent\"],\"value\":\"hot\",\"type\":\"enum\"," + "\"readable\":true,\"writeable\":true,\"visible\":true}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/boiler/comfort")); +} + +void test_6() { + auto expected_response = "[{\"api_data\":\"hot\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/boiler/comfort/value")); +} + +void test_7() { + auto expected_response = "[{\"api_data\":\"dhw comfort\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/boiler/comfort/fullname")); +} + +void test_8() { + auto expected_response = "[{\"name\":\"outdoortemp\",\"fullname\":\"outside " + "temperature\",\"circuit\":\"\",\"type\":\"number\",\"uom\":\"°C\",\"readable\":true,\"writeable\":false,\"visible\":true}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/boiler/outdoortemp")); +} + +void test_9() { + auto expected_response = "[{\"name\":\"chargetype\",\"fullname\":\"dhw charging type\",\"circuit\":\"dhw\",\"index\":1,\"enum\":[\"chargepump\",\"3-way " + "valve\"],\"value\":\"3-way valve\",\"type\":\"enum\",\"readable\":true,\"writeable\":false,\"visible\":true}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/boiler/dhw/chargetype")); +} + +void test_10() { + auto expected_response = "[{\"api_data\":\"false\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/boiler/dhw.chargetype/writeable")); +} + +void test_11() { + auto expected_response = "[{\"api_data\":\"37.4\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/boiler/flamecurr/value")); +} + +void test_12() { + auto expected_response = "[{\"hc1\":{\"seltemp\":20.5,\"currtemp\":22.8,\"haclimate\":\"roomTemp\",\"modetype\":\"heat\",\"remotetemp\":null},\"hc2\":{" + "\"seltemp\":20.6,\"currtemp\":22.9,\"haclimate\":\"roomTemp\",\"modetype\":\"eco\",\"remotetemp\":null},\"hc3\":{\"seltemp\":20." + "7,\"currtemp\":23.0,\"haclimate\":\"roomTemp\",\"modetype\":\"nofrost\",\"remotetemp\":null},\"dhw\":{}}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/thermostat")); +} + +void test_13() { + auto expected_response = "[{\"seltemp\":20.5,\"currtemp\":22.8,\"haclimate\":\"roomTemp\",\"modetype\":\"heat\",\"remotetemp\":null}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/thermostat/hc1/values")); +} + +void test_14() { + auto expected_response = "[{\"name\":\"seltemp\",\"fullname\":\"hc1 selected room " + "temperature\",\"circuit\":\"hc1\",\"value\":20.5,\"type\":\"number\",\"min\":0,\"max\":30,\"uom\":\"°C\",\"readable\":true," + "\"writeable\":true,\"visible\":true}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/thermostat/hc1/seltemp")); +} + +void test_15() { + auto expected_response = "[{\"name\":\"seltemp\",\"fullname\":\"hc2 selected room " + "temperature\",\"circuit\":\"hc2\",\"value\":20.6,\"type\":\"number\",\"min\":0,\"max\":30,\"uom\":\"°C\",\"readable\":true," + "\"writeable\":true,\"visible\":true}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/thermostat/hc2/seltemp")); +} + +void test_16() { + auto expected_response = "[{\"test_custom\":0.00,\"test_read_only\":0.00,\"test_ram\":\"14\",\"seltemp\":\"14\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/custom")); +} + +void test_17() { + auto expected_response = "[{\"test_custom\":0.00,\"test_read_only\":0.00,\"test_ram\":\"14\",\"seltemp\":\"14\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/custom/info")); +} + +void test_18() { + auto expected_response = + "[{\"name\":\"seltemp\",\"storage\":\"ram\",\"type\":\"number\",\"readable\":true,\"writeable\":true,\"visible\":true,\"value\":\"14\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/custom/seltemp")); +} + +void test_19() { + auto expected_response = + "[{\"system\":{\"version\":\"3.7.0-dev.29\",\"uptime\":\"000+00:00:00.000\",\"uptimeSec\":0,\"resetReason\":\"Unknown / " + "Unknown\"},\"network\":{\"network\":\"WiFi\",\"hostname\":\"ems-esp\",\"RSSI\":-23,\"TxPowerSetting\":0,\"staticIP\":false,\"lowBandwidth\":false," + "\"disableSleep\":false,\"enableMDNS\":true,\"enableCORS\":false},\"ntp\":{},\"mqtt\":{\"MQTTStatus\":\"disconnected\",\"MQTTPublishes\":0," + "\"MQTTQueued\":0,\"MQTTPublishFails\":0,\"MQTTConnects\":1,\"enabled\":true,\"clientID\":\"ems-esp\",\"keepAlive\":60,\"cleanSession\":false," + "\"entityFormat\":1,\"base\":\"ems-esp\",\"discoveryPrefix\":\"homeassistant\",\"discoveryType\":0,\"nestedFormat\":1,\"haEnabled\":true,\"mqttQos\":0," + "\"mqttRetain\":false,\"publishTimeHeartbeat\":60,\"publishTimeBoiler\":10,\"publishTimeThermostat\":10,\"publishTimeSolar\":10,\"publishTimeMixer\":" + "10,\"publishTimeWater\":0,\"publishTimeOther\":10,\"publishTimeSensor\":10,\"publishSingle\":false,\"publish2command\":false,\"sendResponse\":false}," + "\"syslog\":{\"enabled\":false},\"sensor\":{\"temperatureSensors\":2,\"temperatureSensorReads\":0,\"temperatureSensorFails\":0,\"analogSensors\":2," + "\"analogSensorReads\":0,\"analogSensorFails\":0},\"api\":{\"APICalls\":0,\"APIFails\":0},\"bus\":{\"busStatus\":\"connected\",\"busProtocol\":" + "\"Buderus\",\"busTelegramsReceived\":8,\"busReads\":0,\"busWrites\":0,\"busIncompleteTelegrams\":0,\"busReadsFailed\":0,\"busWritesFailed\":0," + "\"busRxLineQuality\":100,\"busTxLineQuality\":100},\"settings\":{\"boardProfile\":\"S32\",\"locale\":\"en\",\"txMode\":8,\"emsBusID\":11," + "\"showerTimer\":false,\"showerMinDuration\":180,\"showerAlert\":false,\"hideLed\":false,\"noTokenApi\":false,\"readonlyMode\":false,\"fahrenheit\":" + "false,\"dallasParasite\":false,\"boolFormat\":1,\"boolDashboard\":1,\"enumFormat\":1,\"analogEnabled\":true,\"telnetEnabled\":true," + "\"maxWebLogBuffer\":50,\"webLogBuffer\":0,\"modbusEnabled\":false},\"devices\":[{\"type\":\"boiler\",\"name\":\"Custom " + "Name!!\",\"deviceID\":\"0x08\",\"productID\":123,\"brand\":\"\",\"version\":\"01.00\",\"entities\":37,\"handlersReceived\":\"0x18\"," + "\"handlersFetched\":\"0x14 0x33\",\"handlersPending\":\"0xBF 0x10 0x11 0xC2 0x15 0x1C 0x19 0x1A 0x35 0x34 0x2A 0xD1 0xE3 0xE4 0xE5 0xE9 0x2E " + "0x3B\"},{\"type\":\"thermostat\",\"name\":\"FW120\",\"deviceID\":\"0x10\",\"productID\":192,\"brand\":\"\",\"version\":\"01.00\",\"entities\":15," + "\"handlersReceived\":\"0x016F\",\"handlersFetched\":\"0x0170 0x0171\",\"handlersPending\":\"0xA3 0x06 0xA2 0x12 0x13 0x0172 0x0165 0x0168\"}]}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/system")); +} + +void test_20() { + auto expected_response = + "[{\"system\":{\"version\":\"3.7.0-dev.29\",\"uptime\":\"000+00:00:00.000\",\"uptimeSec\":0,\"resetReason\":\"Unknown / " + "Unknown\"},\"network\":{\"network\":\"WiFi\",\"hostname\":\"ems-esp\",\"RSSI\":-23,\"TxPowerSetting\":0,\"staticIP\":false,\"lowBandwidth\":false," + "\"disableSleep\":false,\"enableMDNS\":true,\"enableCORS\":false},\"ntp\":{},\"mqtt\":{\"MQTTStatus\":\"disconnected\",\"MQTTPublishes\":0," + "\"MQTTQueued\":0,\"MQTTPublishFails\":0,\"MQTTConnects\":1,\"enabled\":true,\"clientID\":\"ems-esp\",\"keepAlive\":60,\"cleanSession\":false," + "\"entityFormat\":1,\"base\":\"ems-esp\",\"discoveryPrefix\":\"homeassistant\",\"discoveryType\":0,\"nestedFormat\":1,\"haEnabled\":true,\"mqttQos\":0," + "\"mqttRetain\":false,\"publishTimeHeartbeat\":60,\"publishTimeBoiler\":10,\"publishTimeThermostat\":10,\"publishTimeSolar\":10,\"publishTimeMixer\":" + "10,\"publishTimeWater\":0,\"publishTimeOther\":10,\"publishTimeSensor\":10,\"publishSingle\":false,\"publish2command\":false,\"sendResponse\":false}," + "\"syslog\":{\"enabled\":false},\"sensor\":{\"temperatureSensors\":2,\"temperatureSensorReads\":0,\"temperatureSensorFails\":0,\"analogSensors\":2," + "\"analogSensorReads\":0,\"analogSensorFails\":0},\"api\":{\"APICalls\":0,\"APIFails\":0},\"bus\":{\"busStatus\":\"connected\",\"busProtocol\":" + "\"Buderus\",\"busTelegramsReceived\":8,\"busReads\":0,\"busWrites\":0,\"busIncompleteTelegrams\":0,\"busReadsFailed\":0,\"busWritesFailed\":0," + "\"busRxLineQuality\":100,\"busTxLineQuality\":100},\"settings\":{\"boardProfile\":\"S32\",\"locale\":\"en\",\"txMode\":8,\"emsBusID\":11," + "\"showerTimer\":false,\"showerMinDuration\":180,\"showerAlert\":false,\"hideLed\":false,\"noTokenApi\":false,\"readonlyMode\":false,\"fahrenheit\":" + "false,\"dallasParasite\":false,\"boolFormat\":1,\"boolDashboard\":1,\"enumFormat\":1,\"analogEnabled\":true,\"telnetEnabled\":true," + "\"maxWebLogBuffer\":50,\"webLogBuffer\":0,\"modbusEnabled\":false},\"devices\":[{\"type\":\"boiler\",\"name\":\"Custom " + "Name!!\",\"deviceID\":\"0x08\",\"productID\":123,\"brand\":\"\",\"version\":\"01.00\",\"entities\":37,\"handlersReceived\":\"0x18\"," + "\"handlersFetched\":\"0x14 0x33\",\"handlersPending\":\"0xBF 0x10 0x11 0xC2 0x15 0x1C 0x19 0x1A 0x35 0x34 0x2A 0xD1 0xE3 0xE4 0xE5 0xE9 0x2E " + "0x3B\"},{\"type\":\"thermostat\",\"name\":\"FW120\",\"deviceID\":\"0x10\",\"productID\":192,\"brand\":\"\",\"version\":\"01.00\",\"entities\":15," + "\"handlersReceived\":\"0x016F\",\"handlersFetched\":\"0x0170 0x0171\",\"handlersPending\":\"0xA3 0x06 0xA2 0x12 0x13 0x0172 0x0165 0x0168\"}]}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/system/info")); +} + +void test_21() { + auto expected_response = + "[{\"name\":\"locale\",\"circuit\":\"settings\",\"readable\":true,\"writable\":false,\"visible\":true,\"value\":\"en\",\"type\":\"string\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/system/settings/locale")); +} + +void test_22() { + auto expected_response = "[{}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/system/fetch")); +} + +void test_23() { + auto expected_response = "[{\"network\":\"WiFi\",\"hostname\":\"ems-esp\",\"RSSI\":\"-23\",\"TxPowerSetting\":\"0\",\"staticIP\":\"false\"," + "\"lowBandwidth\":\"false\",\"disableSleep\":\"false\",\"enableMDNS\":\"true\",\"enableCORS\":\"false\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("api/system/network/values")); +} + +void test_24() { + auto expected_response = "[{\"test_scheduler\":\"on\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/scheduler")); +} + +void test_25() { + auto expected_response = "[{\"test_scheduler\":\"on\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/scheduler/info")); +} + +void test_26() { + auto expected_response = "[{\"name\":\"test_scheduler\",\"type\":\"boolean\",\"value\":\"on\",\"time\":\"12:00\",\"command\":\"system/" + "fetch\",\"cmd_data\":\"10\",\"readable\":true,\"writeable\":true,\"visible\":true}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/scheduler/test_scheduler")); +} + +void test_27() { + auto expected_response = "[{\"test_sensor1\":12.3,\"test_sensor2\":45.6}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/temperaturesensor")); +} + +void test_28() { + auto expected_response = "[{\"test_sensor1\":12.3,\"test_sensor2\":45.6}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/temperaturesensor/info")); +} + +void test_29() { + auto expected_response = "[{\"id\":\"0B_0C0D_0E0F_1011\",\"name\":\"test_sensor2\",\"value\":45.6,\"type\":\"number\",\"uom\":\"°C\",\"writeable\":false}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/temperaturesensor/test_sensor2")); +} + +void test_30() { + auto expected_response = "[{\"id\":\"0B_0C0D_0E0F_1011\",\"name\":\"test_sensor2\",\"value\":45.6,\"type\":\"number\",\"uom\":\"°C\",\"writeable\":false}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/temperaturesensor/0B_0C0D_0E0F_1011")); +} + +void test_31() { + auto expected_response = "[{\"api_data\":\"45.6\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/temperaturesensor/test_sensor2/value")); +} + +void test_32() { + auto expected_response = "[{\"test_analog1\":0,\"test_analog2\":1}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/analogsensor")); +} + +void test_33() { + auto expected_response = "[{\"test_analog1\":0,\"test_analog2\":1}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/analogsensor/info")); +} + +void test_34() { + auto expected_response = + "[{\"gpio\":36,\"type\":\"number\",\"analog\":\"adc\",\"value\":0,\"writeable\":false,\"offset\":0,\"factor\":0.1,\"uom\":\"mV\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/analogsensor/test_analog1")); +} + +void test_35() { + auto expected_response = "[{\"api_data\":\"0\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/analogsensor/test_analog1/offset")); +} + +void test_36() { + auto expected_response = "[{\"message\":\"unknown device boiler2\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/boiler2")); +} + +void test_37() { + auto expected_response = "[{\"message\":\"no bad in boiler\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/boiler/bad/value")); +} + +void test_38() { + auto expected_response = "[{\"message\":\"Command comfort failed (Error)\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/boiler/comfort/valu")); +} + +void test_39() { + auto expected_response = "[{\"message\":\"no settings in system\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/system/settings/locale2")); +} + +void test_40() { + auto expected_response = "[{\"message\":\"no settings2 in system\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/system/settings2")); +} + +void test_41() { + auto expected_response = "[{\"message\":\"no settings2 in system\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/system/settings2/locale2")); +} + +void test_42() { + auto expected_response = "[{\"message\":\"no test_scheduler2 in scheduler\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/scheduler/test_scheduler2")); +} + +void test_43() { + auto expected_response = "[{\"message\":\"no val in test_scheduler\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/scheduler/test_scheduler/val")); +} + +void test_44() { + auto expected_response = "[{\"message\":\"no test_scheduler2 in scheduler\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/scheduler/test_scheduler2/val2")); +} + +void test_45() { + auto expected_response = "[{\"message\":\"no seltemp2 in custom\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/custom/seltemp2")); +} + +void test_46() { + auto expected_response = "[{\"message\":\"no val in seltemp\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/custom/seltemp/val")); +} + +void test_47() { + auto expected_response = "[{\"message\":\"no test_sensor20 in temperaturesensor\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/temperaturesensor/test_sensor20")); +} + +void test_48() { + auto expected_response = "[{\"message\":\"no 0b_0c0d_0e0f_xxxx in temperaturesensor\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/temperaturesensor/0B_0C0D_0E0F_XXXX")); +} + +void test_49() { + auto expected_response = "[{\"message\":\"no bad in test_sensor2\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/temperaturesensor/test_sensor2/bad")); +} + +void test_50() { + auto expected_response = "[{\"message\":\"no bad in test_analog1\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/analogsensor/test_analog1/bad")); +} + +void test_51() { + auto expected_response = "[{\"message\":\"no test_analog10 in analogsensor\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/analogsensor/test_analog10")); +} + +void test_52() { + auto expected_response = "[{\"message\":\"no test_analog10 in analogsensor\"}]"; + TEST_ASSERT_EQUAL_STRING(expected_response, call_url("/api/analogsensor/test_analog10/bad2")); +} + +void run_tests() { + RUN_TEST(test_1); + RUN_TEST(test_2); + RUN_TEST(test_3); + RUN_TEST(test_4); + RUN_TEST(test_5); + RUN_TEST(test_6); + RUN_TEST(test_7); + RUN_TEST(test_8); + RUN_TEST(test_9); + RUN_TEST(test_10); + RUN_TEST(test_11); + RUN_TEST(test_12); + RUN_TEST(test_13); + RUN_TEST(test_14); + RUN_TEST(test_15); + RUN_TEST(test_16); + RUN_TEST(test_17); + RUN_TEST(test_18); + RUN_TEST(test_19); + RUN_TEST(test_20); + RUN_TEST(test_21); + RUN_TEST(test_22); + RUN_TEST(test_23); + RUN_TEST(test_24); + RUN_TEST(test_25); + RUN_TEST(test_26); + RUN_TEST(test_27); + RUN_TEST(test_28); + RUN_TEST(test_29); + RUN_TEST(test_30); + RUN_TEST(test_31); + RUN_TEST(test_32); + RUN_TEST(test_33); + RUN_TEST(test_34); + RUN_TEST(test_35); + RUN_TEST(test_36); + RUN_TEST(test_37); + RUN_TEST(test_38); + RUN_TEST(test_39); + RUN_TEST(test_40); + RUN_TEST(test_41); + RUN_TEST(test_42); + RUN_TEST(test_43); + RUN_TEST(test_44); + RUN_TEST(test_45); + RUN_TEST(test_46); + RUN_TEST(test_47); + RUN_TEST(test_48); + RUN_TEST(test_49); + RUN_TEST(test_50); + RUN_TEST(test_51); + RUN_TEST(test_52); +} + +// ---------- END - CUT HERE ----------