void AnimenfoFetcherTest::testGhost() { KConfig config(QFINDTESTDATA("tellicotest.config"), KConfig::SimpleConfig); QString groupName = QLatin1String("AnimeNfo.com"); if(!config.hasGroup(groupName)) { QSKIP("This test requires a config file.", SkipAll); } KConfigGroup cg(&config, groupName); Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Book, Tellico::Fetch::Keyword, "Ghost in the Shell"); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::AnimeNfoFetcher(this)); fetcher->readConfig(cg, cg.name()); Tellico::Data::EntryList results = DO_FETCH(fetcher, request); QCOMPARE(results.size(), 1); // the first entry had better be the right one Tellico::Data::EntryPtr entry = results.at(0); QVERIFY(entry); QCOMPARE(entry->field("title"), QLatin1String("Kokaku Kido Tai")); QCOMPARE(entry->field("pub_year"), QLatin1String("1991")); QCOMPARE(entry->field("genre"), QLatin1String("Action; Science-Fiction")); QCOMPARE(entry->field("publisher"), QLatin1String("Kodansha")); QCOMPARE(entry->field("origtitle"), QString::fromUtf8("攻殻機動隊")); QCOMPARE(entry->field("author"), QString::fromUtf8("Shiro Masamune (士郎 正宗)")); QCOMPARE(entry->field("alttitle"), QLatin1String("Ghost in the Shell")); QVERIFY(!entry->field("cover").isEmpty()); QVERIFY(!entry->field("animenfo").isEmpty()); }
void AnimenfoFetcherTest::testMegami() { KConfig config(QFINDTESTDATA("tellicotest.config"), KConfig::SimpleConfig); QString groupName = QLatin1String("AnimeNfo.com"); 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::Keyword, "Aa! Megami-sama!"); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::AnimeNfoFetcher(this)); fetcher->readConfig(cg, cg.name()); Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); QCOMPARE(results.size(), 1); // the first entry had better be the right one Tellico::Data::EntryPtr entry = results.at(0); QVERIFY(entry); QCOMPARE(entry->field("title"), QLatin1String("Aa! Megami-sama!: Together Forever")); QCOMPARE(entry->field("year"), QLatin1String("2011")); QCOMPARE(entry->field("episodes"), QLatin1String("2")); QCOMPARE(entry->field("studio"), QLatin1String("AIC (Anime International Company)")); QCOMPARE(entry->field("origtitle"), QString::fromUtf8("ああっ女神さまっ ~ いつも二人で")); QVERIFY(entry->field("plot").startsWith(QLatin1String("Keiichi finds out"))); QVERIFY(!entry->field("cover").isEmpty()); }
void MusicBrainzFetcherTest::testPerson() { Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Album, Tellico::Fetch::Person, m_fieldValues.value(QLatin1String("artist"))); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::MusicBrainzFetcher(this)); Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 20); QVERIFY(results.size() > 0); Tellico::Data::EntryPtr entry; // results can be randomly ordered, loop until we find the one we want foreach(Tellico::Data::EntryPtr test, results) { if(test->field(QLatin1String("title")).toLower() == m_fieldValues.value(QLatin1String("title"))) { entry = test; break; } else { qDebug() << "skipping" << test->title(); } } QVERIFY(entry); QHashIterator<QString, QString> i(m_fieldValues); while(i.hasNext()) { i.next(); QString result = entry->field(i.key()).toLower(); QCOMPARE(result, i.value().toLower()); } QVERIFY(!entry->field(QLatin1String("track")).isEmpty()); QVERIFY(!entry->field(QLatin1String("cover")).isEmpty()); }
void GoogleBookFetcherTest::testKeyword() { Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Book, Tellico::Fetch::Keyword, QLatin1String("Practical Rdf")); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::GoogleBookFetcher(this)); if(m_hasConfigFile) { KConfigGroup cg(&m_config, QLatin1String("GoogleBookTest")); fetcher->readConfig(cg, cg.name()); } Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); QCOMPARE(results.size(), 1); compareEntry(results.at(0)); }
void MusicBrainzFetcherTest::testTitle() { Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Album, Tellico::Fetch::Title, m_fieldValues.value(QLatin1String("title"))); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::MusicBrainzFetcher(this)); Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); QCOMPARE(results.size(), 1); Tellico::Data::EntryPtr entry = results.at(0); QHashIterator<QString, QString> i(m_fieldValues); while(i.hasNext()) { i.next(); QString result = entry->field(i.key()).toLower(); QCOMPARE(result, i.value().toLower()); } QVERIFY(!entry->field(QLatin1String("track")).isEmpty()); QVERIFY(!entry->field(QLatin1String("cover")).isEmpty()); }
void DBLPFetcherTest::testProceedings() { Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Bibtex, Tellico::Fetch::Keyword, QLatin1String("Chip and PIN is Broken")); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::DBLPFetcher(this)); Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); QCOMPARE(results.size(), 1); Tellico::Data::EntryPtr entry = results.at(0); QCOMPARE(entry->field(QLatin1String("title")), QLatin1String("Chip and PIN is Broken.")); QCOMPARE(entry->field(QLatin1String("author")), QLatin1String("Steven J. Murdoch; Saar Drimer; Ross J. Anderson; Mike Bond")); QCOMPARE(entry->field(QLatin1String("year")), QLatin1String("2010")); QCOMPARE(entry->field(QLatin1String("pages")), QLatin1String("433-446")); QCOMPARE(entry->field(QLatin1String("booktitle")), QLatin1String("IEEE Symposium on Security and Privacy")); QCOMPARE(entry->field(QLatin1String("url")), QLatin1String("http://dx.doi.org/10.1109/SP.2010.33")); QCOMPARE(entry->field(QLatin1String("doi")), QLatin1String("10.1109/SP.2010.33")); QCOMPARE(entry->field(QLatin1String("entry-type")), QLatin1String("inproceedings")); QCOMPARE(entry->field(QLatin1String("bibtex-key")), QLatin1String("MurdochDAB10")); }
void MusicBrainzFetcherTest::testKeyword() { // the total test case ends up exceeding the throttle limit so pause for a second QTest::qWait(1000); Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Album, Tellico::Fetch::Keyword, m_fieldValues.value(QLatin1String("title"))); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::MusicBrainzFetcher(this)); Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); QCOMPARE(results.size(), 1); Tellico::Data::EntryPtr entry = results.at(0); QHashIterator<QString, QString> i(m_fieldValues); while(i.hasNext()) { i.next(); QString result = entry->field(i.key()).toLower(); QCOMPARE(result, i.value().toLower()); } QVERIFY(!entry->field(QLatin1String("track")).isEmpty()); QVERIFY(!entry->field(QLatin1String("cover")).isEmpty()); }
void AnimenfoFetcherTest::testHachimitsu() { KConfig config(QFINDTESTDATA("tellicotest.config"), KConfig::SimpleConfig); QString groupName = QLatin1String("AnimeNfo.com"); 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::Keyword, "Hachimitsu to Clover"); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::AnimeNfoFetcher(this)); fetcher->readConfig(cg, cg.name()); Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); QCOMPARE(results.size(), 1); // the first entry had better be the right one Tellico::Data::EntryPtr entry = results.at(0); QVERIFY(entry); QCOMPARE(entry->field("title"), QLatin1String("Hachimitsu to Clover")); QCOMPARE(entry->field("year"), QLatin1String("2005")); QCOMPARE(entry->field("episodes"), QLatin1String("26")); QCOMPARE(entry->field("keyword"), QLatin1String("TV")); QCOMPARE(entry->field("genre"), QLatin1String("Comedy; Drama; Romance")); QCOMPARE(entry->field("studio"), QLatin1String("J.C.STAFF")); QCOMPARE(entry->field("origtitle"), QString::fromUtf8("ハチミツとクローバー")); QCOMPARE(entry->field("director"), QString::fromUtf8("Kasai Kenichi (カサヰ ケンイチ)")); QCOMPARE(entry->field("writer"), QString::fromUtf8("Kuroda Yosuke (黒田洋介)")); QCOMPARE(entry->field("alttitle"), QLatin1String("Honey and Clover")); QCOMPARE(entry->field("animenfo-rating"), QLatin1String("9")); QVERIFY(entry->field("plot").startsWith(QLatin1String("Takemoto, Mayama, and Morita are students"))); QVERIFY(!entry->field("cover").isEmpty()); QVERIFY(!entry->field("animenfo").isEmpty()); QStringList castList = Tellico::FieldFormat::splitTable(entry->field("cast")); QCOMPARE(castList.count(), 7); QCOMPARE(castList.at(0), QString::fromUtf8("Kudo Haruka (工藤晴香)::Hanamoto Hagumi")); }
void DBLPFetcherTest::testArticle() { Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Bibtex, Tellico::Fetch::Keyword, QLatin1String("Nontrivial independent sets of bipartite graphs")); Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::DBLPFetcher(this)); Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); QCOMPARE(results.size(), 1); Tellico::Data::EntryPtr entry = results.at(0); QCOMPARE(entry->field(QLatin1String("title")), QLatin1String("Nontrivial independent sets of bipartite graphs and cross-intersecting families.")); QCOMPARE(entry->field(QLatin1String("author")), QLatin1String("Jun Wang; Huajun Zhang")); QCOMPARE(entry->field(QLatin1String("year")), QLatin1String("2013")); QCOMPARE(entry->field(QLatin1String("pages")), QLatin1String("129-141")); QCOMPARE(entry->field(QLatin1String("volume")), QLatin1String("120")); QCOMPARE(entry->field(QLatin1String("number")), QLatin1String("1")); QCOMPARE(entry->field(QLatin1String("journal")), QLatin1String("J. Comb. Theory, Ser. A (JCT)")); QCOMPARE(entry->field(QLatin1String("booktitle")), QLatin1String("")); QCOMPARE(entry->field(QLatin1String("url")), QLatin1String("http://dx.doi.org/10.1016/j.jcta.2012.07.005")); QCOMPARE(entry->field(QLatin1String("doi")), QLatin1String("10.1016/j.jcta.2012.07.005")); QCOMPARE(entry->field(QLatin1String("entry-type")), QLatin1String("article")); QCOMPARE(entry->field(QLatin1String("bibtex-key")), QLatin1String("WangZ13")); }