Bugzilla – Attachment 134317 Details for
Bug 29346
Real-time holds queue update
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29346: Avoid duplicate actions tests
Bug-29346-Avoid-duplicate-actions-tests.patch (text/plain), 6.78 KB, created by
Tomás Cohen Arazi (tcohen)
on 2022-04-28 22:56:41 UTC
(
hide
)
Description:
Bug 29346: Avoid duplicate actions tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2022-04-28 22:56:41 UTC
Size:
6.78 KB
patch
obsolete
>From 1ef01ec1d9d0640819ac855dc8c7680cb3c9bb9e Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 26 Apr 2022 16:28:14 -0300 >Subject: [PATCH] Bug 29346: Avoid duplicate actions tests > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/db_dependent/Biblio.t | 43 ++-------- > t/db_dependent/Biblio_holdsqueue.t | 106 ++++++++++++++++++++++++ > t/db_dependent/Circulation_holdsqueue.t | 2 +- > 3 files changed, 112 insertions(+), 39 deletions(-) > create mode 100755 t/db_dependent/Biblio_holdsqueue.t > >diff --git a/t/db_dependent/Biblio.t b/t/db_dependent/Biblio.t >index 1287aa57c5..1ffa0143cb 100755 >--- a/t/db_dependent/Biblio.t >+++ b/t/db_dependent/Biblio.t >@@ -639,8 +639,8 @@ subtest 'IsMarcStructureInternal' => sub { > subtest 'deletedbiblio_metadata' => sub { > plan tests => 2; > >- my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue'); >- $mock->mock( 'enqueue', undef ); >+ my $bgj_mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue'); >+ $bgj_mock->mock( 'enqueue', undef ); > > my ($biblionumber, $biblioitemnumber) = AddBiblio(MARC::Record->new, ''); > my $biblio_metadata = C4::Biblio::GetXmlBiblio( $biblionumber ); >@@ -653,10 +653,10 @@ subtest 'deletedbiblio_metadata' => sub { > > subtest 'DelBiblio' => sub { > >- plan tests => 6; >+ plan tests => 5; > >- my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue'); >- $mock->mock( 'enqueue', undef ); >+ my $bgj_mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue'); >+ $bgj_mock->mock( 'enqueue', undef ); > > my ($biblionumber, $biblioitemnumber) = C4::Biblio::AddBiblio(MARC::Record->new, ''); > my $deleted = C4::Biblio::DelBiblio( $biblionumber ); >@@ -694,39 +694,6 @@ subtest 'DelBiblio' => sub { > is( $subscription->get_from_storage, undef, 'subscription should be deleted on biblio deletion' ); > is( $serial->get_from_storage, undef, 'serial should be deleted on biblio deletion' ); > is( $subscription_history->get_from_storage, undef, 'subscription history should be deleted on biblio deletion' ); >- >- subtest 'holds_queue update tests' => sub { >- >- plan tests => 1; >- >- $schema->storage->txn_begin; >- >- my $biblio = $builder->build_sample_biblio; >- >- my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue'); >- $mock->mock( 'enqueue', sub { >- my ( $self, $args ) = @_; >- is_deeply( >- $args->{biblio_ids}, >- [ $biblio->id ], >- '->cancel triggers a holds queue update for the related biblio' >- ); >- } ); >- >- # add a hold >- $builder->build_object( >- { >- class => 'Koha::Holds', >- value => { >- biblionumber => $biblio->id, >- } >- } >- ); >- >- C4::Biblio::DelBiblio( $biblio->id ); >- >- $schema->storage->txn_rollback; >- }; > }; > > subtest 'MarcFieldForCreatorAndModifier' => sub { >diff --git a/t/db_dependent/Biblio_holdsqueue.t b/t/db_dependent/Biblio_holdsqueue.t >new file mode 100755 >index 0000000000..5753a3ca94 >--- /dev/null >+++ b/t/db_dependent/Biblio_holdsqueue.t >@@ -0,0 +1,106 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 2; >+use Test::MockModule; >+ >+use t::lib::Mocks; >+use t::lib::TestBuilder; >+ >+use Koha::Database; >+ >+my $schema = Koha::Database->new->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+subtest 'ModBiblio() + holds_queue update tests' => sub { >+ >+ plan tests => 1; >+ >+ $schema->storage->txn_begin; >+ >+ my $biblio = $builder->build_sample_biblio; >+ >+ my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue'); >+ $mock->mock( 'enqueue', sub { >+ my ( $self, $args ) = @_; >+ my ($package, $filename, $line) = caller; >+ is_deeply( >+ $args->{biblio_ids}, >+ [ $biblio->id ], >+ 'ModBiblio triggers a holds queue update for the related biblio' >+ ); >+ } ); >+ >+ # add a hold >+ $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { >+ biblionumber => $biblio->id, >+ } >+ } >+ ); >+ >+ # this call will trigger the mocked 'enqueue' >+ C4::Biblio::ModBiblio( >+ $biblio->metadata->record, $biblio->id, >+ $biblio->frameworkcode, { skip_holds_queue => 0 } >+ ); >+ >+ # this call will not trigger the mocked 'enqueue', so the test count is 1 >+ C4::Biblio::ModBiblio( >+ $biblio->metadata->record, $biblio->id, >+ $biblio->frameworkcode, { skip_holds_queue => 1 } >+ ); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+subtest 'DelBiblio + holds_queue update tests' => sub { >+ >+ plan tests => 1; >+ >+ $schema->storage->txn_begin; >+ >+ my $biblio = $builder->build_sample_biblio; >+ >+ my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue'); >+ $mock->mock( 'enqueue', sub { >+ my ( $self, $args ) = @_; >+ is_deeply( >+ $args->{biblio_ids}, >+ [ $biblio->id ], >+ 'DelBiblio triggers a holds queue update for the related biblio' >+ ); >+ } ); >+ >+ # add a hold >+ $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { >+ biblionumber => $biblio->id, >+ } >+ } >+ ); >+ >+ C4::Biblio::DelBiblio( $biblio->id ); >+ >+ $schema->storage->txn_rollback; >+}; >diff --git a/t/db_dependent/Circulation_holdsqueue.t b/t/db_dependent/Circulation_holdsqueue.t >index 45b5a731d6..3b542f9913 100755 >--- a/t/db_dependent/Circulation_holdsqueue.t >+++ b/t/db_dependent/Circulation_holdsqueue.t >@@ -52,7 +52,7 @@ subtest 'AddIssue() and AddReturn() real-time holds queue tests' => sub { > is_deeply( > $args->{biblio_ids}, > [ $item->biblionumber ], >- "$action triggers a holds queue update for the related biblio from $package" >+ "$action triggers a holds queue update for the related biblio from $package at line $line" > ); > } ); > >-- >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 29346
:
131088
|
131089
|
131811
|
131812
|
131813
|
131815
|
132078
|
132079
|
132080
|
132081
|
132082
|
132083
|
133183
|
133184
|
133185
|
133186
|
133187
|
133188
|
133189
|
133190
|
133191
|
133205
|
133991
|
133992
|
133993
|
133994
|
133995
|
133996
|
133997
|
133998
|
133999
|
134000
|
134001
|
134010
|
134225
|
134227
|
134309
|
134310
|
134311
|
134312
|
134313
|
134314
|
134315
|
134316
|
134317
|
134318
|
134319
|
134320
|
134321
|
134322
|
134328
|
134329
|
134330
|
134331
|
134332
|
134333
|
134334
|
134335
|
134336
|
134337
|
134338
|
134339
|
134340
|
134341
|
134342
|
134343