File indexing completed on 2024-05-12 05:22:08

0001 /*
0002  * SPDX-FileCopyrightText: 2018 Daniel Vrátil <dvratil@kde.org>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005  */
0006 
0007 #include "taskstestutils.h"
0008 #include "tasksservice.h"
0009 #include "testutils.h"
0010 
0011 #include <QFile>
0012 
0013 KGAPI2::TaskPtr taskFromFile(const QString &path)
0014 {
0015     QFile f(path);
0016     VERIFY_RET(f.open(QIODevice::ReadOnly), {});
0017 
0018     auto task = KGAPI2::TasksService::JSONToTask(f.readAll());
0019     VERIFY_RET(task, {});
0020     return task;
0021 }
0022 
0023 KGAPI2::TaskListPtr taskListFromFile(const QString &path)
0024 {
0025     QFile f(path);
0026     VERIFY_RET(f.open(QIODevice::ReadOnly), {});
0027 
0028     auto taskList = KGAPI2::TasksService::JSONToTaskList(f.readAll());
0029     VERIFY_RET(taskList, {});
0030     return taskList;
0031 }