File indexing completed on 2024-05-12 05:09:54
0001 /*************************************************************************** 0002 Copyright (C) 2011 Robby Stephenson <robby@periapsis.org> 0003 ***************************************************************************/ 0004 0005 /*************************************************************************** 0006 * * 0007 * This program is free software; you can redistribute it and/or * 0008 * modify it under the terms of the GNU General Public License as * 0009 * published by the Free Software Foundation; either version 2 of * 0010 * the License or (at your option) version 3 or any later version * 0011 * accepted by the membership of KDE e.V. (or its successor approved * 0012 * by the membership of KDE e.V.), which shall act as a proxy * 0013 * defined in Section 14 of version 3 of the license. * 0014 * * 0015 * This program is distributed in the hope that it will be useful, * 0016 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0018 * GNU General Public License for more details. * 0019 * * 0020 * You should have received a copy of the GNU General Public License * 0021 * along with this program. If not, see <http://www.gnu.org/licenses/>. * 0022 * * 0023 ***************************************************************************/ 0024 0025 #undef QT_NO_CAST_FROM_ASCII 0026 0027 #include "bibliosharefetchertest.h" 0028 0029 #include "../fetch/bibliosharefetcher.h" 0030 #include "../entry.h" 0031 #include "../collections/bookcollection.h" 0032 #include "../collectionfactory.h" 0033 #include "../images/imagefactory.h" 0034 #include "../utils/datafileregistry.h" 0035 0036 #include <QTest> 0037 0038 QTEST_GUILESS_MAIN( BiblioShareFetcherTest ) 0039 0040 BiblioShareFetcherTest::BiblioShareFetcherTest() : AbstractFetcherTest() { 0041 } 0042 0043 void BiblioShareFetcherTest::initTestCase() { 0044 Tellico::ImageFactory::init(); 0045 Tellico::RegisterCollection<Tellico::Data::BookCollection> registerBook(Tellico::Data::Collection::Book, "book"); 0046 // since we use the importer 0047 Tellico::DataFileRegistry::self()->addDataLocation(QFINDTESTDATA("../../xslt/biblioshare2tellico.xsl")); 0048 } 0049 0050 void BiblioShareFetcherTest::testIsbn() { 0051 Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Book, Tellico::Fetch::ISBN, 0052 QStringLiteral("0670069035")); 0053 Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::BiblioShareFetcher(this)); 0054 0055 Tellico::Data::EntryList results = DO_FETCH(fetcher, request); 0056 0057 QCOMPARE(results.size(), 1); 0058 0059 Tellico::Data::EntryPtr entry = results.at(0); 0060 QCOMPARE(entry->field(QStringLiteral("title")), QStringLiteral("The Girl Who Kicked the Hornet's Nest")); 0061 QCOMPARE(entry->field(QStringLiteral("author")), QStringLiteral("Stieg Larsson")); 0062 QCOMPARE(entry->field(QStringLiteral("binding")), QStringLiteral("Hardback")); 0063 QCOMPARE(entry->field(QStringLiteral("isbn")), QStringLiteral("0-670-06903-5")); 0064 QCOMPARE(entry->field(QStringLiteral("pub_year")), QStringLiteral("2010")); 0065 QCOMPARE(entry->field(QStringLiteral("publisher")), QStringLiteral("Penguin Canada")); 0066 QVERIFY(!entry->field(QStringLiteral("cover")).isEmpty()); 0067 QVERIFY(!entry->field(QStringLiteral("cover")).contains(QLatin1Char('/'))); 0068 } 0069 0070 void BiblioShareFetcherTest::testIsbn13() { 0071 Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Book, Tellico::Fetch::ISBN, 0072 QStringLiteral("9780670069033")); 0073 Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::BiblioShareFetcher(this)); 0074 0075 Tellico::Data::EntryList results = DO_FETCH(fetcher, request); 0076 0077 QCOMPARE(results.size(), 1); 0078 0079 Tellico::Data::EntryPtr entry = results.at(0); 0080 QCOMPARE(entry->field(QStringLiteral("title")), QStringLiteral("The Girl Who Kicked the Hornet's Nest")); 0081 QCOMPARE(entry->field(QStringLiteral("author")), QStringLiteral("Stieg Larsson")); 0082 QCOMPARE(entry->field(QStringLiteral("binding")), QStringLiteral("Hardback")); 0083 QCOMPARE(entry->field(QStringLiteral("isbn")), QStringLiteral("0-670-06903-5")); 0084 QCOMPARE(entry->field(QStringLiteral("pub_year")), QStringLiteral("2010")); 0085 QCOMPARE(entry->field(QStringLiteral("publisher")), QStringLiteral("Penguin Canada")); 0086 QVERIFY(!entry->field(QStringLiteral("cover")).isEmpty()); 0087 QVERIFY(!entry->field(QStringLiteral("cover")).contains(QLatin1Char('/'))); 0088 }