2 # checkout: test Checkout Response
10 use Sip::Constants qw(:all);
18 my $patron_enable_template = {
19 id => 'Renew All: prep: enable patron permissions',
20 msg => "2520060102 084238AO$instid|AA$user_barcode|",
21 pat => qr/^26 {4}[ Y]{10}000$datepat/o,
25 my $patron_disable_template = {
26 id => 'Checkout: block patron (prep to test checkout denied)',
27 msg => "01N20060102 084238AO$instid|ALFees overrun|AA$user_barcode|",
28 # response to block patron is a patron status message
29 pat => qr/^24Y{4}[ Y]{10}000$datepat/o,
33 my $checkin_template = {
34 id => 'Checkout: cleanup: check in item',
35 msg => "09N20050102 08423620060113 084235AP$item_owner|AO$instid|AB$item_barcode|ACterminal password|",
36 pat => qr/^101YNN$datepat/o,
40 my $checkout_test_template = {
41 id => 'Checkout: valid item, valid patron',
42 msg => "11YN20060329 203000 AO$instid|AA$user_barcode|AB$item_barcode|AC|",
43 pat => qr/^121NNY$datepat/,
45 $SIPtest::field_specs{(FID_INST_ID)},
46 $SIPtest::field_specs{(FID_SCREEN_MSG)},
47 $SIPtest::field_specs{(FID_PRINT_LINE)},
48 { field => FID_PATRON_ID,
49 pat => qr/^$user_barcode$/o,
51 { field => FID_ITEM_ID,
52 pat => qr/^$item_barcode$/o,
54 { field => FID_TITLE_ID,
55 pat => qr/^$item_title\s*$/o,
57 { field => FID_DUE_DATE,
60 { field => FID_FEE_TYPE,
63 { field => FID_SECURITY_INHIBIT,
66 { field => FID_CURRENCY,
67 pat => qr/^$currency$/o,
69 { field => FID_FEE_AMT,
72 { field => FID_MEDIA_TYPE,
75 { field => FID_ITEM_PROPS,
78 { field => FID_TRANSACTION_ID,
85 $SIPtest::sc_status_test,
86 clone($checkout_test_template),
87 # Don't check the item in, because we're about to test renew
93 ## Test this by checking out exactly the same book a second time.
94 ## The only difference should be that the "Renewal OK" flag should now
96 #$test = clone($checkout_test_template);
97 #$test->{id} = 'Checkout: patron renewal';
98 #$test->{pat} = qr/^121YNY$datepat/;
104 push @tests, $checkin_template;
106 # Valid Patron, item with diacritical in the title
107 #$test = clone($checkout_test_template);
109 #$test->{id} = 'Checkout: valid patron, diacritical character in title';
110 #$test->{msg} =~ s/AB$item_barcode/AB$item_diacritic_barcode/;
112 #foreach my $i (0 .. (scalar @{$test->{fields}})-1) {
113 # my $field = $test->{fields}[$i];
115 # if ($field->{field} eq FID_ITEM_ID) {
116 # $field->{pat} = qr/^$item_diacritic_barcode$/;
117 # } elsif ($field->{field} eq FID_TITLE_ID) {
118 # $field->{pat} = qr/^$item_diacritic_title\s*$/;
119 # } elsif ($field->{field} eq FID_OWNER) {
120 # $field->{pat} = qr/^$item_diacritic_owner$/;
126 #$test = clone($checkin_template);
127 #$test->{msg} =~ s/AB$item_barcode/AB$item_diacritic_barcode/;
130 # Valid Patron, Invalid Item_id
131 $test = clone($checkout_test_template);
133 $test->{id} = 'Checkout: valid patron, invalid item';
134 $test->{msg} =~ s/AB$item_barcode/ABno-barcode/o;
135 $test->{pat} = qr/^120NUN$datepat/;
136 delete $test->{fields};
138 $SIPtest::field_specs{(FID_INST_ID)},
139 $SIPtest::field_specs{(FID_SCREEN_MSG)},
140 $SIPtest::field_specs{(FID_PRINT_LINE)},
141 { field => FID_PATRON_ID,
142 pat => qr/^$user_barcode$/o,
144 { field => FID_ITEM_ID,
145 pat => qr/^no-barcode$/,
147 { field => FID_TITLE_ID,
150 { field => FID_DUE_DATE,
153 { field => FID_VALID_PATRON,
160 # Invalid patron, valid item
161 $test = clone($checkout_test_template);
162 $test->{id} = 'Checkout: invalid patron, valid item';
163 $test->{msg} =~ s/AA$user_barcode/AAberick/;
164 $test->{pat} = qr/^120NUN$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,
173 { field => FID_ITEM_ID,
174 pat => qr/^$item_barcode$/o,
176 { field => FID_TITLE_ID,
177 pat => qr/^$item_title\s*$/o,
179 { field => FID_DUE_DATE,
182 { field => FID_VALID_PATRON,
189 # Needed: tests for blocked patrons, patrons with excessive
190 # fines/fees, magnetic media, charging fees to borrow items.
193 #$test = clone($checkout_test_template);
194 #$test->{id} = 'Checkout: Blocked patron';
195 #$test->{pat} = qr/^120NUN$datepat/;
196 #delete $test->{fields};
198 # $SIPtest::field_specs{(FID_INST_ID)},
199 # $SIPtest::field_specs{(FID_SCREEN_MSG)},
200 # $SIPtest::field_specs{(FID_PRINT_LINE)},
201 # { field => FID_PATRON_ID,
202 # pat => qr/^$user_barcode$/,
204 # { field => FID_VALID_PATRON,
209 #push @tests, $patron_disable_template, $test, $patron_enable_template;
211 SIPtest::run_sip_tests(@tests);