-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathemailblocktooltest.cpp
42 lines (34 loc) · 1.62 KB
/
emailblocktooltest.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
// SPDX-FileCopyrightText: 2023 Rishi Kumar <rsi.dev17@gmail.com>
// SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "account/accountmanager.h"
#include "admin/emailblocktoolmodel.h"
#include "autotests/helperreply.h"
#include "autotests/mockaccount.h"
#include <QtTest/QtTest>
class IpRulesToolTest : 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/email_domain_blocks"));
account->registerGet(url, new TestReply(QStringLiteral("email-info.json"), account));
EmailBlockToolModel emailBlockToolModel;
QCOMPARE(emailBlockToolModel.rowCount({}), 2);
QCOMPARE(emailBlockToolModel.data(emailBlockToolModel.index(0, 0), EmailBlockToolModel::IdRole).toInt(), 2);
QCOMPARE(emailBlockToolModel.data(emailBlockToolModel.index(0, 0), EmailBlockToolModel::DomainRole).toString(), QStringLiteral("kde.org"));
Q_ASSERT(emailBlockToolModel.data(emailBlockToolModel.index(0, 0), EmailBlockToolModel::CreatedAtRole).isValid());
QCOMPARE(emailBlockToolModel.data(emailBlockToolModel.index(0, 0), EmailBlockToolModel::AccountSignUpCount).toInt(), 112);
QCOMPARE(emailBlockToolModel.data(emailBlockToolModel.index(0, 0), EmailBlockToolModel::IpSignUpCount).toInt(), 255);
}
private:
MockAccount *account = nullptr;
};
QTEST_MAIN(IpRulesToolTest)
#include "emailblocktooltest.moc"