-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathfederationtooltest.cpp
48 lines (40 loc) · 2.28 KB
/
federationtooltest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// SPDX-FileCopyrightText: 2023 Rishi Kumar <[email protected]>
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "account/accountmanager.h"
#include "admin/federationtoolmodel.h"
#include "autotests/helperreply.h"
#include "autotests/mockaccount.h"
#include <QtTest/QtTest>
class FederationToolTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase()
{
AccountManager::instance().setTestMode(true);
account = new MockAccount();
AccountManager::instance().addAccount(account);
}
void testModel()
{
QUrl url = account->apiUrl(QStringLiteral("/api/v1/admin/domain_blocks"));
account->registerGet(url, new TestReply(QStringLiteral("federation-info.json"), account));
FederationToolModel federationToolModel;
QCOMPARE(federationToolModel.rowCount({}), 2);
QCOMPARE(federationToolModel.data(federationToolModel.index(0, 0), FederationToolModel::IdRole).toInt(), 1);
QCOMPARE(federationToolModel.data(federationToolModel.index(0, 0), FederationToolModel::DomainRole).toUrl(), QUrl(QStringLiteral("kde.org")));
Q_ASSERT(federationToolModel.data(federationToolModel.index(0, 0), FederationToolModel::CreatedAtRole).isValid());
QCOMPARE(federationToolModel.data(federationToolModel.index(0, 0), FederationToolModel::SeverityRole).toString(), QStringLiteral("silence"));
QCOMPARE(federationToolModel.data(federationToolModel.index(0, 0), FederationToolModel::RejectMediaRole).toBool(), false);
QCOMPARE(federationToolModel.data(federationToolModel.index(0, 0), FederationToolModel::RejectReportsRole).toBool(), false);
QCOMPARE(federationToolModel.data(federationToolModel.index(0, 0), FederationToolModel::PrivateCommentRole).toString(),
QStringLiteral("This is a private comment"));
QCOMPARE(federationToolModel.data(federationToolModel.index(0, 0), FederationToolModel::PublicCommentRole).toString(),
QStringLiteral("This is a public comment"));
QCOMPARE(federationToolModel.data(federationToolModel.index(0, 0), FederationToolModel::ObfuscateRole).toBool(), false);
}
private:
MockAccount *account = nullptr;
};
QTEST_MAIN(FederationToolTest)
#include "federationtooltest.moc"