Lines 18-24
Link Here
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::NoWarnings; |
20 |
use Test::NoWarnings; |
21 |
use Test::More tests => 3; |
21 |
use Test::More tests => 4; |
22 |
|
22 |
|
23 |
use Koha::Database; |
23 |
use Koha::Database; |
24 |
use Koha::BackgroundJobs; |
24 |
use Koha::BackgroundJobs; |
Lines 153-159
subtest 'enqueue_sushi_harvest_jobs' => sub {
Link Here
|
153 |
is( $another_report->{us_report_info}->{added_mus}, 0 ); |
153 |
is( $another_report->{us_report_info}->{added_mus}, 0 ); |
154 |
is( $another_report->{us_report_info}->{added_usage_objects}, 0 ); |
154 |
is( $another_report->{us_report_info}->{added_usage_objects}, 0 ); |
155 |
|
155 |
|
156 |
#TODO: Test a harvest with sushi errors |
|
|
157 |
#TODO: Test more report types |
156 |
#TODO: Test more report types |
158 |
|
157 |
|
159 |
$schema->storage->txn_rollback; |
158 |
$schema->storage->txn_rollback; |
Lines 236-238
subtest 'enqueue_counter_file_processing_job' => sub {
Link Here
|
236 |
$schema->storage->txn_rollback; |
235 |
$schema->storage->txn_rollback; |
237 |
|
236 |
|
238 |
}; |
237 |
}; |
239 |
- |
238 |
|
|
|
239 |
$ua->unmock_all; |
240 |
$ua->mock( |
241 |
'simple_request', |
242 |
sub { |
243 |
my $response = Test::MockObject->new(); |
244 |
|
245 |
$response->mock( |
246 |
'code', |
247 |
sub { |
248 |
return 200; |
249 |
} |
250 |
); |
251 |
$response->mock( |
252 |
'is_error', |
253 |
sub { |
254 |
return 0; |
255 |
} |
256 |
); |
257 |
$response->mock( |
258 |
'is_redirect', |
259 |
sub { |
260 |
return 0; |
261 |
} |
262 |
); |
263 |
$response->mock( |
264 |
'decoded_content', |
265 |
sub { |
266 |
return '{ |
267 |
"Code": 2010, |
268 |
"Message": "Requestor is Not Authorized to Access Usage for Institution" |
269 |
}'; |
270 |
} |
271 |
); |
272 |
$response->{_rc} = 200; |
273 |
return $response; |
274 |
} |
275 |
); |
276 |
|
277 |
subtest 'enqueue_sushi_harvest_jobs_error_handling' => sub { |
278 |
plan tests => 2; |
279 |
|
280 |
$schema->storage->txn_begin; |
281 |
|
282 |
my $usage_data_provider_error = $builder->build_object( |
283 |
{ class => 'Koha::ERM::EUsage::UsageDataProviders', value => { name => 'TestProvider' } } ); |
284 |
|
285 |
my $job = Koha::BackgroundJob::ErmSushiHarvester->new( |
286 |
{ |
287 |
status => 'new', |
288 |
size => 1, |
289 |
type => 'erm_sushi_harvester' |
290 |
} |
291 |
)->store; |
292 |
|
293 |
$job = Koha::BackgroundJobs->find( $job->id ); |
294 |
|
295 |
$job->process( |
296 |
{ |
297 |
job_id => $job->id, |
298 |
ud_provider_id => $usage_data_provider_error->erm_usage_data_provider_id, |
299 |
report_type => 'TR_J1', |
300 |
} |
301 |
); |
302 |
|
303 |
is( ref $job->messages, 'ARRAY', 'messages is an array' ); |
304 |
is( $job->messages->[0]->{code}, 2010, 'first message has code 2010' ); |
305 |
|
306 |
$schema->storage->txn_rollback; |
307 |
|
308 |
}; |