mirror of
https://gitlab.com/spaceti-app/integrations/acs/colnod-connector.git
synced 2026-07-12 13:00:41 +02:00
Finish unit test
This commit is contained in:
parent
988e01ef1b
commit
0efd39d4ae
6
src/colnod/colnodapi.cpp
Normal file
6
src/colnod/colnodapi.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
#include "colnodapi.h"
|
||||
|
||||
ColnodAPI::ColnodAPI()
|
||||
{
|
||||
|
||||
}
|
||||
11
src/colnod/colnodapi.h
Normal file
11
src/colnod/colnodapi.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef COLNODAPI_H
|
||||
#define COLNODAPI_H
|
||||
|
||||
|
||||
class ColnodAPI
|
||||
{
|
||||
public:
|
||||
ColnodAPI();
|
||||
};
|
||||
|
||||
#endif // COLNODAPI_H
|
||||
@ -4,7 +4,7 @@ DataProcessor::DataProcessor(Data *data)
|
||||
{
|
||||
|
||||
db = new DatabaseManager("192.168.1.94", "deloitte", "postgres", "34rjkciea12");
|
||||
reqMan = new RequestManager(data);
|
||||
reqMan = new RequestManager();
|
||||
dataToProcess = data;
|
||||
}
|
||||
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
#include "requestmanager.h"
|
||||
|
||||
RequestManager::RequestManager(Data *data)
|
||||
RequestManager::RequestManager()
|
||||
{
|
||||
manager = new QNetworkAccessManager();
|
||||
token = "";
|
||||
loginStatus = false; //should be false, true for testing request header
|
||||
this->data = data;
|
||||
/*
|
||||
QFile configFile(QDir::current().filePath("config.json"));
|
||||
if (!configFile.open(QIODevice::ReadOnly)) {
|
||||
|
||||
@ -31,7 +31,7 @@ class RequestManager : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RequestManager(Data *data);
|
||||
RequestManager();
|
||||
void getSubjects();
|
||||
void login(QString endpoint, QString username, QString password);
|
||||
void getRequest(QString endpoint);
|
||||
|
||||
@ -2,8 +2,7 @@
|
||||
|
||||
void UnitTest::loginSuccessfully()
|
||||
{
|
||||
Data *data = new Data();
|
||||
RequestManager* testAccess = new RequestManager(data);
|
||||
RequestManager* testAccess = new RequestManager();
|
||||
QJsonDocument config = testAccess->getConfig();
|
||||
QSignalSpy spy(testAccess, SIGNAL(successLogin()));
|
||||
testAccess->login(host, email, password);
|
||||
@ -19,8 +18,7 @@ void UnitTest::loginSuccessfully()
|
||||
//POST request w/o datas
|
||||
void UnitTest::getSubjects()
|
||||
{
|
||||
Data *data = new Data();
|
||||
RequestManager* testAccess = new RequestManager(data);
|
||||
RequestManager* testAccess = new RequestManager();
|
||||
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
||||
testAccess->getRequest("/SubjectManager/getSubjects");
|
||||
spy.wait();
|
||||
@ -38,21 +36,25 @@ void UnitTest::getSubjects()
|
||||
|
||||
void UnitTest::getTokens()
|
||||
{
|
||||
Data *data = new Data();
|
||||
RequestManager* testAccess = new RequestManager(data);
|
||||
RequestManager* testAccess = new RequestManager();
|
||||
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
||||
testAccess->getRequest("/TokenManager/getTokens");
|
||||
QCOMPARE(spy.count(), 0);
|
||||
spy.wait();
|
||||
QVERIFY(spy.isValid());
|
||||
QCOMPARE(spy.count(), 1);
|
||||
qDebug() << testAccess->getResponse();
|
||||
QString json = testAccess->getResponse();
|
||||
qDebug() << json;
|
||||
QJsonDocument doc = QJsonDocument::fromJson(json.toUtf8());
|
||||
QVERIFY(doc.isObject());
|
||||
QVERIFY2(doc.object().value("items").isArray(), "No parameter 'id' in response");
|
||||
qDebug() << doc.object().value("items").toArray()[0].toObject()["id"].toString();
|
||||
QVERIFY2(doc.object().value("items").toArray()[0].toObject()["id"].isString(), "ada");
|
||||
}
|
||||
|
||||
void UnitTest::getTokensOpenManager()
|
||||
{
|
||||
Data *data = new Data();
|
||||
RequestManager* testAccess = new RequestManager(data);
|
||||
RequestManager* testAccess = new RequestManager();
|
||||
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
||||
testAccess->getRequest("/OpenManager/getTokenSubject");
|
||||
QCOMPARE(spy.count(), 0);
|
||||
@ -79,12 +81,8 @@ void UnitTest::subjectJSONParser()
|
||||
QJsonObject obj = doc.object();
|
||||
QJsonArray arr = obj["items"].toArray();
|
||||
*/
|
||||
QVERIFY(true);
|
||||
//return;
|
||||
|
||||
|
||||
Data *data = new Data();
|
||||
RequestManager* testAccess = new RequestManager(data);
|
||||
RequestManager* testAccess = new RequestManager();
|
||||
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
||||
testAccess->getRequest("/SubjectManager/getSubjects");
|
||||
spy.wait();
|
||||
@ -99,22 +97,17 @@ void UnitTest::subjectJSONParser()
|
||||
|
||||
void UnitTest::tokenJSONParser()
|
||||
{
|
||||
Data *data = new Data();
|
||||
RequestManager* testAccess = new RequestManager(data);
|
||||
RequestManager* testAccess = new RequestManager();
|
||||
QSignalSpy spy(testAccess, SIGNAL(responseReady()));
|
||||
testAccess->getRequest("/TokenManager/getTokens");
|
||||
spy.wait();
|
||||
QString response = testAccess->getResponse();
|
||||
|
||||
//TODO
|
||||
/* QJsonDocument doc = QJsonDocument::fromJson(response.toUtf8());
|
||||
QJsonDocument doc = QJsonDocument::fromJson(response.toUtf8());
|
||||
QJsonArray arr = doc.object()["items"].toArray();
|
||||
auto testSubject = new Subject();
|
||||
testSubject->fromJSON(arr[1].toObject());
|
||||
qDebug() << testSubject->getName();
|
||||
QVERIFY(!testSubject->getName().isEmpty());*/
|
||||
QVERIFY(true);
|
||||
|
||||
auto testToken = new Token();
|
||||
testToken->fromJSON(arr[5].toObject());
|
||||
qDebug() << testToken->getName() << " Size: " << arr.size();
|
||||
QVERIFY(!testToken->getName().isEmpty());
|
||||
}
|
||||
|
||||
void UnitTest::connectToDB()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user