File indexing completed on 2025-02-02 04:51:32

0001 /*
0002    SPDX-FileCopyrightText: 2018-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "statisticsjobtest.h"
0008 #include "misc/statisticsjob.h"
0009 #include "restapimethod.h"
0010 #include "ruqola_restapi_helper.h"
0011 QTEST_GUILESS_MAIN(StatisticsJobTest)
0012 using namespace RocketChatRestApi;
0013 StatisticsJobTest::StatisticsJobTest(QObject *parent)
0014     : QObject(parent)
0015 {
0016 }
0017 
0018 void StatisticsJobTest::shouldHaveDefaultValue()
0019 {
0020     StatisticsJob job;
0021     verifyDefaultValue(&job);
0022     QVERIFY(job.requireHttpAuthentication());
0023     QVERIFY(!job.hasQueryParameterSupport());
0024     QVERIFY(!job.refresh());
0025     QVERIFY(!job.requireTwoFactorAuthentication());
0026 }
0027 
0028 void StatisticsJobTest::shouldGenerateRequest()
0029 {
0030     StatisticsJob job;
0031     {
0032         QNetworkRequest request = QNetworkRequest(QUrl());
0033         verifyAuthentication(&job, request);
0034         QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/statistics?refresh=false")));
0035     }
0036     {
0037         job.setRefresh(true);
0038         QNetworkRequest request = QNetworkRequest(QUrl());
0039         verifyAuthentication(&job, request);
0040         QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/statistics?refresh=true")));
0041     }
0042 }
0043 
0044 #include "moc_statisticsjobtest.cpp"