Bugzilla – Attachment 161501 Details for
Bug 35461
Renew All 66 SIP server response messages produce HASH content in replies
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35461: Add unit tests
Bug-35461-Add-unit-tests.patch (text/plain), 4.65 KB, created by
Marcel de Rooy
on 2024-01-26 10:40:09 UTC
(
hide
)
Description:
Bug 35461: Add unit tests
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2024-01-26 10:40:09 UTC
Size:
4.65 KB
patch
obsolete
>From cff4981787c56e2ef24a435ab3553baae753ccb4 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 2 Jan 2024 13:01:57 -0500 >Subject: [PATCH] Bug 35461: Add unit tests >Content-Type: text/plain; charset=utf-8 > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >Signed-off-by: David Nind <david@davidnind.com> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > t/db_dependent/SIP/Message.t | 106 ++++++++++++++++++++++++++++++++++- > 1 file changed, 105 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/SIP/Message.t b/t/db_dependent/SIP/Message.t >index c64c019e6e..42628085f6 100755 >--- a/t/db_dependent/SIP/Message.t >+++ b/t/db_dependent/SIP/Message.t >@@ -21,7 +21,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 17; >+use Test::More tests => 18; > use Test::Exception; > use Test::MockObject; > use Test::MockModule; >@@ -96,6 +96,15 @@ subtest 'Test renew desensitize' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'Test renew desensitize' => sub { >+ my $schema = Koha::Database->new->schema; >+ $schema->storage->txn_begin; >+ plan tests => 3; >+ $C4::SIP::Sip::protocol_version = 2; >+ test_renew_all(); >+ $schema->storage->txn_rollback; >+}; >+ > subtest 'Checkin V2' => sub { > my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; >@@ -1295,6 +1304,101 @@ sub test_checkout_desensitize { > is( $respcode, 'Y', "Desensitize flag was set for empty inhouse_item_types" ); > } > >+sub test_renew_all { >+ my $builder = t::lib::TestBuilder->new(); >+ my $branchcode = $builder->build( { source => 'Branch' } )->{branchcode}; >+ my ( $response, $findpatron ); >+ my $mocks = create_mocks( \$response, \$findpatron, \$branchcode ); >+ >+ t::lib::Mocks::mock_preference( 'ItemsDeniedRenewal', 'damaged: [1]' ); >+ >+ # create some data >+ my $patron1 = $builder->build( >+ { >+ source => 'Borrower', >+ value => { >+ password => hash_password(PATRON_PW), >+ }, >+ } >+ ); >+ my $card1 = $patron1->{cardnumber}; >+ my $sip_patron1 = C4::SIP::ILS::Patron->new($card1); >+ my $patron_category = $sip_patron1->ptype(); >+ $findpatron = $sip_patron1; >+ my $item_object_1 = $builder->build_sample_item( >+ { >+ damaged => 0, >+ withdrawn => 0, >+ itemlost => 0, >+ restricted => 0, >+ homebranch => $branchcode, >+ holdingbranch => $branchcode, >+ } >+ ); >+ my $item_object_2 = $builder->build_sample_item( >+ { >+ damaged => 1, >+ withdrawn => 0, >+ itemlost => 0, >+ restricted => 0, >+ homebranch => $branchcode, >+ holdingbranch => $branchcode, >+ } >+ ); >+ >+ my $mockILS = $mocks->{ils}; >+ my $server = { ils => $mockILS, account => {} }; >+ $mockILS->mock( 'institution', sub { $branchcode; } ); >+ $mockILS->mock( 'supports', sub { return; } ); >+ $mockILS->mock( >+ 'renew_all', >+ sub { >+ shift; >+ return C4::SIP::ILS->renew_all(@_); >+ } >+ ); >+ my $today = dt_from_string; >+ t::lib::Mocks::mock_userenv( { branchcode => $branchcode, flags => 1 } ); >+ >+ my $issue_1 = Koha::Checkout->new( >+ { >+ branchcode => $branchcode, >+ borrowernumber => $patron1->{borrowernumber}, >+ itemnumber => $item_object_1->itemnumber >+ } >+ )->store; >+ my $issue_2 = Koha::Checkout->new( >+ { >+ branchcode => $branchcode, >+ borrowernumber => $patron1->{borrowernumber}, >+ itemnumber => $item_object_2->itemnumber >+ } >+ )->store; >+ >+ my $siprequest = >+ RENEW_ALL >+ . siprequestdate($today) >+ . FID_INST_ID >+ . $branchcode . '|' >+ . FID_PATRON_ID >+ . $sip_patron1->id . '|' >+ . FID_TERMINAL_PWD >+ . 'ignored' . '|'; >+ >+ undef $response; >+ my $msg = C4::SIP::Sip::MsgType->new( $siprequest, 0 ); >+ $msg->handle_renew_all($server); >+ isnt( >+ index( $response, "BM" . $item_object_1->barcode ), >+ -1, "Found correct BM for item renewed successfully" >+ ); >+ isnt( >+ index( $response, "BN" . $item_object_2->barcode ), >+ -1, "Found correct BN for item not renewed" >+ ); >+ is( index( $response, "HASH(", ), - 1, "String 'HASH(' not found in reponse ( Bug 35461 )" ); >+} >+ > sub test_renew_desensitize { > my $builder = t::lib::TestBuilder->new(); > my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; >-- >2.30.2
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 35461
:
160419
|
160420
|
160421
|
160436
|
160437
|
160438
|
160453
|
160454
|
160496
|
160497
|
160685
| 161501 |
161502