[Koha-patches] [PATCH 2/2] Bug 12782: (followup) skip tests that fail because of provider's error

Tomas Cohen Arazi tomascohen at gmail.com
Mon Aug 18 22:32:40 CEST 2014


It seems that XISBN is failing sometimes, if you run the tests a couple
of times in a row. An error 500 is raised by lwp.

This problem should be trapped and related tests skipped. Because too much
noise could make people pay no attention to this tests failing.

To reproduce:
- Run the tests several consecutive times:
  $ prove -v t/db_dependent/XISBN.t
=> FAIL: XISBN test will fail eventually, printing a networking-related warning.
- Apply the patch
- Repeat the test
=> SUCCESS: when XISBN the networking/connection refused problem arises, the test
  is skipped, and it still passes.

Regards
To+
---
 t/db_dependent/XISBN.t | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/t/db_dependent/XISBN.t b/t/db_dependent/XISBN.t
index 1f6f797..9486274 100755
--- a/t/db_dependent/XISBN.t
+++ b/t/db_dependent/XISBN.t
@@ -53,19 +53,33 @@ $trial = C4::XISBN::_get_biblio_from_xisbn($isbn1);
 is( $trial->{biblionumber},
     $biblionumber1, "Gets biblionumber like the previous test." );
 
+## Test ThingISBN
 $context->set_preference( 'ThingISBN', 1 );
 $context->set_preference( 'XISBN', 0 );
-my $results_thingisbn = C4::XISBN::get_xisbns($isbn1);
-is( $results_thingisbn->[0]->{biblionumber},
-    $biblionumber3,
-    "Gets correct biblionumber from a book with a similar isbn using ThingISBN." );
 
+my $results_thingisbn;
+eval { $results_thingisbn = C4::XISBN::get_xisbns($isbn1); };
+SKIP: {
+    skip "Problem retrieving ThingISBN", 1
+        unless $@ eq '';
+    is( $results_thingisbn->[0]->{biblionumber},
+        $biblionumber3,
+        "Gets correct biblionumber from a book with a similar isbn using ThingISBN." );
+}
+
+## Test XISBN
 $context->set_preference( 'ThingISBN', 0 );
 $context->set_preference( 'XISBN', 1 );
-my $results_xisbn = C4::XISBN::get_xisbns($isbn1);
-is( $results_xisbn->[0]->{biblionumber},
-    $biblionumber3,
-    "Gets correct biblionumber from a book with a similar isbn using XISBN." );
+
+my $results_xisbn;
+eval { $results_xisbn = C4::XISBN::get_xisbns($isbn1); };
+SKIP: {
+    skip "Problem retrieving XISBN", 1
+        unless $@ eq '';
+    is( $results_xisbn->[0]->{biblionumber},
+        $biblionumber3,
+        "Gets correct biblionumber from a book with a similar isbn using XISBN." );
+}
 
 $dbh->rollback;
 
-- 
1.9.1



More information about the Koha-patches mailing list