feat: Test_IOT #40
@ -40,9 +40,7 @@ public:
|
|||||||
* @return false il y a une erreur durran l'envoie
|
* @return false il y a une erreur durran l'envoie
|
||||||
*/
|
*/
|
||||||
bool sendValue(String val, String poubelleID, String unit, bool full);
|
bool sendValue(String val, String poubelleID, String unit, bool full);
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
/**
|
/**
|
||||||
* @brief connect l'utilisateur a l'api et met a jour le token
|
* @brief connect l'utilisateur a l'api et met a jour le token
|
||||||
*
|
*
|
||||||
@ -51,6 +49,11 @@ private:
|
|||||||
*/
|
*/
|
||||||
bool connect();
|
bool connect();
|
||||||
|
|
||||||
|
//TODO :: Check wifibegin avant
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ID de l'utilisateur
|
* @brief ID de l'utilisateur
|
||||||
*
|
*
|
||||||
|
@ -59,7 +59,8 @@ bool API::connect(){
|
|||||||
this->client->println();
|
this->client->println();
|
||||||
|
|
||||||
|
|
||||||
while (!client->available()) {}
|
while (!client->available()) {
|
||||||
|
}
|
||||||
|
|
||||||
String responce = "";
|
String responce = "";
|
||||||
while (client->available()) {
|
while (client->available()) {
|
||||||
@ -77,7 +78,10 @@ bool API::connect(){
|
|||||||
this->client->stop();
|
this->client->stop();
|
||||||
|
|
||||||
sortie = true;
|
sortie = true;
|
||||||
|
if (JSONVar::stringify(JSONVar::parse(str)["code"]) == "400") {
|
||||||
|
Serial.println("Failed to authenticate");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return sortie;
|
return sortie;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,8 @@ void setup() {
|
|||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
RUN_TEST(TestWifiBeginConnected);
|
RUN_TEST(TestWifiBeginConnected);
|
||||||
RUN_TEST(TestWifiBeginNotConnected);
|
RUN_TEST(TestWifiBeginNotConnected);
|
||||||
|
RUN_TEST(TestConnectAPI);
|
||||||
|
// RUN_TEST(TestConnectAPIFailed);
|
||||||
|
|
||||||
|
|
||||||
UNITY_END();
|
UNITY_END();
|
||||||
|
@ -3,5 +3,7 @@
|
|||||||
|
|
||||||
void TestWifiBeginConnected();
|
void TestWifiBeginConnected();
|
||||||
void TestWifiBeginNotConnected();
|
void TestWifiBeginNotConnected();
|
||||||
|
void TestConnectAPI();
|
||||||
|
// void TestConnectAPIFailed();
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -2,6 +2,8 @@
|
|||||||
#include <unity.h>
|
#include <unity.h>
|
||||||
#include "API.h"
|
#include "API.h"
|
||||||
|
|
||||||
|
|
||||||
|
//Testing WifiBegin function
|
||||||
void TestWifiBeginConnected() {
|
void TestWifiBeginConnected() {
|
||||||
API* api = new API(USER_NAME, USER_PASSWORD, API_HOST);
|
API* api = new API(USER_NAME, USER_PASSWORD, API_HOST);
|
||||||
|
|
||||||
@ -16,4 +18,24 @@ void TestWifiBeginNotConnected() {
|
|||||||
Serial2.begin(MONITOR_SPEED);
|
Serial2.begin(MONITOR_SPEED);
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(false, api->wifiBegin(WIFI_SSID, WIFI_PASSWORD, &Serial2), "Wifi connected");
|
TEST_ASSERT_EQUAL_MESSAGE(false, api->wifiBegin(WIFI_SSID, WIFI_PASSWORD, &Serial2), "Wifi connected");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Testing Connect function
|
||||||
|
void TestConnectAPI() {
|
||||||
|
API* api = new API(USER_NAME, USER_PASSWORD, API_HOST);
|
||||||
|
|
||||||
|
Serial1.begin(MONITOR_SPEED);
|
||||||
|
api->wifiBegin(WIFI_SSID, WIFI_PASSWORD, &Serial1);
|
||||||
|
TEST_ASSERT_EQUAL_MESSAGE(true, api->connect(), "Not Connected");
|
||||||
|
}
|
||||||
|
|
||||||
|
// void TestConnectAPIFailed() {
|
||||||
|
// API* api = new API("Carl", "toto", API_HOST);
|
||||||
|
|
||||||
|
// Serial1.begin(MONITOR_SPEED);
|
||||||
|
// api->wifiBegin(WIFI_SSID, WIFI_PASSWORD, &Serial1);
|
||||||
|
// TEST_ASSERT_EQUAL_MESSAGE(false, api->connect(), "Connected");
|
||||||
|
// }
|
||||||
|
|
||||||
|
//Testing SendValue function
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user