3 # Copyright (C) 2006-2008 Georgia Public Library Service
5 # Author: David J. Fiander
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of version 2 of the GNU General Public
9 # License as published by the Free Software Foundation.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public
17 # License along with this program; if not, write to the Free
18 # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 # patron_status: test Patron Status Response
27 use Sip::Constants qw(:all);
29 use SIPtest qw($datepat $textpat $instid $user_barcode $password);
31 my $patron_status_test_template = {
32 id => 'Patron Status: valid patron, no patron password',
33 msg => "2300120060101 084237AO$instid|AA$user_barcode|AC$password|",
34 pat => qr/^24 [ Y]{13}001$datepat/,
36 $SIPtest::field_specs{(FID_INST_ID)},
37 $SIPtest::field_specs{(FID_SCREEN_MSG)},
38 $SIPtest::field_specs{(FID_PRINT_LINE)},
39 { field => FID_PATRON_ID,
40 pat => qr/^$user_barcode$/,
42 { field => FID_PERSONAL_NAME,
43 pat => qr/^David J\. Fiander$/,
45 { field => FID_VALID_PATRON,
47 # Not required by the spec, but by the test
49 $SIPtest::field_specs{(FID_CURRENCY)},
50 { field => FID_FEE_AMT,
57 $SIPtest::sc_status_test,
58 clone($patron_status_test_template),
62 my $test = clone($patron_status_test_template);
64 $test->{id} = 'Patron Status: invalid id';
65 $test->{msg} =~ s/AA$user_barcode\|/AAbad_userid|/ or warn "Substitution failed on test clone";
67 # The test assumes that the language sent by the terminal is
68 # just echoed back for invalid patrons.
69 $test->{pat} = qr/^24Y[ Y]{13}001$datepat/;
71 delete $test->{fields};
73 $SIPtest::field_specs{(FID_INST_ID)},
74 $SIPtest::field_specs{(FID_SCREEN_MSG)},
75 $SIPtest::field_specs{(FID_PRINT_LINE)},
76 { field => FID_PATRON_ID,
77 pat => qr/^bad_userid$/,
79 { field => FID_PERSONAL_NAME,
82 { field => FID_VALID_PATRON,
89 # Valid patron, invalid patron password
90 $test = clone($patron_status_test_template);
91 $test->{id} = 'Patron Status: Valid patron, invalid patron password';
92 $test->{msg} .= (FID_PATRON_PWD) . 'badpwd|';
93 $test->{pat} = qr/^24[ Y]{14}001$datepat/;
94 delete $test->{fields};
96 $SIPtest::field_specs{(FID_INST_ID)},
97 $SIPtest::field_specs{(FID_SCREEN_MSG)},
98 $SIPtest::field_specs{(FID_PRINT_LINE)},
99 { field => FID_PATRON_ID,
100 pat => qr/^$user_barcode$/,
102 { field => FID_PERSONAL_NAME,
103 pat => qr/^David J\. Fiander$/,
105 { field => FID_VALID_PATRON,
108 { field => FID_VALID_PATRON_PWD,
114 # TODO: Need multiple patrons to test each individual
117 SIPtest::run_sip_tests(@tests);