File indexing completed on 2024-05-05 04:55:40

0001 /**
0002  * \file testamazonimporter.cpp
0003  * Test import from Amazon server.
0004  *
0005  * \b Project: Kid3
0006  * \author Urs Fleisch
0007  * \date 11 Feb 2021
0008  *
0009  * Copyright (C) 2021  Urs Fleisch
0010  *
0011  * This file is part of Kid3.
0012  *
0013  * Kid3 is free software; you can redistribute it and/or modify
0014  * it under the terms of the GNU General Public License as published by
0015  * the Free Software Foundation; either version 2 of the License, or
0016  * (at your option) any later version.
0017  *
0018  * Kid3 is distributed in the hope that it will be useful,
0019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0021  * GNU General Public License for more details.
0022  *
0023  * You should have received a copy of the GNU General Public License
0024  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0025  */
0026 
0027 #include "testamazonimporter.h"
0028 #include <QTest>
0029 #include "serverimporter.h"
0030 #include "trackdatamodel.h"
0031 
0032 void TestAmazonImporter::initTestCase()
0033 {
0034   setServerImporter(QLatin1String("AmazonImport"));
0035 }
0036 
0037 void TestAmazonImporter::testQueryAlbums()
0038 {
0039   queryAlbums(QLatin1String("Wizard"), QLatin1String("Odin"));
0040 
0041   AlbumListModel* albumModel = m_importer->getAlbumListModel();
0042   QVERIFY(albumModel->rowCount() > 0);
0043   QString text, category, id;
0044   for (int row = 0; row < albumModel->rowCount(); ++row) {
0045     albumModel->getItem(row, text, category, id);
0046     if (text.contains(QLatin1String("Wizard")) &&
0047         text.contains(QLatin1String("Odin"))) {
0048       break;
0049     }
0050   }
0051   QCOMPARE(text, QString(QLatin1String("Wizard - Odin")));
0052   QCOMPARE(category, QString(QLatin1String("dp")));
0053   QVERIFY(!id.isEmpty());
0054 }
0055 
0056 void TestAmazonImporter::testQueryTracks()
0057 {
0058   queryTracks(QLatin1String("dp"), QLatin1String("B00U1GQ4D0"));
0059 
0060   QStringList titles;
0061   titles << QLatin1String("The Prophecy")
0062          << QLatin1String("Betrayer")
0063          << QLatin1String("Dead Hope")
0064          << QLatin1String("Dark God")
0065          << QLatin1String("Loki S Punishment")
0066          << QLatin1String("Beginning of the End")
0067          << QLatin1String("Thor S Hammer")
0068          << QLatin1String("Hall of Odin")
0069          << QLatin1String("The Powergod")
0070          << QLatin1String("March of the Einheriers")
0071          << QLatin1String("End of All")
0072          << QLatin1String("Ultimate War (Bonus Track)")
0073          << QLatin1String("Golden Dawn (Bonus Track)")
0074          << QLatin1String("Betrayer (video bonus track)");
0075   QCOMPARE(m_trackDataModel->rowCount(), 14);
0076   for (int row = 0; row < 13; ++row) {
0077     QCOMPARE(m_trackDataModel->index(row, 0).data().toString(), "");
0078     QCOMPARE(m_trackDataModel->index(row, 3).data().toInt(), row + 1);
0079     QCOMPARE(m_trackDataModel->index(row, 4).data().toString(), titles.at(row));
0080     QCOMPARE(m_trackDataModel->index(row, 5).data().toString(),
0081              QString(QLatin1String("Wizard")));
0082     QCOMPARE(m_trackDataModel->index(row, 6).data().toString(),
0083              QString(QLatin1String("Odin")));
0084     QCOMPARE(m_trackDataModel->index(row, 7).data().toInt(), 2015);
0085     QCOMPARE(m_trackDataModel->index(row, 8).data().toString(),
0086              QString(QLatin1String("")));
0087     QCOMPARE(m_trackDataModel->index(row, 9).data().toString(),
0088              QString(QLatin1String("")));
0089   }
0090 }