Bugzilla – Attachment 67847 Details for
Bug 19440
XISBN tests should skip if XISBN returns overlimit error
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19440: Identify overlimit problems in XISBN tests
Bug-19440-Identify-overlimit-problems-in-XISBN-tes.patch (text/plain), 3.23 KB, created by
Tomás Cohen Arazi (tcohen)
on 2017-10-09 18:42:31 UTC
(
hide
)
Description:
Bug 19440: Identify overlimit problems in XISBN tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2017-10-09 18:42:31 UTC
Size:
3.23 KB
patch
obsolete
>From 5b561f78649ad423ef701345a23164de34c0ed51 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 9 Oct 2017 15:36:41 -0300 >Subject: [PATCH] Bug 19440: Identify overlimit problems in XISBN tests > >This patch makes C4::XISBN::get_xisbns() return an errors hashref >including information of the failing fetches from xisbn services. > >It tackles the situation of XISBN, which in some cases returns 'overlimit' >errors. > >The patch makes the relevant functions check if the response->{stat} string >is 'ok' and returns the string in $errors otherwise. > >This only happens when in list context. This allows to fix the randomly failing >tests while keeping the current behaviour. > >All this code should be rewritten. It does the job bug doesn't have problems handling >or reoprting. This is just a band aid. > >To test: >- Make sure > k$ prove t/db_dependent/XISBN.t >=> SUCCESS :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > C4/XISBN.pm | 11 +++++++++-- > t/db_dependent/XISBN.t | 8 ++++---- > 2 files changed, 13 insertions(+), 6 deletions(-) > >diff --git a/C4/XISBN.pm b/C4/XISBN.pm >index 5f3fd51..cff35c9 100644 >--- a/C4/XISBN.pm >+++ b/C4/XISBN.pm >@@ -91,7 +91,7 @@ sub _get_biblio_from_xisbn { > > sub get_xisbns { > my ( $isbn ) = @_; >- my ($response,$thing_response,$xisbn_response,$syndetics_response); >+ my ($response,$thing_response,$xisbn_response,$syndetics_response,$errors); > # THINGISBN > if ( C4::Context->preference('ThingISBN') ) { > my $url = "http://www.librarything.com/api/thingISBN/".$isbn; >@@ -117,6 +117,8 @@ sub get_xisbns { > unless ($reached_limit) { > $xisbn_response = _get_url($url,'xisbn'); > } >+ $errors->{xisbn} = $xisbn_response->{ stat } >+ if $xisbn_response->{ stat } ne 'ok'; > } > > $response->{isbn} = [ @{ $xisbn_response->{isbn} or [] }, @{ $syndetics_response->{isbn} or [] }, @{ $thing_response->{isbn} or [] } ]; >@@ -132,7 +134,12 @@ sub get_xisbns { > my $xbiblio= _get_biblio_from_xisbn($response_data->{content}); > push @xisbns, $xbiblio if $xbiblio; > } >- return \@xisbns; >+ if ( wantarray ) { >+ return (\@xisbns, $errors); >+ } >+ else { >+ return \@xisbns; >+ } > } > > sub _get_url { >diff --git a/t/db_dependent/XISBN.t b/t/db_dependent/XISBN.t >index 2f6d63b..df598ce 100755 >--- a/t/db_dependent/XISBN.t >+++ b/t/db_dependent/XISBN.t >@@ -25,7 +25,7 @@ $dbh->{AutoCommit} = 0; > my $search_module = new Test::MockModule('C4::Search'); > > $search_module->mock('SimpleSearch', \&Mock_SimpleSearch ); >- >+my $errors; > my $context = C4::Context->new; > > my ( $biblionumber_tag, $biblionumber_subfield ) = >@@ -73,10 +73,10 @@ t::lib::Mocks::mock_preference( 'ThingISBN', 0 ); > t::lib::Mocks::mock_preference( 'XISBN', 1 ); > > my $results_xisbn; >-eval { $results_xisbn = C4::XISBN::get_xisbns($isbn1); }; >+eval { ($results_xisbn, $errors) = C4::XISBN::get_xisbns($isbn1); }; > SKIP: { >- skip "Problem retrieving XISBN", 1 >- unless $@ eq ''; >+ skip "Problem retrieving XISBN (" . $errors->{xisbn} . ")", 1 >+ if $errors->{xisbn}; > is( $results_xisbn->[0]->{biblionumber}, > $biblionumber3, > "Gets correct biblionumber from a book with a similar isbn using XISBN." ); >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 19440
: 67847 |
67848