diff --git a/src/tests/moviemeterfetchertest.cpp b/src/tests/moviemeterfetchertest.cpp index 4f98c91a..2d982a9d 100644 --- a/src/tests/moviemeterfetchertest.cpp +++ b/src/tests/moviemeterfetchertest.cpp @@ -1,96 +1,96 @@ /*************************************************************************** Copyright (C) 2011 Robby Stephenson ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * * published by the Free Software Foundation; either version 2 of * * the License or (at your option) version 3 or any later version * * accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy * * defined in Section 14 of version 3 of the license. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * ***************************************************************************/ #undef QT_NO_CAST_FROM_ASCII #include "moviemeterfetchertest.h" #include "../fetch/moviemeterfetcher.h" #include "../collections/videocollection.h" #include "../collectionfactory.h" #include "../entry.h" #include "../images/imagefactory.h" #include QTEST_GUILESS_MAIN( MovieMeterFetcherTest ) MovieMeterFetcherTest::MovieMeterFetcherTest() : AbstractFetcherTest() { } void MovieMeterFetcherTest::initTestCase() { Tellico::RegisterCollection registerVideo(Tellico::Data::Collection::Video, "video"); Tellico::ImageFactory::init(); m_fieldValues.insert(QStringLiteral("title"), QStringLiteral("Man from Snowy River, The")); m_fieldValues.insert(QStringLiteral("year"), QStringLiteral("1982")); - m_fieldValues.insert(QStringLiteral("director"), QStringLiteral("George Miller")); +// m_fieldValues.insert(QStringLiteral("director"), QStringLiteral("George Miller")); m_fieldValues.insert(QStringLiteral("running-time"), QStringLiteral("102")); m_fieldValues.insert(QStringLiteral("genre"), QStringLiteral("Western")); m_fieldValues.insert(QStringLiteral("nationality"), QStringLiteral("Australië")); } void MovieMeterFetcherTest::testKeyword() { Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Video, Tellico::Fetch::Keyword, QStringLiteral("Man From Snowy River")); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::MovieMeterFetcher(this)); Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 2); QCOMPARE(results.size(), 2); Tellico::Data::EntryPtr entry = results.at(0); QVERIFY(entry); QHashIterator i(m_fieldValues); while(i.hasNext()) { i.next(); QString result = entry->field(i.key()).toLower(); QCOMPARE(result, i.value().toLower()); } QStringList castList = Tellico::FieldFormat::splitTable(entry->field(QStringLiteral("cast"))); QVERIFY(!castList.isEmpty()); QCOMPARE(castList.at(0), QStringLiteral("Tom Burlinson")); QVERIFY(!entry->field(QStringLiteral("cover")).isEmpty()); QVERIFY(!entry->field(QStringLiteral("cover")).contains(QLatin1Char('/'))); QVERIFY(!entry->field(QStringLiteral("plot")).isEmpty()); } void MovieMeterFetcherTest::testKeywordCzech() { // QString tmav = QString::fromUtf8("Tmavomodrý Svět"); QString tmav = QStringLiteral("Tmavomodrý Svet"); // QString tmav = QString::fromUtf8("Tmavomodrý svet"); Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Video, Tellico::Fetch::Keyword, tmav); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::MovieMeterFetcher(this)); Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 2); QCOMPARE(results.size(), 1); Tellico::Data::EntryPtr entry = results.at(0); QVERIFY(entry); QCOMPARE(entry->title(), tmav); } diff --git a/src/tests/mrlookupfetchertest.cpp b/src/tests/mrlookupfetchertest.cpp index e2bf19df..6714e864 100644 --- a/src/tests/mrlookupfetchertest.cpp +++ b/src/tests/mrlookupfetchertest.cpp @@ -1,97 +1,97 @@ /*************************************************************************** Copyright (C) 2014 Robby Stephenson ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * * published by the Free Software Foundation; either version 2 of * * the License or (at your option) version 3 or any later version * * accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy * * defined in Section 14 of version 3 of the license. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * ***************************************************************************/ #undef QT_NO_CAST_FROM_ASCII #include "mrlookupfetchertest.h" #include "../fetch/mrlookupfetcher.h" #include "../entry.h" #include "../utils/datafileregistry.h" #include QTEST_GUILESS_MAIN( MRLookupFetcherTest ) MRLookupFetcherTest::MRLookupFetcherTest() : AbstractFetcherTest() { } void MRLookupFetcherTest::initTestCase() { // since we use the bibtex importer Tellico::DataFileRegistry::self()->addDataLocation(QFINDTESTDATA("../translators/bibtex-translation.xml")); m_fieldValues.insert(QStringLiteral("doi"), QStringLiteral("10.4169/amer.math.monthly.121.10.917")); - m_fieldValues.insert(QStringLiteral("title"), QStringLiteral("An unnoticed consequence of Szeg\\\"o's distribution theorem")); + m_fieldValues.insert(QStringLiteral("title"), QStringLiteral("An unnoticed consequence of Szegö's distribution theorem")); m_fieldValues.insert(QStringLiteral("author"), QStringLiteral("Trench, William F.")); m_fieldValues.insert(QStringLiteral("volume"), QStringLiteral("121")); m_fieldValues.insert(QStringLiteral("journal"), QStringLiteral("American Mathematical Monthly")); m_fieldValues.insert(QStringLiteral("number"), QStringLiteral("10")); m_fieldValues.insert(QStringLiteral("year"), QStringLiteral("2014")); m_fieldValues.insert(QStringLiteral("pages"), QStringLiteral("917–921")); m_fieldValues.insert(QStringLiteral("entry-type"), QStringLiteral("article")); } void MRLookupFetcherTest::testTitle() { Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Bibtex, Tellico::Fetch::Title, QLatin1String("An unnoticed consequence of Szego's distribution theorem")); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::MRLookupFetcher(this)); Tellico::Data::EntryList results = DO_FETCH(fetcher, request); QVERIFY(!results.isEmpty()); Tellico::Data::EntryPtr entry = results.at(0); QHashIterator i(m_fieldValues); while(i.hasNext()) { i.next(); QCOMPARE(entry->field(i.key()), i.value()); } } void MRLookupFetcherTest::testAuthor() { Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Bibtex, Tellico::Fetch::Person, QStringLiteral("Trench, William")); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::MRLookupFetcher(this)); Tellico::Data::EntryList results = DO_FETCH(fetcher, request); QVERIFY(!results.isEmpty()); Tellico::Data::EntryPtr entry; foreach(Tellico::Data::EntryPtr test, results) { if(test->title().toLower() == m_fieldValues.value(QStringLiteral("title")).toLower()) { entry = test; break; } else { qDebug() << "Skipping" << test->title(); } } QVERIFY(entry); QHashIterator i(m_fieldValues); while(i.hasNext()) { i.next(); QCOMPARE(entry->field(i.key()), i.value()); } } diff --git a/src/tests/srufetchertest.cpp b/src/tests/srufetchertest.cpp index 9a87447c..7b3500e5 100644 --- a/src/tests/srufetchertest.cpp +++ b/src/tests/srufetchertest.cpp @@ -1,166 +1,166 @@ /*************************************************************************** Copyright (C) 2009-2011 Robby Stephenson ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * * published by the Free Software Foundation; either version 2 of * * the License or (at your option) version 3 or any later version * * accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy * * defined in Section 14 of version 3 of the license. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * ***************************************************************************/ #undef QT_NO_CAST_FROM_ASCII #include "srufetchertest.h" #include "../fetch/srufetcher.h" #include "../collections/bookcollection.h" #include "../collections/bibtexcollection.h" #include "../collectionfactory.h" #include "../entry.h" #include "../utils/datafileregistry.h" #include #include #include QTEST_GUILESS_MAIN( SRUFetcherTest ) SRUFetcherTest::SRUFetcherTest() : AbstractFetcherTest() { } void SRUFetcherTest::initTestCase() { Tellico::RegisterCollection registerBook(Tellico::Data::Collection::Book, "book"); Tellico::RegisterCollection registerBibtex(Tellico::Data::Collection::Bibtex, "bibtex"); // since we use the MODS importer Tellico::DataFileRegistry::self()->addDataLocation(QFINDTESTDATA("../../xslt/mods2tellico.xsl")); } void SRUFetcherTest::testTitle() { Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Book, Tellico::Fetch::Title, QStringLiteral("Foundations of Qt Development")); Tellico::Fetch::Fetcher::Ptr fetcher = Tellico::Fetch::SRUFetcher::libraryOfCongress(this); Tellico::Data::EntryList results = DO_FETCH(fetcher, request); QCOMPARE(results.size(), 1); Tellico::Data::EntryPtr entry = results.at(0); QCOMPARE(entry->field(QStringLiteral("title")), QStringLiteral("Foundations of Qt development")); QCOMPARE(entry->field(QStringLiteral("author")), QStringLiteral("Thelin, Johan.")); QCOMPARE(entry->field(QStringLiteral("isbn")), QStringLiteral("1-59059-831-8")); } void SRUFetcherTest::testIsbn() { // also testing multiple values Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Book, Tellico::Fetch::ISBN, QStringLiteral("978-1-59059-831-3; 0-201-88954-4")); Tellico::Fetch::Fetcher::Ptr fetcher = Tellico::Fetch::SRUFetcher::libraryOfCongress(this); Tellico::Data::EntryList results = DO_FETCH(fetcher, request); QCOMPARE(results.size(), 2); Tellico::Data::EntryPtr entry = results.at(1); QCOMPARE(entry->field(QStringLiteral("title")), QStringLiteral("Foundations of Qt development")); QCOMPARE(entry->field(QStringLiteral("author")), QStringLiteral("Thelin, Johan.")); QCOMPARE(entry->field(QStringLiteral("isbn")), QStringLiteral("1-59059-831-8")); } // see http://raoulm.home.xs4all.nl/mcq.htm void SRUFetcherTest::testKBTitle() { KConfig config(QFINDTESTDATA("tellicotest.config"), KConfig::SimpleConfig); QString groupName = QStringLiteral("KB"); if(!config.hasGroup(groupName)) { QSKIP("This test requires a config file.", SkipAll); } KConfigGroup cg(&config, groupName); Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Bibtex, Tellico::Fetch::Title, QStringLiteral("Godfried Bomans: Erik of het klein insectenboek")); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::SRUFetcher(this)); fetcher->readConfig(cg, cg.name()); - Tellico::Data::EntryList results = DO_FETCH(fetcher, request); + Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); QCOMPARE(results.size(), 1); Tellico::Data::EntryPtr entry = results.at(0); QCOMPARE(entry->field(QStringLiteral("title")), QStringLiteral("Godfried Bomans: Erik of het klein insectenboek")); // QCOMPARE(entry->field(QStringLiteral("author")), QStringLiteral("No Author")); QCOMPARE(entry->field(QStringLiteral("entry-type")), QStringLiteral("book")); QCOMPARE(entry->field(QStringLiteral("publisher")), QStringLiteral("Purmerend : Muusses")); QCOMPARE(entry->field(QStringLiteral("isbn")), QStringLiteral("9023117042")); QCOMPARE(entry->field(QStringLiteral("year")), QStringLiteral("1971")); QVERIFY(!entry->field(QStringLiteral("url")).isEmpty()); } // see http://raoulm.home.xs4all.nl/mcq.htm void SRUFetcherTest::testKBIsbn() { KConfig config(QFINDTESTDATA("tellicotest.config"), KConfig::SimpleConfig); QString groupName = QStringLiteral("KB"); if(!config.hasGroup(groupName)) { QSKIP("This test requires a config file.", SkipAll); } KConfigGroup cg(&config, groupName); Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Bibtex, Tellico::Fetch::ISBN, QStringLiteral("9023117042")); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::SRUFetcher(this)); fetcher->readConfig(cg, cg.name()); Tellico::Data::EntryList results = DO_FETCH(fetcher, request); // for whatever reason, there are two results with the same isbn and we want the second QCOMPARE(results.size(), 2); Tellico::Data::EntryPtr entry = results.at(1); QCOMPARE(entry->field(QStringLiteral("title")), QStringLiteral("Godfried Bomans: Erik of het klein insectenboek")); QCOMPARE(entry->field(QStringLiteral("entry-type")), QStringLiteral("book")); QCOMPARE(entry->field(QStringLiteral("publisher")), QStringLiteral("Purmerend : Muusses")); QCOMPARE(entry->field(QStringLiteral("isbn")), QStringLiteral("9023117042")); QCOMPARE(entry->field(QStringLiteral("year")), QStringLiteral("1971")); QVERIFY(!entry->field(QStringLiteral("url")).isEmpty()); } void SRUFetcherTest::testCopacIsbn() { KConfig config(QFINDTESTDATA("tellicotest.config"), KConfig::SimpleConfig); QString groupName = QStringLiteral("Copac"); if(!config.hasGroup(groupName)) { QSKIP("This test requires a config file.", SkipAll); } KConfigGroup cg(&config, groupName); Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Bibtex, Tellico::Fetch::ISBN, QStringLiteral("1430202513")); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::SRUFetcher(this)); fetcher->readConfig(cg, cg.name()); Tellico::Data::EntryList results = DO_FETCH(fetcher, request); QCOMPARE(results.size(), 1); Tellico::Data::EntryPtr entry = results.at(0); QCOMPARE(entry->field(QStringLiteral("title")), QStringLiteral("Foundations of Qt development")); QCOMPARE(entry->field(QStringLiteral("author")), QStringLiteral("Thelin, Johan.")); // the mods2tellico.xsl file returns the last ISBN value in the response, which is different in this case. Ignore for now // QCOMPARE(entry->field(QStringLiteral("isbn")), QStringLiteral("1-43020-251-3")); QCOMPARE(entry->field(QStringLiteral("lcc")), QStringLiteral("QA76.6 .T4457 2007eb")); QCOMPARE(entry->field(QStringLiteral("doi")), QStringLiteral("10.1007/978-1-4302-0251-6")); QCOMPARE(entry->field(QStringLiteral("pub_year")), QStringLiteral("2007")); QVERIFY(entry->field(QStringLiteral("publisher")).contains(QStringLiteral("Apress"))); } diff --git a/src/tests/themoviedbfetchertest.cpp b/src/tests/themoviedbfetchertest.cpp index 737f8746..86fd11a9 100644 --- a/src/tests/themoviedbfetchertest.cpp +++ b/src/tests/themoviedbfetchertest.cpp @@ -1,132 +1,132 @@ /*************************************************************************** Copyright (C) 2010-2011 Robby Stephenson ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * * published by the Free Software Foundation; either version 2 of * * the License or (at your option) version 3 or any later version * * accepted by the membership of KDE e.V. (or its successor approved * * by the membership of KDE e.V.), which shall act as a proxy * * defined in Section 14 of version 3 of the license. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * * * ***************************************************************************/ #undef QT_NO_CAST_FROM_ASCII #include "themoviedbfetchertest.h" #include "../fetch/themoviedbfetcher.h" #include "../collections/videocollection.h" #include "../entry.h" #include "../images/imagefactory.h" #include #include #include QTEST_GUILESS_MAIN( TheMovieDBFetcherTest ) TheMovieDBFetcherTest::TheMovieDBFetcherTest() : AbstractFetcherTest() { } void TheMovieDBFetcherTest::initTestCase() { Tellico::ImageFactory::init(); m_fieldValues.insert(QStringLiteral("title"), QStringLiteral("Superman Returns")); - m_fieldValues.insert(QStringLiteral("studio"), QStringLiteral("Warner Bros. Pictures; DC Entertainment; Red Sun Productions Pty. Ltd.; " + m_fieldValues.insert(QStringLiteral("studio"), QStringLiteral("Warner Bros. Pictures; Red Sun Productions Pty. Ltd.; " "Peters Entertainment; DC Comics; Legendary Entertainment; " "Bad Hat Harry Productions")); m_fieldValues.insert(QStringLiteral("year"), QStringLiteral("2006")); m_fieldValues.insert(QStringLiteral("genre"), QStringLiteral("action; adventure; science fiction")); m_fieldValues.insert(QStringLiteral("director"), QStringLiteral("Bryan Singer")); m_fieldValues.insert(QStringLiteral("producer"), QStringLiteral("Bryan Singer; Jon Peters; Gilbert Adler")); m_fieldValues.insert(QStringLiteral("running-time"), QStringLiteral("154")); m_fieldValues.insert(QStringLiteral("nationality"), QStringLiteral("USA")); } void TheMovieDBFetcherTest::testTitle() { Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Video, Tellico::Fetch::Title, QStringLiteral("superman returns")); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::TheMovieDBFetcher(this)); Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); QCOMPARE(results.size(), 1); Tellico::Data::EntryPtr entry = results.at(0); QHashIterator i(m_fieldValues); while(i.hasNext()) { i.next(); QString result = entry->field(i.key()).toLower(); QCOMPARE(set(result), set(i.value().toLower())); } QStringList castList = Tellico::FieldFormat::splitTable(entry->field(QStringLiteral("cast"))); QVERIFY(!castList.isEmpty()); QCOMPARE(castList.at(0), QStringLiteral("Brandon Routh::Superman / Clark Kent")); QVERIFY(!entry->field(QStringLiteral("cover")).isEmpty()); QVERIFY(!entry->field(QStringLiteral("cover")).contains(QLatin1Char('/'))); QVERIFY(!entry->field(QStringLiteral("plot")).isEmpty()); } void TheMovieDBFetcherTest::testTitleFr() { KConfig config(QFINDTESTDATA("tellicotest.config"), KConfig::SimpleConfig); QString groupName = QStringLiteral("TMDB FR"); if(!config.hasGroup(groupName)) { QSKIP("This test requires a config file.", SkipAll); } KConfigGroup cg(&config, groupName); Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Video, Tellico::Fetch::Title, QStringLiteral("superman returns")); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::TheMovieDBFetcher(this)); fetcher->readConfig(cg, cg.name()); Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); QCOMPARE(results.size(), 1); Tellico::Data::EntryPtr entry = results.at(0); QStringList fields = QStringList() << QStringLiteral("title") << QStringLiteral("studio") << QStringLiteral("year") << QStringLiteral("title"); foreach(const QString& field, fields) { QString result = entry->field(field).toLower(); QCOMPARE(set(result), set(m_fieldValues.value(field).toLower())); } QStringList castList = Tellico::FieldFormat::splitTable(entry->field(QStringLiteral("cast"))); QVERIFY(!castList.isEmpty()); QCOMPARE(castList.at(0), QStringLiteral("Brandon Routh::Superman / Clark Kent")); QVERIFY(!entry->field(QStringLiteral("cover")).isEmpty()); QVERIFY(!entry->field(QStringLiteral("cover")).contains(QLatin1Char('/'))); QVERIFY(!entry->field(QStringLiteral("plot")).isEmpty()); } // see https://bugs.kde.org/show_bug.cgi?id=336765 void TheMovieDBFetcherTest::testBabel() { Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Video, Tellico::Fetch::Title, QStringLiteral("babel")); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::TheMovieDBFetcher(this)); Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); QCOMPARE(results.size(), 1); Tellico::Data::EntryPtr entry = results.at(0); QCOMPARE(entry->field("title"), QStringLiteral("Babel")); QCOMPARE(entry->field("year"), QStringLiteral("2006")); QCOMPARE(set(entry, "director"), set(QString::fromUtf8("Alejandro González Iñárritu"))); QCOMPARE(set(entry, "producer"), set(QString::fromUtf8("Alejandro González Iñárritu; Steve Golin; Jon Kilik; Ann Ruark; Corinne Golden Weber"))); }