File indexing completed on 2024-05-12 05:10:00
0001 /*************************************************************************** 0002 Copyright (C) 2015 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 "hathitrustfetchertest.h" 0028 0029 #include "../fetch/hathitrustfetcher.h" 0030 #include "../entry.h" 0031 #include "../collections/bookcollection.h" 0032 #include "../collectionfactory.h" 0033 #include "../utils/datafileregistry.h" 0034 0035 #include <QTest> 0036 0037 QTEST_GUILESS_MAIN( HathiTrustFetcherTest ) 0038 0039 HathiTrustFetcherTest::HathiTrustFetcherTest() : AbstractFetcherTest() { 0040 } 0041 0042 void HathiTrustFetcherTest::initTestCase() { 0043 Tellico::RegisterCollection<Tellico::Data::BookCollection> registerBook(Tellico::Data::Collection::Book, "book"); 0044 Tellico::DataFileRegistry::self()->addDataLocation(QFINDTESTDATA("../../xslt/MARC21slim2MODS3.xsl")); 0045 } 0046 0047 void HathiTrustFetcherTest::testIsbn() { 0048 Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Book, Tellico::Fetch::ISBN, 0049 QStringLiteral("1931561567")); 0050 Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::HathiTrustFetcher(this)); 0051 0052 Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); 0053 0054 QCOMPARE(results.size(), 1); 0055 0056 Tellico::Data::EntryPtr entry = results.at(0); 0057 QVERIFY(entry); 0058 compareEntry(entry); 0059 } 0060 0061 void HathiTrustFetcherTest::testLccn() { 0062 Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Book, Tellico::Fetch::LCCN, 0063 QStringLiteral("2003019402")); 0064 Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::HathiTrustFetcher(this)); 0065 0066 Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); 0067 0068 QCOMPARE(results.size(), 1); 0069 0070 Tellico::Data::EntryPtr entry = results.at(0); 0071 QVERIFY(entry); 0072 compareEntry(entry); 0073 } 0074 0075 void HathiTrustFetcherTest::compareEntry(Tellico::Data::EntryPtr entry) { 0076 QCOMPARE(entry->field(QStringLiteral("title")), QStringLiteral("The forgotten genius")); 0077 QCOMPARE(entry->field(QStringLiteral("subtitle")), QStringLiteral("the biography of Robert Hooke 1635-1703")); 0078 QCOMPARE(entry->field(QStringLiteral("isbn")), QStringLiteral("1-931561-56-7")); 0079 QCOMPARE(entry->field(QStringLiteral("lccn")), QStringLiteral("2003019402")); 0080 QCOMPARE(entry->field(QStringLiteral("author")), QStringLiteral("Inwood, Stephen")); 0081 QCOMPARE(entry->field(QStringLiteral("publisher")), QStringLiteral("MacAdam/Cage Pub.")); 0082 QCOMPARE(entry->field(QStringLiteral("pub_year")), QStringLiteral("2003")); 0083 QCOMPARE(entry->field(QStringLiteral("genre")), QStringLiteral("bibliography; biography")); 0084 QVERIFY(entry->field(QStringLiteral("keyword")).contains(QStringLiteral("Architecture"))); 0085 QVERIFY(entry->field(QStringLiteral("keyword")).contains(QStringLiteral("history"))); 0086 QVERIFY(entry->field(QStringLiteral("comments")).contains(QStringLiteral("London"))); 0087 }