Bug 39823: Add tests
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 9b0d6260bb)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
parent
54ee4ded1e
commit
d4fb56be5b
|
|
@ -18,7 +18,7 @@
|
|||
use Modern::Perl;
|
||||
|
||||
use Test::NoWarnings;
|
||||
use Test::More tests => 3;
|
||||
use Test::More tests => 4;
|
||||
|
||||
use Koha::Database;
|
||||
use Koha::BackgroundJobs;
|
||||
|
|
@ -153,7 +153,6 @@ subtest 'enqueue_sushi_harvest_jobs' => sub {
|
|||
is( $another_report->{us_report_info}->{added_mus}, 0 );
|
||||
is( $another_report->{us_report_info}->{added_usage_objects}, 0 );
|
||||
|
||||
#TODO: Test a harvest with sushi errors
|
||||
#TODO: Test more report types
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
|
|
@ -236,3 +235,74 @@ subtest 'enqueue_counter_file_processing_job' => sub {
|
|||
$schema->storage->txn_rollback;
|
||||
|
||||
};
|
||||
|
||||
$ua->unmock_all;
|
||||
$ua->mock(
|
||||
'simple_request',
|
||||
sub {
|
||||
my $response = Test::MockObject->new();
|
||||
|
||||
$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 '{
|
||||
"Code": 2010,
|
||||
"Message": "Requestor is Not Authorized to Access Usage for Institution"
|
||||
}';
|
||||
}
|
||||
);
|
||||
$response->{_rc} = 200;
|
||||
return $response;
|
||||
}
|
||||
);
|
||||
|
||||
subtest 'enqueue_sushi_harvest_jobs_error_handling' => sub {
|
||||
plan tests => 2;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
my $usage_data_provider_error = $builder->build_object(
|
||||
{ class => 'Koha::ERM::EUsage::UsageDataProviders', value => { name => 'TestProvider' } } );
|
||||
|
||||
my $job = Koha::BackgroundJob::ErmSushiHarvester->new(
|
||||
{
|
||||
status => 'new',
|
||||
size => 1,
|
||||
type => 'erm_sushi_harvester'
|
||||
}
|
||||
)->store;
|
||||
|
||||
$job = Koha::BackgroundJobs->find( $job->id );
|
||||
|
||||
$job->process(
|
||||
{
|
||||
job_id => $job->id,
|
||||
ud_provider_id => $usage_data_provider_error->erm_usage_data_provider_id,
|
||||
report_type => 'TR_J1',
|
||||
}
|
||||
);
|
||||
|
||||
is( ref $job->messages, 'ARRAY', 'messages is an array' );
|
||||
is( $job->messages->[0]->{code}, 2010, 'first message has code 2010' );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue