2 # patron_enable: test Patron Enable Response
8 use Sip::Constants qw(:all);
10 use SIPtest qw($datepat $textpat);
12 my $hold_test_template = {
13 id => 'Place Hold: valid item, valid patron',
14 msg => '15+20060415 110158BW20060815 110158|BSTaylor|BY2|AOUWOLS|AAdjfiander|AB1565921879|',
15 pat => qr/^161N$datepat/,
17 $SIPtest::field_specs{(FID_INST_ID)},
18 $SIPtest::field_specs{(FID_SCREEN_MSG)},
19 $SIPtest::field_specs{(FID_PRINT_LINE)},
20 { field => FID_PATRON_ID,
21 pat => qr/^djfiander$/,
23 { field => FID_EXPIRATION,
26 { field => FID_QUEUE_POS,
29 { field => FID_PICKUP_LOCN,
32 { field => FID_TITLE_ID,
33 pat => qr/^Perl 5 desktop reference$/,
35 { field => FID_ITEM_ID,
36 pat => qr/^1565921879$/,
40 my $hold_count_test_template0 = {
41 id => 'Confirm patron has 0 holds',
42 msg => '6300020060329 201700 AOUWOLS|AAdjfiander|',
43 pat => qr/^64 [ Y]{13}\d{3}${datepat}0000(\d{4}){5}/,
47 my $hold_count_test_template1 = {
48 id => 'Confirm patron has 1 hold',
49 msg => '6300020060329 201700 AOUWOLS|AAdjfiander|',
50 pat => qr/^64 [ Y]{13}\d{3}${datepat}0001(\d{4}){5}/,
57 $SIPtest::sc_status_test,
58 $hold_test_template, $hold_count_test_template1,
63 # Hold Queue: second hold placed on item
64 $test = clone($hold_test_template);
65 $test->{id} = 'Place hold: second hold on item';
66 $test->{msg} =~ s/djfiander/miker/;
67 $test->{pat} = qr/^161N$datepat/;
68 foreach my $i (0 .. (scalar @{$test->{fields}})-1) {
69 my $field = $test->{fields}[$i];
71 if ($field->{field} eq FID_PATRON_ID) {
72 $field->{pat} = qr/^miker$/;
73 } elsif ($field->{field} eq FID_QUEUE_POS) {
74 $field->{pat} = qr/^2$/;
80 # Cancel hold: valid hold
81 $test = clone($hold_test_template);
82 $test->{id} = 'Cancel hold: valid hold';
83 $test->{msg} =~ s/\+/-/;
84 $test->{pat} = qr/^161[NY]$datepat/;
85 delete $test->{fields};
87 $SIPtest::field_specs{(FID_INST_ID)},
88 $SIPtest::field_specs{(FID_SCREEN_MSG)},
89 $SIPtest::field_specs{(FID_PRINT_LINE)},
90 { field => FID_PATRON_ID,
91 pat => qr/^djfiander$/,
95 push @tests, $test, $hold_count_test_template0;
97 # Cancel Hold: no hold on item
98 # $test is already set up to cancel a hold, just change
100 $test = clone($test);
101 $test->{id} = 'Cancel Hold: no hold on specified item';
102 $test->{pat} = qr/^160N$datepat/;
104 push @tests, $test, $hold_count_test_template0;
106 # Cleanup: cancel miker's hold too.
107 $test = clone($hold_test_template);
108 $test->{id} = "Cancel hold: cleanup second patron's hold";
109 $test->{msg} =~ s/\+/-/;
110 $test->{msg} =~ s/djfiander/miker/;
111 $test->{pat} = qr/^161[NY]$datepat/;
112 delete $test->{fields};
114 $SIPtest::field_specs{(FID_INST_ID)},
115 $SIPtest::field_specs{(FID_SCREEN_MSG)},
116 $SIPtest::field_specs{(FID_PRINT_LINE)},
117 { field => FID_PATRON_ID,
124 # Place hold: valid patron, item, invalid patron pwd
125 $test = clone($hold_test_template);
126 $test->{id} = 'Place hold: invalid patron password';
127 $test->{msg} .= FID_PATRON_PWD . 'bad password|';
128 $test->{pat} = qr/^160N$datepat/;
129 delete $test->{fields};
131 $SIPtest::field_specs{(FID_INST_ID)},
132 $SIPtest::field_specs{(FID_SCREEN_MSG)},
133 $SIPtest::field_specs{(FID_PRINT_LINE)},
134 { field => FID_PATRON_ID,
135 pat => qr/^djfiander$/,
139 push @tests, $test, $hold_count_test_template0;
141 # Place hold: invalid patron
142 $test = clone($hold_test_template);
143 $test->{id} = 'Place hold: invalid patron';
144 $test->{msg} =~ s/AAdjfiander\|/AAberick|/;
145 $test->{pat} = qr/^160N$datepat/;
146 delete $test->{fields};
148 $SIPtest::field_specs{(FID_INST_ID)},
149 $SIPtest::field_specs{(FID_SCREEN_MSG)},
150 $SIPtest::field_specs{(FID_PRINT_LINE)},
151 { field => FID_PATRON_ID,
156 # There's no patron to check the number of holds against
159 # Place hold: invalid item
160 $test = clone($hold_test_template);
161 $test->{id} = 'Place hold: invalid item';
162 $test->{msg} =~ s/AB1565921879\|/ABnosuchitem|/;
163 $test->{pat} = qr/^160N$datepat/;
164 delete $test->{fields};
166 $SIPtest::field_specs{(FID_INST_ID)},
167 $SIPtest::field_specs{(FID_SCREEN_MSG)},
168 $SIPtest::field_specs{(FID_PRINT_LINE)},
169 { field => FID_PATRON_ID,
170 pat => qr/^djfiander$/,
172 { field => FID_ITEM_ID,
173 pat => qr/^nosuchitem$/,
177 push @tests, $test, $hold_count_test_template0;
179 # Still need tests for:
180 # - valid patron not permitted to place holds
181 # - valid item, not allowed to hold item
182 # - multiple holds on item: correct queue position management
183 # - setting and verifying hold expiry dates (requires ILS support)
185 SIPtest::run_sip_tests(@tests);