From beb7cd0d9e17dd7a8511a99a9003d4fccf95888b Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 20 Sep 2023 16:00:08 +0200 Subject: [PATCH] Bug 34848: Fix SIP/Message.t if DB has been upgraded Content-Type: text/plain; charset=utf-8 There were a lot of failures (in the context of bug 34841) t/db_dependent/SIP/Message.t .. 2/16 # Failed test 'Found AH field as timestamp in response' # at t/db_dependent/SIP/Message.t line 820. # Failed test 'Found AH field as SQL date in response' # at t/db_dependent/SIP/Message.t line 825. # Looks like you failed 2 tests of 8. t/db_dependent/SIP/Message.t .. 3/16 # Failed test 'Desensitize flag was set for patron category not in inhouse_patron_categories' # at t/db_dependent/SIP/Message.t line 1133. # got: 'N' # expected: 'Y' # Failed test 'Desensitize flag was set for empty inhouse_patron_categories' # at t/db_dependent/SIP/Message.t line 1139. # got: 'N' # expected: 'Y' Because renewalsallowed is 0 for upgraded DB, when it's 5 for new install. We need to set the value. This patch also adds some missing transaction Signed-off-by: David Nind Signed-off-by: Marcel de Rooy --- t/db_dependent/SIP/Message.t | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/t/db_dependent/SIP/Message.t b/t/db_dependent/SIP/Message.t index e4f0e38385..0ac278c4b3 100755 --- a/t/db_dependent/SIP/Message.t +++ b/t/db_dependent/SIP/Message.t @@ -35,6 +35,7 @@ use C4::Circulation qw( AddIssue AddReturn ); use Koha::Database; use Koha::AuthUtils qw(hash_password); use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::CirculationRules; use Koha::Items; use Koha::Checkouts; use Koha::Old::Checkouts; @@ -380,6 +381,9 @@ subtest "Test build_custom_field_string" => sub { }; subtest "Test cr_item_field" => sub { + my $schema = Koha::Database->new->schema; + $schema->storage->txn_begin; + plan tests => 8; my $builder = t::lib::TestBuilder->new(); @@ -483,6 +487,8 @@ subtest "Test cr_item_field" => sub { $msg = C4::SIP::Sip::MsgType->new( $siprequest, 0 ); $msg->handle_item_information( $server ); ok( $response =~ m/AH1999-01-01 12:59/, "Found correct CR field in response"); + + $schema->storage->txn_rollback; }; subtest 'Patron info summary > 5 should not crash server' => sub { @@ -575,6 +581,7 @@ subtest 'SC status tests' => sub { dies_ok{ $msg->handle_sc_status( $server ) } ,"Dies if sip user cannot be found"; + $schema->storage->txn_rollback; }; # Here is room for some more subtests @@ -761,6 +768,8 @@ sub test_checkout_v2 { my ( $response, $findpatron ); my $mocks = create_mocks( \$response, \$findpatron, \$branchcode ); + + # create some data my $patron1 = $builder->build({ source => 'Borrower', @@ -1262,6 +1271,16 @@ sub create_mocks { $mockILS->mock( 'institution_id', sub { $$branchcode; } ); $mockILS->mock( 'find_patron', sub { $$findpatron; } ); + Koha::CirculationRules->set_rule( + { + categorycode => undef, + itemtype => undef, + branchcode => undef, + rule_name => 'renewalsallowed', + rule_value => '5', + } + ); + return { ils => $mockILS, message => $mockMsg }; } -- 2.30.2