2 # checkout: test Checkout Response
12 use C4
::SIP
::Sip
::Constants
qw(:all);
20 my $patron_enable_template = {
21 id
=> 'Renew All: prep: enable patron permissions',
22 msg
=> "2520060102 084238AO$instid|AA$user_barcode|",
23 pat
=> qr/^26 {4}[ Y]{10}000$datepat/o,
27 my $patron_disable_template = {
28 id
=> 'Checkout: block patron (prep to test checkout denied)',
29 msg
=> "01N20060102 084238AO$instid|ALFees overrun|AA$user_barcode|",
30 # response to block patron is a patron status message
31 pat
=> qr/^24Y{4}[ Y]{10}000$datepat/o,
35 my $checkin_template = {
36 id
=> 'Checkout: cleanup: check in item',
37 msg
=> "09N20050102 08423620060113 084235AP$item_owner|AO$instid|AB$item_barcode|ACterminal password|",
38 pat
=> qr/^101YNN$datepat/o,
42 my $checkout_test_template = {
43 id
=> 'Checkout: valid item, valid patron',
44 msg
=> "11YN20060329 203000 AO$instid|AA$user_barcode|AB$item_barcode|AC|",
45 pat
=> qr/^121NNY$datepat/,
47 $SIPtest::field_specs
{(FID_INST_ID
)},
48 $SIPtest::field_specs
{(FID_SCREEN_MSG
)},
49 $SIPtest::field_specs
{(FID_PRINT_LINE
)},
50 { field
=> FID_PATRON_ID
,
51 pat
=> qr/^$user_barcode$/o,
53 { field
=> FID_ITEM_ID
,
54 pat
=> qr/^$item_barcode$/o,
56 { field
=> FID_TITLE_ID
,
57 pat
=> qr/^$item_title\s*$/o,
59 { field
=> FID_DUE_DATE
,
62 { field
=> FID_FEE_TYPE
,
65 { field
=> FID_SECURITY_INHIBIT
,
68 { field
=> FID_CURRENCY
,
69 pat
=> qr/^$currency$/o,
71 { field
=> FID_FEE_AMT
,
74 { field
=> FID_MEDIA_TYPE
,
77 { field
=> FID_ITEM_PROPS
,
80 { field
=> FID_TRANSACTION_ID
,
87 $SIPtest::sc_status_test
,
88 clone
($checkout_test_template),
89 # Don't check the item in, because we're about to test renew
95 ## Test this by checking out exactly the same book a second time.
96 ## The only difference should be that the "Renewal OK" flag should now
98 #$test = clone($checkout_test_template);
99 #$test->{id} = 'Checkout: patron renewal';
100 #$test->{pat} = qr/^121YNY$datepat/;
106 push @tests, $checkin_template;
108 # Valid Patron, item with diacritical in the title
109 #$test = clone($checkout_test_template);
111 #$test->{id} = 'Checkout: valid patron, diacritical character in title';
112 #$test->{msg} =~ s/AB$item_barcode/AB$item_diacritic_barcode/;
114 #foreach my $i (0 .. (scalar @{$test->{fields}})-1) {
115 # my $field = $test->{fields}[$i];
117 # if ($field->{field} eq FID_ITEM_ID) {
118 # $field->{pat} = qr/^$item_diacritic_barcode$/;
119 # } elsif ($field->{field} eq FID_TITLE_ID) {
120 # $field->{pat} = qr/^$item_diacritic_title\s*$/;
121 # } elsif ($field->{field} eq FID_OWNER) {
122 # $field->{pat} = qr/^$item_diacritic_owner$/;
128 #$test = clone($checkin_template);
129 #$test->{msg} =~ s/AB$item_barcode/AB$item_diacritic_barcode/;
132 # Valid Patron, Invalid Item_id
133 $test = clone
($checkout_test_template);
135 $test->{id
} = 'Checkout: valid patron, invalid item';
136 $test->{msg
} =~ s/AB$item_barcode/ABno-barcode/o;
137 $test->{pat
} = qr/^120NUN$datepat/;
138 delete $test->{fields
};
140 $SIPtest::field_specs
{(FID_INST_ID
)},
141 $SIPtest::field_specs
{(FID_SCREEN_MSG
)},
142 $SIPtest::field_specs
{(FID_PRINT_LINE
)},
143 { field
=> FID_PATRON_ID
,
144 pat
=> qr/^$user_barcode$/o,
146 { field
=> FID_ITEM_ID
,
147 pat
=> qr/^no-barcode$/,
149 { field
=> FID_TITLE_ID
,
152 { field
=> FID_DUE_DATE
,
155 { field
=> FID_VALID_PATRON
,
162 # Invalid patron, valid item
163 $test = clone
($checkout_test_template);
164 $test->{id
} = 'Checkout: invalid patron, valid item';
165 $test->{msg
} =~ s/AA$user_barcode/AAberick/;
166 $test->{pat
} = qr/^120NUN$datepat/;
167 delete $test->{fields
};
169 $SIPtest::field_specs
{(FID_INST_ID
)},
170 $SIPtest::field_specs
{(FID_SCREEN_MSG
)},
171 $SIPtest::field_specs
{(FID_PRINT_LINE
)},
172 { field
=> FID_PATRON_ID
,
175 { field
=> FID_ITEM_ID
,
176 pat
=> qr/^$item_barcode$/o,
178 { field
=> FID_TITLE_ID
,
179 pat
=> qr/^$item_title\s*$/o,
181 { field
=> FID_DUE_DATE
,
184 { field
=> FID_VALID_PATRON
,
191 # Needed: tests for blocked patrons, patrons with excessive
192 # fines/fees, magnetic media, charging fees to borrow items.
195 #$test = clone($checkout_test_template);
196 #$test->{id} = 'Checkout: Blocked patron';
197 #$test->{pat} = qr/^120NUN$datepat/;
198 #delete $test->{fields};
200 # $SIPtest::field_specs{(FID_INST_ID)},
201 # $SIPtest::field_specs{(FID_SCREEN_MSG)},
202 # $SIPtest::field_specs{(FID_PRINT_LINE)},
203 # { field => FID_PATRON_ID,
204 # pat => qr/^$user_barcode$/,
206 # { field => FID_VALID_PATRON,
211 #push @tests, $patron_disable_template, $test, $patron_enable_template;
213 SIPtest
::run_sip_tests
(@tests);