Bugzilla – Attachment 145970 Details for
Bug 32779
Import from list is broken
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32779: Add tests
Bug-32779-Add-tests.patch (text/plain), 3.06 KB, created by
Tomás Cohen Arazi (tcohen)
on 2023-02-01 17:29:19 UTC
(
hide
)
Description:
Bug 32779: Add tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2023-02-01 17:29:19 UTC
Size:
3.06 KB
patch
obsolete
>From c2270d142869ec8c41a79f03f50912c3164bb4e1 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 1 Feb 2023 14:28:23 +0100 >Subject: [PATCH] Bug 32779: Add tests > >Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > .../CreateEHoldingsFromBiblios.t | 44 ++++++++++++++----- > 1 file changed, 33 insertions(+), 11 deletions(-) > >diff --git a/t/db_dependent/Koha/BackgroundJob/CreateEHoldingsFromBiblios.t b/t/db_dependent/Koha/BackgroundJob/CreateEHoldingsFromBiblios.t >index 36d64d86880..b18a3bfb6ef 100755 >--- a/t/db_dependent/Koha/BackgroundJob/CreateEHoldingsFromBiblios.t >+++ b/t/db_dependent/Koha/BackgroundJob/CreateEHoldingsFromBiblios.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 1; >+use Test::More tests => 2; > > use Koha::Database; > use Koha::BackgroundJobs; >@@ -29,28 +29,50 @@ use t::lib::TestBuilder; > my $schema = Koha::Database->new->schema; > my $builder = t::lib::TestBuilder->new; > >-subtest 'enqueue() tests' => sub { >+subtest 'enqueue' => sub { > >- plan tests => 5; >+ plan tests => 2; > > $schema->storage->txn_begin; > > # FIXME: Should be an exception >- my $job_id = Koha::BackgroundJob::CreateEHoldingsFromBiblios->new->enqueue(); >+ my $job_id = >+ Koha::BackgroundJob::CreateEHoldingsFromBiblios->new->enqueue(); > is( $job_id, undef, 'Nothing enqueued if missing params' ); > > # FIXME: Should be an exception >- $job_id = Koha::BackgroundJob::CreateEHoldingsFromBiblios->new->enqueue( { record_ids => undef } ); >+ $job_id = Koha::BackgroundJob::CreateEHoldingsFromBiblios->new->enqueue( >+ { record_ids => undef } ); > is( $job_id, undef, "Nothing enqueued if missing 'package_id' param" ); > >- my $record_ids = [ 1, 2 ]; >+ $schema->storage->txn_rollback; >+}; >+ >+subtest 'process' => sub { >+ plan tests => 1; >+ >+ $schema->storage->txn_begin; >+ >+ my $biblio = $builder->build_sample_biblio; > >- $job_id = Koha::BackgroundJob::CreateEHoldingsFromBiblios->new->enqueue( { record_ids => $record_ids, package_id => 'thing' } ); >- my $job = Koha::BackgroundJobs->find($job_id)->_derived_class; >+ my $package = >+ Koha::ERM::EHoldings::Package->new( { name => 'a package' } )->store; > >- is( $job->size, scalar @{$record_ids}, 'Size is correct' ); >- is( $job->status, 'new', 'Initial status set correctly' ); >- is( $job->queue, 'long_tasks', 'BatchUpdateItem should use the long_tasks queue' ); >+ my $job = Koha::BackgroundJob::CreateEHoldingsFromBiblios->new( >+ { >+ status => 'new', >+ type => 'create_eholdings_from_biblios', >+ } >+ )->store; >+ $job = Koha::BackgroundJobs->find( $job->id ); >+ my $data = { >+ record_ids => [ $biblio->biblionumber ], >+ package_id => $package->package_id, >+ }; >+ my $json = $job->json->encode($data); >+ $job->data($json)->store; >+ $job->process($data); >+ is( $job->report->{total_success}, 1 ); > > $schema->storage->txn_rollback; > }; >-- >2.34.1
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 32779
:
145948
|
145949
|
145968
|
145969
| 145970 |
145971