Bugzilla – Attachment 182816 Details for
Bug 39823
SUSHI harvest fails to display error if the provider's response does not contain Severity
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39823: Clean-up: Mock LWP response instead of class method being tested
Bug-39823-Clean-up-Mock-LWP-response-instead-of-cl.patch (text/plain), 3.10 KB, created by
Nick Clemens (kidclamp)
on 2025-05-28 12:12:10 UTC
(
hide
)
Description:
Bug 39823: Clean-up: Mock LWP response instead of class method being tested
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2025-05-28 12:12:10 UTC
Size:
3.10 KB
patch
obsolete
>From bc533981eb15bd6ad0c84e79108015ddb15c03db Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@openfifth.co.uk> >Date: Mon, 5 May 2025 10:26:57 +0000 >Subject: [PATCH] Bug 39823: Clean-up: Mock LWP response instead of class > method being tested > >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > .../Koha/BackgroundJobs/ErmSushiHarvester.t | 62 +++++++++---------- > 1 file changed, 29 insertions(+), 33 deletions(-) > >diff --git a/t/db_dependent/Koha/BackgroundJobs/ErmSushiHarvester.t b/t/db_dependent/Koha/BackgroundJobs/ErmSushiHarvester.t >index e7f66b4e21e..18ffa61f8e8 100755 >--- a/t/db_dependent/Koha/BackgroundJobs/ErmSushiHarvester.t >+++ b/t/db_dependent/Koha/BackgroundJobs/ErmSushiHarvester.t >@@ -42,42 +42,38 @@ my $sushi_counter_5_response_TR_J1 = read_file($sushi_response_file_TR_J1); > my $sushi_counter_report_TR_J1 = > Koha::ERM::EUsage::SushiCounter->new( { response => decode_json($sushi_counter_5_response_TR_J1) } ); > >-my $usage_data_provider_module = Test::MockModule->new('Koha::ERM::EUsage::UsageDataProvider'); >- >-# Mock harvest_sushi to have data coming from TR_J1.json act as a SUSHI response >-$usage_data_provider_module->mock( >- 'harvest_sushi', >+my $ua = Test::MockModule->new('LWP::UserAgent'); >+$ua->mock( >+ 'simple_request', > sub { >- my ( $self, $args ) = @_; >- >- # Set class wide vars >- $self->{report_type} = $args->{report_type}; >- $self->{begin_date} = $args->{begin_date}; >- $self->{end_date} = $args->{end_date}; >- my $response = $sushi_counter_5_response_TR_J1; >- >- my $decoded_response = decode_json($response); >- >- return if $self->_sushi_errors($decoded_response); >- >- # Parse the SUSHI response >- my $sushi_counter = Koha::ERM::EUsage::SushiCounter->new( { response => $decoded_response } ); >- my $counter_file = $sushi_counter->get_COUNTER_from_SUSHI; >+ my $response = Test::MockObject->new(); > >- return if $self->_counter_file_size_too_large($counter_file); >- >- $self->counter_files( >- [ >- { >- usage_data_provider_id => $self->erm_usage_data_provider_id, >- file_content => $counter_file, >- date_uploaded => POSIX::strftime( "%Y%m%d%H%M%S", localtime ), >- >- #TODO: add ".csv" to end of filename here >- filename => $self->name . "_" . $self->{report_type}, >- } >- ] >+ $response->mock( >+ 'code', >+ sub { >+ return 200; >+ } >+ ); >+ $response->mock( >+ 'is_error', >+ sub { >+ return 0; >+ } >+ ); >+ $response->mock( >+ 'is_redirect', >+ sub { >+ return 0; >+ } >+ ); >+ $response->mock( >+ 'decoded_content', >+ sub { >+ return $sushi_counter_5_response_TR_J1; >+ } > ); >+ $response->{_rc} = 200; >+ return $response; > } > ); > >-- >2.39.5
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 39823
:
181904
|
181905
|
181906
|
182121
|
182122
|
182123
| 182816 |
182817
|
182818