2 # renew_all: test Renew All Response
10 use C4::SIP::Sip::Constants qw(:all);
12 use SIPtest qw(:basic :user1 :item1 :item2);
14 my $enable_template = {
15 id => 'Renew All: prep: enable patron permissions',
16 msg => "2520060102 084238AO$instid|AA$user_barcode|",
17 pat => qr/^26 {4}[ Y]{10}000$datepat/,
21 my @checkout_templates = (
22 { id => "Renew All: prep: check out $item_barcode to $user_barcode",
23 msg => "11YN20060329 203000 AO$instid|AA$user_barcode|AB$item_barcode|AC$password|",
24 pat => qr/^121NNY$datepat/,
26 { id => "Renew All: prep: check out $item2_barcode to $user_barcode",
27 msg => "11YN20060329 203000 AO$instid|AA$user_barcode|AB$item2_barcode|AC$password|",
28 pat => qr/^121NNY$datepat/,
32 my @checkin_templates = (
33 { id => "Renew All: prep: check in $item_barcode",
34 msg => "09N20060102 08423620060113 084235AP$item_owner|AO$instid|AB$item_barcode|AC$password|",
35 pat => qr/^101YNN$datepat/,
37 { id => "Renew All: prep: check in $item2_barcode",
38 msg => "09N20060102 08423620060113 084235AP$item2_owner|AO$instid|AB$item2_barcode|AC$password|",
39 pat => qr/^101YNN$datepat/,
43 my $renew_all_test_template = {
44 id => "Renew All: patron ($user_barcode) with 1 item ($item_barcode) checked out, no patron password",
45 msg => "6520060102 084236AO$instid|AA$user_barcode|",
46 pat => qr/^66100010000$datepat/,
48 $SIPtest::field_specs{(FID_INST_ID)},
49 $SIPtest::field_specs{(FID_SCREEN_MSG)},
50 $SIPtest::field_specs{(FID_PRINT_LINE)},
51 { field => FID_RENEWED_ITEMS,
52 pat => qr/^$item_barcode$/,
59 $SIPtest::sc_status_test,
61 $checkout_templates[0],
62 $renew_all_test_template,
63 $checkin_templates[0], # check the book in, when done testing
68 $test = clone($renew_all_test_template);
69 $test->{id} = 'Renew All: Valid patron, two items checked out';
70 $test->{pat} = qr/^66100020000$datepat/;
71 foreach my $i (0 .. (scalar @{$test->{fields}})-1) {
72 my $field = $test->{fields}[$i];
73 if ($field->{field} eq FID_RENEWED_ITEMS) {
74 $field->{pat} = qr/^$item_barcode\|$item2_barcode$/;
78 #push @tests, @checkout_templates[0..1], $renew_all_test_template, @checkin_templates[0..1];
80 $test = clone($renew_all_test_template);
81 $test->{id} = 'Renew All: valid patron, invalid patron password';
82 $test->{msg} .= (FID_PATRON_PWD) . 'bad_pwd|';
83 $test->{pat} = qr/^66000000000$datepat/;
84 delete $test->{fields};
86 $SIPtest::field_specs{(FID_INST_ID)},
87 $SIPtest::field_specs{(FID_SCREEN_MSG)},
88 $SIPtest::field_specs{(FID_PRINT_LINE)},
91 push @tests, $checkout_templates[0], $test, $checkin_templates[0];
93 $test = clone($renew_all_test_template);
94 $test->{id} = 'Renew All: invalid patron';
95 $test->{msg} =~ s/AA$user_barcode/AAbad_barcode/;
96 $test->{pat} = qr/^66000000000$datepat/;
97 delete $test->{fields};
99 $SIPtest::field_specs{(FID_INST_ID)},
100 $SIPtest::field_specs{(FID_SCREEN_MSG)},
101 $SIPtest::field_specs{(FID_PRINT_LINE)},
105 SIPtest::run_sip_tests(@tests);