File indexing completed on 2024-05-12 05:09:53
0001 /*************************************************************************** 0002 Copyright (C) 2023 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 "adsfetchertest.h" 0028 0029 #include "../fetch/adsfetcher.h" 0030 #include "../collections/bibtexcollection.h" 0031 #include "../collectionfactory.h" 0032 #include "../entry.h" 0033 0034 #include <QTest> 0035 0036 QTEST_GUILESS_MAIN( ADSFetcherTest ) 0037 0038 ADSFetcherTest::ADSFetcherTest() : AbstractFetcherTest() { 0039 } 0040 0041 void ADSFetcherTest::initTestCase() { 0042 Tellico::RegisterCollection<Tellico::Data::BibtexCollection> registerBib(Tellico::Data::Collection::Bibtex, "entry"); 0043 } 0044 0045 void ADSFetcherTest::testTitle() { 0046 Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Bibtex, Tellico::Fetch::Title, 0047 "spacecraft architectures for the Terrestrial Planet Finder"); 0048 Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::ADSFetcher(this)); 0049 0050 Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); 0051 0052 QCOMPARE(results.size(), 1); 0053 0054 Tellico::Data::EntryPtr entry = results.at(0); 0055 QCOMPARE(entry->field("title"), "Comparison of structurally connected and separated spacecraft architectures for the Terrestrial Planet Finder"); 0056 QCOMPARE(entry->field("author"), "Stephenson, Robert L.; Miller, David W."); 0057 QCOMPARE(entry->field("entry-type"), "inproceedings"); 0058 QCOMPARE(entry->field("year"), "1998"); 0059 QCOMPARE(entry->field("pages"), "672-682"); 0060 QCOMPARE(entry->field("volume"), "3350"); 0061 QCOMPARE(entry->field("journal"), "Astronomical Interferometry"); 0062 QCOMPARE(entry->field("doi"), "10.1117/12.317131"); 0063 QCOMPARE(entry->field("url"), "https://ui.adsabs.harvard.edu/abs/1998SPIE.3350..672S"); 0064 QVERIFY(!entry->field("abstract").isEmpty()); 0065 } 0066 0067 void ADSFetcherTest::testAuthor() { 0068 Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Bibtex, Tellico::Fetch::Person, 0069 QString::fromUtf8("Miret-Roig, Núria")); 0070 Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::ADSFetcher(this)); 0071 0072 Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); 0073 QCOMPARE(results.size(), 1); 0074 0075 Tellico::Data::EntryPtr entry = results.at(0); 0076 QVERIFY(entry->field("author").contains("Miret-Roig, Núria")); 0077 } 0078 0079 void ADSFetcherTest::testDOI() { 0080 Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Bibtex, Tellico::Fetch::DOI, 0081 QString::fromUtf8("10.1117/12.317131")); 0082 Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::ADSFetcher(this)); 0083 0084 Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); 0085 QCOMPARE(results.size(), 1); 0086 0087 Tellico::Data::EntryPtr entry = results.at(0); 0088 QCOMPARE(entry->field("title"), "Comparison of structurally connected and separated spacecraft architectures for the Terrestrial Planet Finder"); 0089 QCOMPARE(entry->field("author"), "Stephenson, Robert L.; Miller, David W."); 0090 QCOMPARE(entry->field("entry-type"), "inproceedings"); 0091 QCOMPARE(entry->field("year"), "1998"); 0092 QCOMPARE(entry->field("pages"), "672-682"); 0093 QCOMPARE(entry->field("volume"), "3350"); 0094 QCOMPARE(entry->field("journal"), "Astronomical Interferometry"); 0095 QCOMPARE(entry->field("doi"), "10.1117/12.317131"); 0096 QCOMPARE(entry->field("url"), "https://ui.adsabs.harvard.edu/abs/1998SPIE.3350..672S"); 0097 QVERIFY(!entry->field("abstract").isEmpty()); 0098 }