Bugzilla – Attachment 73920 Details for
Bug 18625
Update borrower last seen from SIP
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18625: QA followup - Unit tests
Bug-18625-QA-followup---Unit-tests.patch (text/plain), 4.95 KB, created by
Kyle M Hall
on 2018-04-10 11:21:35 UTC
(
hide
)
Description:
Bug 18625: QA followup - Unit tests
Filename:
MIME Type:
Creator:
Kyle M Hall
Created:
2018-04-10 11:21:35 UTC
Size:
4.95 KB
patch
obsolete
>From 6c7b6ba9e2859cbcb9d73d7474a69caaa225b0f4 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 27 Oct 2017 02:23:22 +0000 >Subject: [PATCH] Bug 18625: QA followup - Unit tests > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > t/db_dependent/SIP/Message.t | 52 +++++++++++++++++++++++++++++++++++++++++++- > t/db_dependent/SIP/Patron.t | 26 +++++++++++++++++++++- > 2 files changed, 76 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/SIP/Message.t b/t/db_dependent/SIP/Message.t >index 12019c29bf..44fef285d5 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 => 3; >+use Test::More tests => 4; > use Test::MockObject; > use Test::MockModule; > use Test::Warn; >@@ -73,6 +73,56 @@ subtest 'Checkin V2' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'Lastseen response' => sub { >+ >+ my $schema = Koha::Database->new->schema; >+ $schema->storage->txn_begin; >+ >+ plan tests => 6; >+ my $builder = t::lib::TestBuilder->new(); >+ my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; >+ my ( $response, $findpatron ); >+ my $mocks = create_mocks( \$response, \$findpatron, \$branchcode ); >+ my $seen_patron = $builder->build({ >+ source => 'Borrower', >+ value => { >+ lastseen => '2001-01-01', >+ password => hash_password( PATRON_PW ), >+ branchcode => $branchcode, >+ }, >+ }); >+ my $cardnum = $seen_patron->{cardnumber}; >+ my $sip_patron = C4::SIP::ILS::Patron->new( $cardnum ); >+ $findpatron = $sip_patron; >+ >+ my $siprequest = PATRON_INFO. 'engYYYYMMDDZZZZHHMMSS'.'Y '. >+ FID_INST_ID. $branchcode. '|'. >+ FID_PATRON_ID. $cardnum. '|'. >+ FID_PATRON_PWD. PATRON_PW. '|'; >+ my $msg = C4::SIP::Sip::MsgType->new( $siprequest, 0 ); >+ >+ my $server = { ils => $mocks->{ils} }; >+ undef $response; >+ t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '' ); >+ $msg->handle_patron_info( $server ); >+ >+ isnt( $response, undef, 'At least we got a response.' ); >+ my $respcode = substr( $response, 0, 2 ); >+ is( $respcode, PATRON_INFO_RESP, 'Response code fine' ); >+ $seen_patron = Koha::Patrons->find({ cardnumber => $seen_patron->{cardnumber} }); >+ is( output_pref({str => $seen_patron->lastseen(), dateonly => 1}), output_pref({str => '2001-01-01', dateonly => 1}),'Last seen not updated if not tracking patrons'); >+ undef $response; >+ t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '1' ); >+ $msg->handle_patron_info( $server ); >+ >+ isnt( $response, undef, 'At least we got a response.' ); >+ $respcode = substr( $response, 0, 2 ); >+ is( $respcode, PATRON_INFO_RESP, 'Response code fine' ); >+ $seen_patron = Koha::Patrons->find({ cardnumber => $seen_patron->cardnumber() }); >+ is( output_pref({str => $seen_patron->lastseen(), dateonly => 1}), output_pref({dt => dt_from_string(), dateonly => 1}),'Last seen updated if tracking patrons'); >+ $schema->storage->txn_rollback; >+ >+}; > # Here is room for some more subtests > > # END of main code >diff --git a/t/db_dependent/SIP/Patron.t b/t/db_dependent/SIP/Patron.t >index f0a6f667e1..0f20ac3e5c 100755 >--- a/t/db_dependent/SIP/Patron.t >+++ b/t/db_dependent/SIP/Patron.t >@@ -4,9 +4,11 @@ > # This needs to be extended! Your help is appreciated.. > > use Modern::Perl; >-use Test::More tests => 4; >+use Test::More tests => 5; > > use Koha::Database; >+use Koha::Patrons; >+use Koha::DateUtils; > use t::lib::TestBuilder; > use t::lib::Mocks; > use C4::SIP::ILS::Patron; >@@ -114,4 +116,26 @@ subtest "Test build_patron_attribute_string" => sub { > is( $attribute_string, "XYTest Attribute|YZAnother Test Attribute|", 'Attribute field generated correctly with multiple params' ); > }; > >+subtest "update_lastseen tests" => sub { >+ plan tests => 2; >+ >+ my $seen_patron = $builder->build( >+ { >+ source => 'Borrower', >+ value => { >+ lastseen => "2001-01-01", >+ } >+ } >+ ); >+ my $sip_patron = C4::SIP::ILS::Patron->new( $seen_patron->{cardnumber} ); >+ t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '' ); >+ $sip_patron->update_lastseen(); >+ $seen_patron = Koha::Patrons->find({ cardnumber => $seen_patron->{cardnumber} }); >+ is( output_pref({str => $seen_patron->lastseen(), dateonly => 1}), output_pref({str => '2001-01-01', dateonly => 1}),'Last seen not updated if not tracking patrons'); >+ t::lib::Mocks::mock_preference( 'TrackLastPatronActivity', '1' ); >+ $sip_patron->update_lastseen(); >+ $seen_patron = Koha::Patrons->find({ cardnumber => $seen_patron->cardnumber() }); >+ is( output_pref({str => $seen_patron->lastseen(), dateonly => 1}), output_pref({dt => dt_from_string(), dateonly => 1}),'Last seen updated to today if tracking patrons'); >+}; >+ > $schema->storage->txn_rollback; >-- >2.15.1 (Apple Git-101)
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 18625
:
63533
|
67953
|
67954
|
68650
|
68651
|
68652
|
72557
|
72558
| 73920 |
73921
|
73922