2 # patron_info: test Patron Information Response
8 use Sip::Constants qw(:all);
10 use SIPtest qw(:basic :user1);
12 # This is a template test case for the Patron Information
13 # message handling. Because of the large number of fields,
14 # this template forms the basis for all of the different
15 # situations: valid patron no details, valid patron with each
16 # individual detail requested, invalid patron, invalid patron
18 our $patron_info_test_template = {
19 id => 'valid Patron Info no details',
20 msg => "6300020060329 201700 AO$instid|AA$user_barcode|",
21 pat => qr/^64 [ Y]{13}\d{3}$datepat(\d{4}){6}/,
23 $SIPtest::field_specs{(FID_INST_ID)},
24 $SIPtest::field_specs{(FID_SCREEN_MSG)},
25 $SIPtest::field_specs{(FID_PRINT_LINE)},
26 { field => FID_PATRON_ID,
27 pat => qr/^$user_barcode$/o,
29 { field => FID_PERSONAL_NAME,
30 pat => qr/^$user_fullname$/o,
32 $SIPtest::field_specs{(FID_HOLD_ITEMS_LMT)},
33 $SIPtest::field_specs{(FID_OVERDUE_ITEMS_LMT)},
34 $SIPtest::field_specs{(FID_CHARGED_ITEMS_LMT)},
35 { field => FID_VALID_PATRON,
37 # Not required by the spec, but by the test
39 $SIPtest::field_specs{(FID_CURRENCY)},
40 { field => FID_FEE_AMT,
43 { field => FID_FEE_LMT,
46 { field => FID_HOME_ADDR,
47 pat => qr/^$user_homeaddr$/o,
48 required => 1, }, # required by this test case
50 pat => qr/^$user_email$/o,
52 { field => FID_HOME_PHONE,
53 pat => qr/^$user_phone$/o,
55 { field => FID_PATRON_BIRTHDATE,
56 pat => qr/^$user_birthday$/o,
58 { field => FID_PATRON_CLASS,
59 pat => qr/^$user_ptype$/o,
61 { field => FID_INET_PROFILE,
62 pat => qr/^$user_inet$/,
68 $SIPtest::sc_status_test,
69 clone($patron_info_test_template),
73 # Create the test cases for the various summary detail fields
74 sub create_patron_summary_tests {
76 my @patron_info_summary_tests = (
77 { field => FID_HOLD_ITEMS,
80 { field => FID_OVERDUE_ITEMS,
83 { field => FID_CHARGED_ITEMS,
86 # The test user has no items of these types, so the tests seem to fail
87 # { field => FID_FINE_ITEMS,
90 # { field => FID_RECALL_ITEMS,
93 # { field => FID_UNAVAILABLE_HOLD_ITEMS,
98 foreach my $i (0 .. scalar @patron_info_summary_tests-1) {
99 # The tests for each of the summary fields are exactly the
100 # same as the basic one, except for the fact that there's
101 # an extra field to test
103 # Copy the hash, adjust it, add it to the end of the list
104 $test = clone($patron_info_test_template);
106 substr($test->{msg}, 23+$i, 1) = 'Y';
107 $test->{id} = "valid Patron Info details: "
108 . $patron_info_summary_tests[$i]->{field};
109 push @{$test->{fields}}, $patron_info_summary_tests[$i];
114 sub create_invalid_patron_tests {
117 $test = clone($patron_info_test_template);
118 $test->{id} = "invalid Patron Info id";
119 $test->{msg} =~ s/AA$user_barcode\|/AAberick|/o;
120 $test->{pat} = qr/^64Y[ Y]{13}\d{3}$datepat(\d{4}){6}/;
121 delete $test->{fields};
123 $SIPtest::field_specs{(FID_INST_ID)},
124 $SIPtest::field_specs{(FID_SCREEN_MSG)},
125 $SIPtest::field_specs{(FID_PRINT_LINE)},
126 { field => FID_PATRON_ID,
129 { field => FID_PERSONAL_NAME,
132 { field => FID_VALID_PATRON,
138 # Valid patron, invalid patron password
139 $test = clone($patron_info_test_template);
140 $test->{id} = "valid Patron Info, invalid password";
141 $test->{msg} .= (FID_PATRON_PWD) . 'badpwd|';
142 $test->{pat} = qr/^64[ Y]{14}\d{3}$datepat(\d{4}){6}/;
143 delete $test->{fields};
145 $SIPtest::field_specs{(FID_INST_ID)},
146 $SIPtest::field_specs{(FID_SCREEN_MSG)},
147 $SIPtest::field_specs{(FID_PRINT_LINE)},
148 { field => FID_PATRON_ID,
149 pat => qr/^$user_barcode$/,
151 { field => FID_PERSONAL_NAME,
152 pat => qr/^$user_fullname$/,
154 { field => FID_VALID_PATRON,
157 { field => FID_VALID_PATRON_PWD,
164 create_patron_summary_tests;
165 create_invalid_patron_tests;
166 SIPtest::run_sip_tests(@tests);