2 # patron_info: test Patron Information Response
10 use C4
::SIP
::Sip
::Constants
qw(:all);
12 use SIPtest
qw(:basic :user1);
14 # This is a template test case for the Patron Information
15 # message handling. Because of the large number of fields,
16 # this template forms the basis for all of the different
17 # situations: valid patron no details, valid patron with each
18 # individual detail requested, invalid patron, invalid patron
20 our $patron_info_test_template = {
21 id
=> 'valid Patron Info no details',
22 msg
=> "6300020060329 201700 AO$instid|AA$user_barcode|",
23 pat
=> qr/^64 [ Y]{13}\d{3}$datepat(\d{4}){6}/,
25 $SIPtest::field_specs
{(FID_INST_ID
)},
26 $SIPtest::field_specs
{(FID_SCREEN_MSG
)},
27 $SIPtest::field_specs
{(FID_PRINT_LINE
)},
28 { field
=> FID_PATRON_ID
,
29 pat
=> qr/^$user_barcode$/o,
31 { field
=> FID_PERSONAL_NAME
,
32 pat
=> qr/^$user_fullname$/o,
34 $SIPtest::field_specs
{(FID_HOLD_ITEMS_LMT
)},
35 $SIPtest::field_specs
{(FID_OVERDUE_ITEMS_LMT
)},
36 $SIPtest::field_specs
{(FID_CHARGED_ITEMS_LMT
)},
37 { field
=> FID_VALID_PATRON
,
39 # Not required by the spec, but by the test
41 $SIPtest::field_specs
{(FID_CURRENCY
)},
42 { field
=> FID_FEE_AMT
,
45 { field
=> FID_FEE_LMT
,
48 { field
=> FID_HOME_ADDR
,
49 pat
=> qr/^$user_homeaddr$/o,
50 required
=> 1, }, # required by this test case
52 pat
=> qr/^$user_email$/o,
54 { field
=> FID_HOME_PHONE
,
55 pat
=> qr/^$user_phone$/o,
57 { field
=> FID_PATRON_BIRTHDATE
,
58 pat
=> qr/^$user_birthday$/o,
60 { field
=> FID_PATRON_CLASS
,
61 pat
=> qr/^$user_ptype$/o,
63 { field
=> FID_INET_PROFILE
,
64 pat
=> qr/^$user_inet$/,
70 $SIPtest::sc_status_test
,
71 clone
($patron_info_test_template),
75 # Create the test cases for the various summary detail fields
76 sub create_patron_summary_tests
{
78 my @patron_info_summary_tests = (
79 { field
=> FID_HOLD_ITEMS
,
82 { field
=> FID_OVERDUE_ITEMS
,
85 { field
=> FID_CHARGED_ITEMS
,
88 # The test user has no items of these types, so the tests seem to fail
89 # { field => FID_FINE_ITEMS,
92 # { field => FID_RECALL_ITEMS,
95 # { field => FID_UNAVAILABLE_HOLD_ITEMS,
100 foreach my $i (0 .. scalar @patron_info_summary_tests-1) {
101 # The tests for each of the summary fields are exactly the
102 # same as the basic one, except for the fact that there's
103 # an extra field to test
105 # Copy the hash, adjust it, add it to the end of the list
106 $test = clone
($patron_info_test_template);
108 substr($test->{msg
}, 23+$i, 1) = 'Y';
109 $test->{id
} = "valid Patron Info details: "
110 . $patron_info_summary_tests[$i]->{field
};
111 push @
{$test->{fields
}}, $patron_info_summary_tests[$i];
116 sub create_invalid_patron_tests
{
119 $test = clone
($patron_info_test_template);
120 $test->{id
} = "invalid Patron Info id";
121 $test->{msg
} =~ s/AA$user_barcode\|/AAberick|/o;
122 $test->{pat
} = qr/^64Y[ Y]{13}\d{3}$datepat(\d{4}){6}/;
123 delete $test->{fields
};
125 $SIPtest::field_specs
{(FID_INST_ID
)},
126 $SIPtest::field_specs
{(FID_SCREEN_MSG
)},
127 $SIPtest::field_specs
{(FID_PRINT_LINE
)},
128 { field
=> FID_PATRON_ID
,
131 { field
=> FID_PERSONAL_NAME
,
134 { field
=> FID_VALID_PATRON
,
140 # Valid patron, invalid patron password
141 $test = clone
($patron_info_test_template);
142 $test->{id
} = "valid Patron Info, invalid password";
143 $test->{msg
} .= (FID_PATRON_PWD
) . 'badpwd|';
144 $test->{pat
} = qr/^64[ Y]{14}\d{3}$datepat(\d{4}){6}/;
145 delete $test->{fields
};
147 $SIPtest::field_specs
{(FID_INST_ID
)},
148 $SIPtest::field_specs
{(FID_SCREEN_MSG
)},
149 $SIPtest::field_specs
{(FID_PRINT_LINE
)},
150 { field
=> FID_PATRON_ID
,
151 pat
=> qr/^$user_barcode$/,
153 { field
=> FID_PERSONAL_NAME
,
154 pat
=> qr/^$user_fullname$/,
156 { field
=> FID_VALID_PATRON
,
159 { field
=> FID_VALID_PATRON_PWD
,
166 create_patron_summary_tests
;
167 create_invalid_patron_tests
;
168 SIPtest
::run_sip_tests
(@tests);