[office/tellico/4.2] src: GoogleBooks: add test for multiple ISBN

Robby Stephenson <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 90e5505cc04f388014cb8eccb29fa22f9a845112 by Robby Stephenson.
Committed on 01/08/2026 at 00:48.
Pushed by rstephenson into branch '4.2'.

GoogleBooks: add test for multiple ISBN

M  +12   -6    src/fetch/googlebookfetcher.cpp
M  +11   -1    src/tests/googlebookfetchertest.cpp
M  +1    -0    src/tests/googlebookfetchertest.h

https://invent.kde.org/office/tellico/-/commit/90e5505cc04f388014cb8eccb29fa22f9a845112

diff --git a/src/fetch/googlebookfetcher.cpp b/src/fetch/googlebookfetcher.cpp
index ae5cd9439..368ebec2d 100644
--- a/src/fetch/googlebookfetcher.cpp
+++ b/src/fetch/googlebookfetcher.cpp
@@ -94,14 +94,14 @@ void GoogleBookFetcher::search() {
 
 void GoogleBookFetcher::continueSearch() {
   m_started = true;
-  // we only split ISBN and LCCN values
+  // we only split ISBN values
   QStringList searchTerms;
   if(request().key() == ISBN) {
     searchTerms = FieldFormat::splitValue(request().value());
-  } else  {
+  } else {
     searchTerms += request().value();
   }
-  foreach(const QString& searchTerm, searchTerms) {
+  for(const auto& searchTerm : std::as_const(searchTerms)) {
     doSearch(searchTerm);
   }
   if(m_jobs.isEmpty()) {
@@ -147,7 +147,7 @@ void GoogleBookFetcher::doSearch(const QString& term_) {
       return;
   }
   u.setQuery(q);
-//  myDebug() << "url:" << u;
+  myLog() << "Reading" << u.toDisplayString();
 
   QPointer<KIO::StoredTransferJob> job = KIO::storedGet(u, KIO::NoReload, KIO::HideProgressInfo);
   KJobWidgets::setWindow(job, GUI::Proxy::widget());
@@ -166,7 +166,7 @@ void GoogleBookFetcher::stop() {
   if(!m_started) {
     return;
   }
-  foreach(QPointer<KIO::StoredTransferJob> job, m_jobs) {
+  for(auto& job : std::as_const(m_jobs)) {
     if(job) {
       job->kill();
     }
@@ -274,7 +274,13 @@ void GoogleBookFetcher::slotComplete(KJob* job_) {
 
   const auto resultList = result["items"_L1].toArray();
   if(resultList.isEmpty()) {
-    myDebug() << "no results";
+    const auto msg = result["error"_L1]["message"_L1].toString();
+    if(msg.isEmpty()) {
+      myDebug() << "no results";
+    } else {
+      message(msg, MessageHandler::Error);
+      myDebug() << "UPCItemDbFetcher -" << msg;
+    }
     endJob(job);
     return;
   }
diff --git a/src/tests/googlebookfetchertest.cpp b/src/tests/googlebookfetchertest.cpp
index 163dcc43a..accf046c1 100644
--- a/src/tests/googlebookfetchertest.cpp
+++ b/src/tests/googlebookfetchertest.cpp
@@ -32,7 +32,7 @@
 
 #include <QTest>
 
-QTEST_GUILESS_MAIN( GoogleBookFetcherTest )
+QTEST_MAIN( GoogleBookFetcherTest )
 
 GoogleBookFetcherTest::GoogleBookFetcherTest() : AbstractFetcherTest() {
 }
@@ -63,6 +63,16 @@ void GoogleBookFetcherTest::testIsbn() {
   compareEntry(results.at(0));
 }
 
+void GoogleBookFetcherTest::testMultipleIsbn() {
+  Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Book, Tellico::Fetch::ISBN,
+                                       QStringLiteral("0-596-55051-0; 0671319728"));
+  Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::GoogleBookFetcher(this));
+
+  Tellico::Data::EntryList results = DO_FETCH(fetcher, request);
+
+  QCOMPARE(results.size(), 2);
+}
+
 void GoogleBookFetcherTest::testAuthor() {
   Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Book, Tellico::Fetch::Person,
                                        QStringLiteral("Shelley Powers"));
diff --git a/src/tests/googlebookfetchertest.h b/src/tests/googlebookfetchertest.h
index 957390283..0fc8ebae9 100644
--- a/src/tests/googlebookfetchertest.h
+++ b/src/tests/googlebookfetchertest.h
@@ -36,6 +36,7 @@ private Q_SLOTS:
   void initTestCase();
   void testTitle();
   void testIsbn();
+  void testMultipleIsbn();
   void testAuthor();
   void testKeyword();
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.