3 # Tests for SIP::Sip::MsgType
4 # Please help to extend it!
6 # This file is part of Koha.
8 # Copyright 2016 Rijksmuseum
10 # Koha is free software; you can redistribute it and/or modify it
11 # under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 3 of the License, or
13 # (at your option) any later version.
15 # Koha is distributed in the hope that it will be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with Koha; if not, see <http://www.gnu.org/licenses>.
24 use Test
::More tests
=> 4;
30 use t
::lib
::TestBuilder
;
33 use Koha
::AuthUtils
qw(hash_password);
37 use Koha
::Old
::Checkouts
;
41 use C4
::SIP
::ILS
::Patron
;
42 use C4
::SIP
::Sip
qw(write_msg);
43 use C4
::SIP
::Sip
::Constants
qw(:all);
44 use C4
::SIP
::Sip
::MsgType
;
46 use constant PATRON_PW
=> 'do_not_ever_use_this_one';
49 subtest
'Testing Patron Status Request V2' => sub {
50 my $schema = Koha
::Database
->new->schema;
51 $schema->storage->txn_begin;
53 $C4::SIP
::Sip
::protocol_version
= 2;
54 test_request_patron_status_v2
();
55 $schema->storage->txn_rollback;
58 subtest
'Testing Patron Info Request V2' => sub {
59 my $schema = Koha
::Database
->new->schema;
60 $schema->storage->txn_begin;
62 $C4::SIP
::Sip
::protocol_version
= 2;
63 test_request_patron_info_v2
();
64 $schema->storage->txn_rollback;
67 subtest
'Checkin V2' => sub {
68 my $schema = Koha
::Database
->new->schema;
69 $schema->storage->txn_begin;
71 $C4::SIP
::Sip
::protocol_version
= 2;
73 $schema->storage->txn_rollback;
76 subtest
'Lastseen response' => sub {
78 my $schema = Koha
::Database
->new->schema;
79 $schema->storage->txn_begin;
82 my $builder = t
::lib
::TestBuilder
->new();
83 my $branchcode = $builder->build({ source
=> 'Branch' })->{branchcode
};
84 my ( $response, $findpatron );
85 my $mocks = create_mocks
( \
$response, \
$findpatron, \
$branchcode );
86 my $seen_patron = $builder->build({
89 lastseen
=> '2001-01-01',
90 password
=> hash_password
( PATRON_PW
),
91 branchcode
=> $branchcode,
94 my $cardnum = $seen_patron->{cardnumber
};
95 my $sip_patron = C4
::SIP
::ILS
::Patron
->new( $cardnum );
96 $findpatron = $sip_patron;
98 my $siprequest = PATRON_INFO
. 'engYYYYMMDDZZZZHHMMSS'.'Y '.
99 FID_INST_ID
. $branchcode. '|'.
100 FID_PATRON_ID
. $cardnum. '|'.
101 FID_PATRON_PWD
. PATRON_PW
. '|';
102 my $msg = C4
::SIP
::Sip
::MsgType
->new( $siprequest, 0 );
104 my $server = { ils
=> $mocks->{ils
} };
106 t
::lib
::Mocks
::mock_preference
( 'TrackLastPatronActivity', '' );
107 $msg->handle_patron_info( $server );
109 isnt
( $response, undef, 'At least we got a response.' );
110 my $respcode = substr( $response, 0, 2 );
111 is
( $respcode, PATRON_INFO_RESP
, 'Response code fine' );
112 $seen_patron = Koha
::Patrons
->find({ cardnumber
=> $seen_patron->{cardnumber
} });
113 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');
115 t
::lib
::Mocks
::mock_preference
( 'TrackLastPatronActivity', '1' );
116 $msg->handle_patron_info( $server );
118 isnt
( $response, undef, 'At least we got a response.' );
119 $respcode = substr( $response, 0, 2 );
120 is
( $respcode, PATRON_INFO_RESP
, 'Response code fine' );
121 $seen_patron = Koha
::Patrons
->find({ cardnumber
=> $seen_patron->cardnumber() });
122 is
( output_pref
({str
=> $seen_patron->lastseen(), dateonly
=> 1}), output_pref
({dt
=> dt_from_string
(), dateonly
=> 1}),'Last seen updated if tracking patrons');
123 $schema->storage->txn_rollback;
126 # Here is room for some more subtests
130 sub test_request_patron_status_v2
{
131 my $builder = t
::lib
::TestBuilder
->new();
132 my $branchcode = $builder->build({ source
=> 'Branch' })->{branchcode
};
133 my ( $response, $findpatron );
134 my $mocks = create_mocks
( \
$response, \
$findpatron, \
$branchcode );
136 my $patron1 = $builder->build({
137 source
=> 'Borrower',
139 password
=> hash_password
( PATRON_PW
),
142 my $card1 = $patron1->{cardnumber
};
143 my $sip_patron1 = C4
::SIP
::ILS
::Patron
->new( $card1 );
144 $findpatron = $sip_patron1;
146 my $siprequest = PATRON_STATUS_REQ
. 'engYYYYMMDDZZZZHHMMSS'.
147 FID_INST_ID
. $branchcode. '|'.
148 FID_PATRON_ID
. $card1. '|'.
149 FID_PATRON_PWD
. PATRON_PW
. '|';
150 my $msg = C4
::SIP
::Sip
::MsgType
->new( $siprequest, 0 );
152 my $server = { ils
=> $mocks->{ils
} };
154 $msg->handle_patron_status( $server );
156 isnt
( $response, undef, 'At least we got a response.' );
157 my $respcode = substr( $response, 0, 2 );
158 is
( $respcode, PATRON_STATUS_RESP
, 'Response code fine' );
160 check_field
( $respcode, $response, FID_INST_ID
, $branchcode , 'Verified institution id' );
161 check_field
( $respcode, $response, FID_PATRON_ID
, $card1, 'Verified patron id' );
162 check_field
( $respcode, $response, FID_PERSONAL_NAME
, $patron1->{surname
}, 'Verified patron name', 'contains' );
163 check_field
( $respcode, $response, FID_VALID_PATRON
, 'Y', 'Verified code BL' );
164 check_field
( $respcode, $response, FID_VALID_PATRON_PWD
, 'Y', 'Verified code CQ' );
165 check_field
( $respcode, $response, FID_SCREEN_MSG
, '.+', 'Verified non-empty screen message', 'regex' );
167 # Now, we pass a wrong password and verify CQ again
168 $siprequest = PATRON_STATUS_REQ
. 'engYYYYMMDDZZZZHHMMSS'.
169 FID_INST_ID
. $branchcode. '|'.
170 FID_PATRON_ID
. $card1. '|'.
171 FID_PATRON_PWD
. 'wrong_password'. '|';
172 $msg = C4
::SIP
::Sip
::MsgType
->new( $siprequest, 0 );
174 $msg->handle_patron_status( $server );
175 $respcode = substr( $response, 0, 2 );
176 check_field
( $respcode, $response, FID_VALID_PATRON_PWD
, 'N', 'Verified code CQ for wrong pw' );
178 # Check empty password and verify CQ again
179 $siprequest = PATRON_STATUS_REQ
. 'engYYYYMMDDZZZZHHMMSS'.
180 FID_INST_ID
. $branchcode. '|'.
181 FID_PATRON_ID
. $card1. '|'.
183 $msg = C4
::SIP
::Sip
::MsgType
->new( $siprequest, 0 );
185 $msg->handle_patron_status( $server );
186 $respcode = substr( $response, 0, 2 );
187 check_field
( $respcode, $response, FID_VALID_PATRON_PWD
, 'N', 'code CQ should be N for empty AD' );
189 # Finally, we send a wrong card number and check AE, BL
190 # This is done by removing the new patron first
191 Koha
::Patrons
->search({ cardnumber
=> $card1 })->delete;
193 $siprequest = PATRON_STATUS_REQ
. 'engYYYYMMDDZZZZHHMMSS'.
194 FID_INST_ID
. $branchcode. '|'.
195 FID_PATRON_ID
. $card1. '|'.
196 FID_PATRON_PWD
. PATRON_PW
. '|';
197 $msg = C4
::SIP
::Sip
::MsgType
->new( $siprequest, 0 );
199 $msg->handle_patron_status( $server );
200 $respcode = substr( $response, 0, 2 );
201 check_field
( $respcode, $response, FID_VALID_PATRON
, 'N', 'Verified code BL for wrong cardnumber' );
202 check_field
( $respcode, $response, FID_PERSONAL_NAME
, '', 'Name should be empty now' );
203 check_field
( $respcode, $response, FID_SCREEN_MSG
, '.+', 'But we have a screen msg', 'regex' );
206 sub test_request_patron_info_v2
{
207 my $builder = t
::lib
::TestBuilder
->new();
208 my $branchcode = $builder->build({ source
=> 'Branch' })->{branchcode
};
209 my ( $response, $findpatron );
210 my $mocks = create_mocks
( \
$response, \
$findpatron, \
$branchcode );
212 my $patron2 = $builder->build({
213 source
=> 'Borrower',
215 password
=> hash_password
( PATRON_PW
),
218 my $card = $patron2->{cardnumber
};
219 my $sip_patron2 = C4
::SIP
::ILS
::Patron
->new( $card );
220 $findpatron = $sip_patron2;
221 my $siprequest = PATRON_INFO
. 'engYYYYMMDDZZZZHHMMSS'.'Y '.
222 FID_INST_ID
. $branchcode. '|'.
223 FID_PATRON_ID
. $card. '|'.
224 FID_PATRON_PWD
. PATRON_PW
. '|';
225 my $msg = C4
::SIP
::Sip
::MsgType
->new( $siprequest, 0 );
227 my $server = { ils
=> $mocks->{ils
} };
229 $msg->handle_patron_info( $server );
230 isnt
( $response, undef, 'At least we got a response.' );
231 my $respcode = substr( $response, 0, 2 );
232 is
( $respcode, PATRON_INFO_RESP
, 'Response code fine' );
234 check_field
( $respcode, $response, FID_INST_ID
, $branchcode , 'Verified institution id' );
235 check_field
( $respcode, $response, FID_PATRON_ID
, $card, 'Verified patron id' );
236 check_field
( $respcode, $response, FID_PERSONAL_NAME
, $patron2->{surname
}, 'Verified patron name', 'contains' );
237 check_field
( $respcode, $response, FID_VALID_PATRON
, 'Y', 'Verified code BL' );
238 check_field
( $respcode, $response, FID_VALID_PATRON_PWD
, 'Y', 'Verified code CQ' );
239 check_field
( $respcode, $response, FID_FEE_LMT
, '.*', 'Checked existence of fee limit', 'regex' );
240 check_field
( $respcode, $response, FID_HOME_ADDR
, $patron2->{address
}, 'Address in BD', 'contains' );
241 check_field
( $respcode, $response, FID_EMAIL
, $patron2->{email
}, 'Verified email in BE' );
242 check_field
( $respcode, $response, FID_HOME_PHONE
, $patron2->{phone
}, 'Verified home phone in BF' );
243 # No check for custom fields here (unofficial PB, PC and PI)
244 check_field
( $respcode, $response, FID_SCREEN_MSG
, '.+', 'We have a screen msg', 'regex' );
246 # Test customized patron name in AE with same sip request
247 # This implicitly tests C4::SIP::ILS::Patron->name
248 $server->{account
}->{ae_field_template
} = "X[% patron.surname %]Y";
249 $msg = C4
::SIP
::Sip
::MsgType
->new( $siprequest, 0 );
251 $msg->handle_patron_info( $server );
252 $respcode = substr( $response, 0, 2 );
253 check_field
( $respcode, $response, FID_PERSONAL_NAME
, 'X' . $patron2->{surname
} . 'Y', 'Check customized patron name' );
255 # Check empty password and verify CQ again
256 $siprequest = PATRON_INFO
. 'engYYYYMMDDZZZZHHMMSS'.'Y '.
257 FID_INST_ID
. $branchcode. '|'.
258 FID_PATRON_ID
. $card. '|'.
260 $msg = C4
::SIP
::Sip
::MsgType
->new( $siprequest, 0 );
262 $msg->handle_patron_info( $server );
263 $respcode = substr( $response, 0, 2 );
264 check_field
( $respcode, $response, FID_VALID_PATRON_PWD
, 'N', 'code CQ should be N for empty AD' );
265 # Test empty password is OK if account configured to allow
266 $server->{account
}->{allow_empty_passwords
} = 1;
267 $msg = C4
::SIP
::Sip
::MsgType
->new( $siprequest, 0 );
269 $msg->handle_patron_info( $server );
270 $respcode = substr( $response, 0, 2 );
271 check_field
( $respcode, $response, FID_VALID_PATRON_PWD
, 'Y', 'code CQ should be Y if empty AD allowed' );
273 t
::lib
::Mocks
::mock_preference
( 'FailedLoginAttempts', '1' );
274 my $patron = Koha
::Patrons
->find({ cardnumber
=> $card });
275 $patron->update({ login_attempts
=> 0 });
276 is
( $patron->account_locked, 0, "Patron account not locked already" );
277 $msg->handle_patron_info( $server );
278 $patron = Koha
::Patrons
->find({ cardnumber
=> $card });
279 is
( $patron->account_locked, 0, "Patron account is not locked by patron info messages with empty password" );
281 # Finally, we send a wrong card number
282 Koha
::Patrons
->search({ cardnumber
=> $card })->delete;
284 $msg = C4
::SIP
::Sip
::MsgType
->new( $siprequest, 0 );
286 $msg->handle_patron_info( $server );
287 $respcode = substr( $response, 0, 2 );
288 check_field
( $respcode, $response, FID_VALID_PATRON
, 'N', 'Verified code BL for wrong cardnumber' );
289 check_field
( $respcode, $response, FID_PERSONAL_NAME
, '', 'Name should be empty now' );
290 check_field
( $respcode, $response, FID_SCREEN_MSG
, '.+', 'But we have a screen msg', 'regex' );
293 sub test_checkin_v2
{
294 my $builder = t
::lib
::TestBuilder
->new();
295 my $branchcode = $builder->build({ source
=> 'Branch' })->{branchcode
};
296 my ( $response, $findpatron );
297 my $mocks = create_mocks
( \
$response, \
$findpatron, \
$branchcode );
300 my $patron1 = $builder->build({
301 source
=> 'Borrower',
303 password
=> hash_password
( PATRON_PW
),
306 my $card1 = $patron1->{cardnumber
};
307 my $sip_patron1 = C4
::SIP
::ILS
::Patron
->new( $card1 );
308 $findpatron = $sip_patron1;
309 my $item = $builder->build({
311 value
=> { damaged
=> 0, withdrawn
=> 0, itemlost
=> 0, restricted
=> 0, homebranch
=> $branchcode, holdingbranch
=> $branchcode },
314 my $mockILS = $mocks->{ils
};
315 my $server = { ils
=> $mockILS, account
=> {} };
316 $mockILS->mock( 'institution', sub { $branchcode; } );
317 $mockILS->mock( 'supports', sub { return; } );
318 $mockILS->mock( 'checkin', sub {
320 return C4
::SIP
::ILS
->checkin(@_);
322 my $today = dt_from_string
;
324 # Checkin invalid barcode
325 Koha
::Items
->search({ barcode
=> 'not_to_be_found' })->delete;
326 my $siprequest = CHECKIN
. 'N' . 'YYYYMMDDZZZZHHMMSS' .
327 siprequestdate
( $today->clone->add( days
=> 1) ) .
328 FID_INST_ID
. $branchcode . '|'.
329 FID_ITEM_ID
. 'not_to_be_found' . '|' .
330 FID_TERMINAL_PWD
. 'ignored' . '|';
332 my $msg = C4
::SIP
::Sip
::MsgType
->new( $siprequest, 0 );
333 warnings_like
{ $msg->handle_checkin( $server ); }
334 [ qr/No item 'not_to_be_found'/, qr/no item found in object to resensitize/ ],
335 'Checkin of invalid item with two warnings';
336 my $respcode = substr( $response, 0, 2 );
337 is
( $respcode, CHECKIN_RESP
, 'Response code fine' );
338 is
( substr($response,2,1), '0', 'OK flag is false' );
339 is
( substr($response,5,1), 'Y', 'Alert flag is set' );
340 check_field
( $respcode, $response, FID_SCREEN_MSG
, 'Invalid Item', 'Check screen msg', 'regex' );
342 # Not checked out, toggle option checked_in_ok
343 $siprequest = CHECKIN
. 'N' . 'YYYYMMDDZZZZHHMMSS' .
344 siprequestdate
( $today->clone->add( days
=> 1) ) .
345 FID_INST_ID
. $branchcode . '|'.
346 FID_ITEM_ID
. $item->{barcode
} . '|' .
347 FID_TERMINAL_PWD
. 'ignored' . '|';
349 $msg = C4
::SIP
::Sip
::MsgType
->new( $siprequest, 0 );
350 $msg->handle_checkin( $server );
351 $respcode = substr( $response, 0, 2 );
352 is
( substr($response,2,1), '0', 'OK flag is false when checking in an item that was not checked out' );
353 is
( substr($response,5,1), 'Y', 'Alert flag is set' );
354 check_field
( $respcode, $response, FID_SCREEN_MSG
, 'not checked out', 'Check screen msg', 'regex' );
356 $server->{account
}->{checked_in_ok
} = 1;
358 $msg = C4
::SIP
::Sip
::MsgType
->new( $siprequest, 0 );
359 $msg->handle_checkin( $server );
360 is
( substr($response,2,1), '1', 'OK flag is true now with checked_in_ok flag set when checking in an item that was not checked out' );
361 is
( substr($response,5,1), 'N', 'Alert flag no longer set' );
362 check_field
( $respcode, $response, FID_SCREEN_MSG
, undef, 'No screen msg' );
363 $server->{account
}->{checked_in_ok
} = 0;
365 $server->{account
}->{checked_in_ok
} = 1;
366 $server->{account
}->{cv_send_00_on_success
} = 0;
368 $msg = C4
::SIP
::Sip
::MsgType
->new( $siprequest, 0 );
369 $msg->handle_checkin( $server );
370 $respcode = substr( $response, 0, 2 );
371 check_field
( $respcode, $response, FID_ALERT_TYPE
, undef, 'No FID_ALERT_TYPE (CV) field' );
372 $server->{account
}->{cv_send_00_on_success
} = 1;
374 $msg = C4
::SIP
::Sip
::MsgType
->new( $siprequest, 0 );
375 $msg->handle_checkin( $server );
376 $respcode = substr( $response, 0, 2 );
377 check_field
( $respcode, $response, FID_ALERT_TYPE
, '00', 'FID_ALERT_TYPE (CV) field is 00' );
378 $server->{account
}->{checked_in_ok
} = 0;
379 $server->{account
}->{cv_send_00_on_success
} = 0;
381 t
::lib
::Mocks
::mock_preference
( 'RecordLocalUseOnReturn', '1' );
382 $server->{account
}->{checked_in_ok
} = 0;
383 $server->{account
}->{cv_triggers_alert
} = 0;
385 $msg = C4
::SIP
::Sip
::MsgType
->new( $siprequest, 0 );
386 $msg->handle_checkin( $server );
387 $respcode = substr( $response, 0, 2 );
388 is
( substr( $response, 5, 1 ), 'Y', 'Checkin without CV triggers alert flag when cv_triggers_alert is off' );
389 t
::lib
::Mocks
::mock_preference
( 'RecordLocalUseOnReturn', '0' );
390 $server->{account
}->{cv_triggers_alert
} = 1;
392 $msg = C4
::SIP
::Sip
::MsgType
->new( $siprequest, 0 );
393 $msg->handle_checkin( $server );
394 $respcode = substr( $response, 0, 2 );
395 is
( substr( $response, 5, 1 ), 'N', 'Checkin without CV does not trigger alert flag when cv_triggers_alert is on' );
396 $server->{account
}->{cv_triggers_alert
} = 0;
397 t
::lib
::Mocks
::mock_preference
( 'RecordLocalUseOnReturn', '1' );
399 $server->{account
}->{checked_in_ok
} = 1;
400 $server->{account
}->{ct_always_send
} = 0;
402 $msg = C4
::SIP
::Sip
::MsgType
->new( $siprequest, 0 );
403 $msg->handle_checkin( $server );
404 $respcode = substr( $response, 0, 2 );
405 check_field
( $respcode, $response, FID_DESTINATION_LOCATION
, undef, 'No FID_DESTINATION_LOCATION (CT) field' );
406 $server->{account
}->{ct_always_send
} = 1;
408 $msg = C4
::SIP
::Sip
::MsgType
->new( $siprequest, 0 );
409 $msg->handle_checkin( $server );
410 $respcode = substr( $response, 0, 2 );
411 check_field
( $respcode, $response, FID_DESTINATION_LOCATION
, q{}, 'FID_DESTINATION_LOCATION (CT) field is empty but present' );
412 $server->{account
}->{checked_in_ok
} = 0;
413 $server->{account
}->{ct_always_send
} = 0;
415 # Checkin at wrong branch: issue item and switch branch, and checkin
416 my $issue = Koha
::Checkout
->new({ branchcode
=> $branchcode, borrowernumber
=> $patron1->{borrowernumber
}, itemnumber
=> $item->{itemnumber
} })->store;
417 $branchcode = $builder->build({ source
=> 'Branch' })->{branchcode
};
418 t
::lib
::Mocks
::mock_preference
( 'AllowReturnToBranch', 'homebranch' );
420 $msg = C4
::SIP
::Sip
::MsgType
->new( $siprequest, 0 );
421 $msg->handle_checkin( $server );
422 is
( substr($response,2,1), '0', 'OK flag is false when we check in at the wrong branch and we do not allow it' );
423 is
( substr($response,5,1), 'Y', 'Alert flag is set' );
424 check_field
( $respcode, $response, FID_SCREEN_MSG
, 'Checkin failed', 'Check screen msg' );
425 $branchcode = $item->{homebranch
}; # switch back
426 t
::lib
::Mocks
::mock_preference
( 'AllowReturnToBranch', 'anywhere' );
428 # Data corrupted: add same issue_id to old_issues
429 Koha
::Old
::Checkout
->new({ issue_id
=> $issue->issue_id })->store;
431 $msg = C4
::SIP
::Sip
::MsgType
->new( $siprequest, 0 );
432 warnings_like
{ $msg->handle_checkin( $server ); }
433 [ qr/Duplicate entry/, qr/data corrupted/ ],
434 'DBIx error on duplicate issue_id';
435 is
( substr($response,2,1), '0', 'OK flag is false when we encounter data corruption in old_issues' );
436 is
( substr($response,5,1), 'Y', 'Alert flag is set' );
437 check_field
( $respcode, $response, FID_SCREEN_MSG
, 'Checkin failed: data problem', 'Check screen msg' );
439 # Finally checkin without problems (remove duplicate id)
440 Koha
::Old
::Checkouts
->search({ issue_id
=> $issue->issue_id })->delete;
442 $msg = C4
::SIP
::Sip
::MsgType
->new( $siprequest, 0 );
443 $msg->handle_checkin( $server );
444 is
( substr($response,2,1), '1', 'OK flag is true when we checkin after removing the duplicate' );
445 is
( substr($response,5,1), 'N', 'Alert flag is not set' );
446 is
( Koha
::Checkouts
->find( $issue->issue_id ), undef,
447 'Issue record is gone now' );
453 my ( $response, $findpatron, $branchcode ) = @_; # referenced variables !
455 # mock write_msg (imported from Sip.pm into Message.pm)
456 my $mockMsg = Test
::MockModule
->new( 'C4::SIP::Sip::MsgType' );
457 $mockMsg->mock( 'write_msg', sub { $$response = $_[1]; } ); # save response
460 my $mockILS = Test
::MockObject
->new;
461 $mockILS->mock( 'check_inst_id', sub {} );
462 $mockILS->mock( 'institution_id', sub { $$branchcode; } );
463 $mockILS->mock( 'find_patron', sub { $$findpatron; } );
465 return { ils
=> $mockILS, message
=> $mockMsg };
469 my ( $code, $resp, $fld, $expr, $msg, $mode ) = @_;
470 # mode: contains || equals || regex (by default: equals)
472 # strip fixed part; prefix to simplify next regex
473 $resp = '|'. substr( $resp, fixed_length
( $code ) );
475 if( $resp =~ /\|$fld([^\|]*)\|/ ) {
477 } elsif( !defined($expr) ) { # field should not be found
480 } else { # test fails
481 is
( 0, 1, "Code $fld not found in '$resp'?" );
485 if( !$mode || $mode eq 'equals' ) { # default
486 is
( $fldval, $expr, $msg );
487 } elsif( $mode eq 'regex' ) {
488 is
( $fldval =~ /$expr/, 1, $msg );
490 is
( index( $fldval, $expr ) > -1, 1, $msg );
496 return $dt->ymd('').(' 'x4
).$dt->hms('');
499 sub fixed_length
{ #length of fixed fields including response code
501 ( PATRON_STATUS_RESP
) => 37,
502 ( PATRON_INFO_RESP
) => 61,
503 ( CHECKIN_RESP
) => 24,