Bugzilla – Attachment 172057 Details for
Bug 37526
Handle redirects in SUSHI requests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37526: (QA follow-up) Tidy
Bug-37526-QA-follow-up-Tidy.patch (text/plain), 4.42 KB, created by
Nick Clemens (kidclamp)
on 2024-09-26 19:55:42 UTC
(
hide
)
Description:
Bug 37526: (QA follow-up) Tidy
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2024-09-26 19:55:42 UTC
Size:
4.42 KB
patch
obsolete
>From 5477320e55c636ed4b089baf4674e0044139f3ac Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 26 Sep 2024 19:53:28 +0000 >Subject: [PATCH] Bug 37526: (QA follow-up) Tidy > >--- > .../Koha/BackgroundJob/ErmSushiHarvester.t | 94 +++++++++++++------ > 1 file changed, 63 insertions(+), 31 deletions(-) > >diff --git a/t/db_dependent/Koha/BackgroundJob/ErmSushiHarvester.t b/t/db_dependent/Koha/BackgroundJob/ErmSushiHarvester.t >index 214cbc41862..9621f5a4887 100755 >--- a/t/db_dependent/Koha/BackgroundJob/ErmSushiHarvester.t >+++ b/t/db_dependent/Koha/BackgroundJob/ErmSushiHarvester.t >@@ -232,31 +232,48 @@ subtest 'is_redirect() tests' => sub { > $schema->storage->txn_begin; > > my $ua = Test::MockModule->new('LWP::UserAgent'); >- $ua->mock('simple_request', sub { >+ $ua->mock( >+ 'simple_request', >+ sub { > return mock_HTTP_redirect(); >- }); >- $ua->mock('get', sub { >- return mock_sushi_response({'error'=>'invalid_api_key'}); >- }); >+ } >+ ); >+ $ua->mock( >+ 'get', >+ sub { >+ return mock_sushi_response( { 'error' => 'invalid_api_key' } ); >+ } >+ ); > > my $usage_data_provider = $builder->build_object( > { class => 'Koha::ERM::EUsage::UsageDataProviders', value => { name => 'TestProvider' } } ); > > my $job_args = { >- ud_provider_id => $usage_data_provider->erm_usage_data_provider_id, >- report_type => 'TR_J1', >- begin_date => '2023-08-01', >- end_date => '2023-09-30', >- ud_provider_name => $usage_data_provider->name, >- }; >+ ud_provider_id => $usage_data_provider->erm_usage_data_provider_id, >+ report_type => 'TR_J1', >+ begin_date => '2023-08-01', >+ end_date => '2023-09-30', >+ ud_provider_name => $usage_data_provider->name, >+ }; > > my $job_id = Koha::BackgroundJob::ErmSushiHarvester->new->enqueue($job_args); >- my $job = Koha::BackgroundJobs->find($job_id)->_derived_class; >- $job->process( $job_args ); >+ my $job = Koha::BackgroundJobs->find($job_id)->_derived_class; >+ $job->process($job_args); > >- is( $job->{messages}[0]->{message}, decode_json($sushi_response_errors->{invalid_api_key})->{Severity} . ' - ' . decode_json($sushi_response_errors->{invalid_api_key})->{Message},'SUSHI error invalid_date_arguments is stored on job messages correctly' ); >- is( $job->{messages}[0]->{type},'error','SUSHI error invalid_date_arguments is stored on job messages correctly' ); >- is( $job->{messages}[0]->{code},decode_json($sushi_response_errors->{invalid_api_key})->{Code},'SUSHI error invalid_date_arguments is stored on job messages correctly' ); >+ is( >+ $job->{messages}[0]->{message}, >+ decode_json( $sushi_response_errors->{invalid_api_key} )->{Severity} . ' - ' >+ . decode_json( $sushi_response_errors->{invalid_api_key} )->{Message}, >+ 'SUSHI error invalid_date_arguments is stored on job messages correctly' >+ ); >+ is( >+ $job->{messages}[0]->{type}, 'error', >+ 'SUSHI error invalid_date_arguments is stored on job messages correctly' >+ ); >+ is( >+ $job->{messages}[0]->{code}, decode_json( $sushi_response_errors->{invalid_api_key} )->{Code}, >+ 'SUSHI error invalid_date_arguments is stored on job messages correctly' >+ ); > > $schema->storage->txn_rollback; > }; >@@ -296,19 +313,34 @@ sub mock_sushi_response { > sub mock_HTTP_redirect { > my $response = Test::MockObject->new(); > >- $response->mock('code', sub { >- return 301; >- }); >- $response->mock('is_error', sub { >- return 0; >- }); >- $response->mock('is_redirect', sub { >- return 1; >- }); >- $response->mock('header', sub { >- return 'www.whatever.com'; >- }); >- $response->mock('decoded_content', sub { >- return 'Moved permanently'; >- }); >+ $response->mock( >+ 'code', >+ sub { >+ return 301; >+ } >+ ); >+ $response->mock( >+ 'is_error', >+ sub { >+ return 0; >+ } >+ ); >+ $response->mock( >+ 'is_redirect', >+ sub { >+ return 1; >+ } >+ ); >+ $response->mock( >+ 'header', >+ sub { >+ return 'www.whatever.com'; >+ } >+ ); >+ $response->mock( >+ 'decoded_content', >+ sub { >+ return 'Moved permanently'; >+ } >+ ); > } >-- >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 37526
:
169858
|
170381
|
171777
|
171778
|
171891
|
171892
|
172055
|
172056
| 172057