2 # patron_enable: test Patron Enable Response
8 use Sip::Constants qw(:all);
10 use SIPtest qw(:basic :user1 :user2 :item1 :item2);
12 my $hold_test_template = {
13 id => "Place Hold: valid item ($item_barcode), valid patron ($user_barcode)", #BS could be another branch
14 msg => "15+20060415 110158BW20060815 110158|BS$instid|BY2|AO$instid|AA$user_barcode|AB$item_barcode|",
15 pat => qr/^161Y$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/^$user_barcode$/,
23 { field => FID_EXPIRATION,
26 { field => FID_QUEUE_POS,
29 { field => FID_PICKUP_LOCN,
30 pat => qr/^$item_owner$/,
32 { field => FID_TITLE_ID,
33 pat => qr/^$item_title$/,
35 { field => FID_ITEM_ID,
36 pat => qr/^$item_barcode$/,
40 my $tmp_msg = "6300020060329 201700 AO$instid|AA$user_barcode|";
41 my $hold_count_test_template0 = {
42 id => "Confirm patron ($user_barcode) has 0 holds",
44 pat => qr/^64 [ Y]{13}\d{3}${datepat}0000(\d{4}){5}/,
47 my $hold_count_test_template1 = {
48 id => "Confirm patron ($user_barcode) has 1 hold",
50 pat => qr/^64 [ Y]{13}\d{3}${datepat}((0001(\d{4}){4}0000)|(0000(\d{4}){4}0001))/,
51 # The tricky part at the end here is because we don't know whether
52 # the hold will count as "waiting" or unavailable.
53 # But it will be one or the other!
58 $SIPtest::login_test, # 1
59 $SIPtest::sc_status_test, # 2
60 $hold_test_template, $hold_count_test_template1, # 3,4
65 # Hold Queue: second hold placed on item
66 $test = clone($hold_test_template);
67 $test->{id} = "Place 2nd hold on item ($item_barcode) for user ($user2_barcode)";
68 $test->{msg} =~ s/AA$user_barcode\|/AA$user2_barcode|/;
69 $test->{pat} = qr/^161N$datepat/;
70 foreach my $i (0 .. (scalar @{$test->{fields}})-1) {
71 my $field = $test->{fields}[$i];
72 if ($field->{field} eq FID_PATRON_ID) {
73 $field->{pat} = qr/^$user2_barcode$/;
74 } elsif ($field->{field} eq FID_QUEUE_POS) {
75 $field->{pat} = qr/^2$/;
79 push @tests, $test; # 5
81 # Cancel hold: valid hold
82 $test = clone($hold_test_template);
83 $test->{id} = "Cancel Hold: valid hold for user ($user_barcode)";
84 $test->{msg} =~ s/\+/-/;
85 $test->{pat} = qr/^161[NY]$datepat/;
86 delete $test->{fields};
88 $SIPtest::field_specs{(FID_INST_ID)},
89 $SIPtest::field_specs{(FID_SCREEN_MSG)},
90 $SIPtest::field_specs{(FID_PRINT_LINE)},
91 { field => FID_PATRON_ID,
92 pat => qr/^$user_barcode$/,
96 push @tests, $test, $hold_count_test_template0; # 6,7
98 # Cancel Hold: no hold on item
99 # $test is already set up to cancel a hold, just change
101 $test = clone($test);
102 $test->{id} = 'Cancel Hold: no hold on specified item';
103 $test->{pat} = qr/^160N$datepat/;
105 push @tests, $test, $hold_count_test_template0; # 8,9
107 # Cleanup: cancel 2nd user's hold too.
108 $test = clone($hold_test_template);
109 $test->{id} = "Cancel hold: cleanup hold for 2nd patron ($user2_barcode)";
110 $test->{msg} =~ s/\+/-/;
111 $test->{msg} =~ s/$user_barcode/$user2_barcode/;
112 $test->{pat} = qr/^161[NY]$datepat/;
113 delete $test->{fields};
115 $SIPtest::field_specs{(FID_INST_ID)},
116 $SIPtest::field_specs{(FID_SCREEN_MSG)},
117 $SIPtest::field_specs{(FID_PRINT_LINE)},
118 { field => FID_PATRON_ID,
119 pat => qr/^$user2_barcode$/,
123 push @tests, $test; # 11
125 # Place hold: valid patron, item, invalid patron pwd
126 $test = clone($hold_test_template);
127 $test->{id} = 'Place hold: invalid patron password';
128 $test->{msg} .= FID_PATRON_PWD . 'bad password|';
129 $test->{pat} = qr/^160N$datepat/;
130 delete $test->{fields};
132 $SIPtest::field_specs{(FID_INST_ID)},
133 $SIPtest::field_specs{(FID_SCREEN_MSG)},
134 $SIPtest::field_specs{(FID_PRINT_LINE)},
135 { field => FID_PATRON_ID,
136 pat => qr/^$user_barcode$/,
140 push @tests, $test, $hold_count_test_template0; # 12,13
142 # Place hold: invalid patron
143 $test = clone($hold_test_template);
144 $test->{id} = 'Place hold: invalid patron';
145 $test->{msg} =~ s/AA$user_barcode\|/AAbad_barcode|/;
146 $test->{pat} = qr/^160N$datepat/;
147 delete $test->{fields};
149 $SIPtest::field_specs{(FID_INST_ID)},
150 $SIPtest::field_specs{(FID_SCREEN_MSG)},
151 $SIPtest::field_specs{(FID_PRINT_LINE)},
152 { field => FID_PATRON_ID,
153 pat => qr/^bad_barcode$/,
157 # There's no patron to check the number of holds against
158 push @tests, $test; # 14
160 # Place hold: invalid item
161 $test = clone($hold_test_template);
162 $test->{id} = 'Place hold: invalid item';
163 $test->{msg} =~ s/AB$item_barcode\|/ABnosuchitem|/;
164 $test->{pat} = qr/^160N$datepat/;
165 delete $test->{fields};
167 $SIPtest::field_specs{(FID_INST_ID)},
168 $SIPtest::field_specs{(FID_SCREEN_MSG)},
169 $SIPtest::field_specs{(FID_PRINT_LINE)},
170 { field => FID_PATRON_ID,
171 pat => qr/^$user_barcode$/,
173 { field => FID_ITEM_ID,
174 pat => qr/^nosuchitem$/,
178 push @tests, $test, $hold_count_test_template0; # 15
180 # Still need tests for:
181 # - valid patron not permitted to place holds
182 # - valid item, not allowed to hold item
183 # - multiple holds on item: correct queue position management
184 # - setting and verifying hold expiry dates (requires ILS support)
185 # - 3M checkin extensions for hold/ILL routing
187 SIPtest::run_sip_tests(@tests);