test Relais extensions
authorJason Etheridge <jason@EquinoxOLI.org>
Thu, 24 Nov 2022 16:04:25 +0000 (11:04 -0500)
committerJason Etheridge <jason@EquinoxOLI.org>
Thu, 24 Nov 2022 16:04:25 +0000 (11:04 -0500)
t/17extensions.t

index b65d69e..4a6859c 100755 (executable)
@@ -37,7 +37,7 @@ my $patron_info_test_template = {
         { field    => FID_FEE_LMT,
             pat      => $textpat,
             required => 0, },
-        # field    => FID_HOME_ADDR,
+        #{ field    => FID_HOME_ADDR,
         #   pat      => qr/^$user_homeaddr$/o,
         #   required => 1, }, # required by this test case
         { field    => FID_EMAIL,
@@ -55,26 +55,56 @@ my $patron_info_test_template = {
         #{ field    => FID_INET_PROFILE,
         #   pat      => qr/^$user_inet$/,
         #   required => 1, },
-        # field    => FID_HOME_LIBRARY,
+        #{ field    => FID_HOME_LIBRARY,
         #   pat      => qr/^$user_homelib$/,
         #   required => 1, }, # Required for this test
 ], };
 
+my $patron_status_test_template = {
+    id => 'valid Patron Status',
+    msg => "2300120060101    084237AO$SIPtest::instid|AA$user_barcode|AD$user_pin|AC|",
+    pat => qr/^24 [ Y]{13}\d{3}$datepat/,
+    fields => [
+        $SIPtest::field_specs{(FID_INST_ID)},
+        $SIPtest::field_specs{(FID_SCREEN_MSG)},
+        $SIPtest::field_specs{(FID_PRINT_LINE)},
+        { field    => FID_PERSONAL_NAME,
+            pat      => qr/^$user_fullname$/o,
+            required => 1, },
+        { field    => FID_PATRON_ID,
+            pat      => qr/^$user_barcode/o,
+            required => 1, },
+        { field    => FID_VALID_PATRON,
+            pat      => qr/^Y$/,
+            required => 0, },
+        { field    => FID_VALID_PATRON_PWD,
+            pat      => qr/^Y$/,
+            required => 0, },
+        { field    => FID_CURRENCY,
+            pat      => qr/^$currency$/io,
+            required => 0, },
+        { field    => FID_FEE_AMT,
+            pat      => qr/^[0-9.]+$/,
+            required => 0, },
+    ]
+};
+
 my @tests = (
     $SIPtest::login_test,
     $SIPtest::sc_status_test,
     clone($patron_info_test_template),
+    clone($patron_status_test_template),
 );
 
 
 sub create_patron_info_extension_tests {
-    my $test = clone($patron_info_test_template);
 
+    my $test = clone($patron_info_test_template);
     $test->{id} = "Patron Info home address extension";
     push @{$test->{fields}}, {
         field    => FID_HOME_ADDR,
         pat      => qr/^$user_homeaddr$/o,
-        required => 1, };
+        just_warn => 1, required => 1, };
     push @tests, $test;
 
     $test = clone($patron_info_test_template);
@@ -82,7 +112,7 @@ sub create_patron_info_extension_tests {
     push @{$test->{fields}}, {
         field    => FID_INET_PROFILE,
         pat      => qr/^$user_inet$/,
-        required => 1, };
+        just_warn => 1, required => 1, };
     push @tests, $test;
 
     $test = clone($patron_info_test_template);
@@ -90,7 +120,7 @@ sub create_patron_info_extension_tests {
     push @{$test->{fields}}, {
         field    => FID_HOME_LIBRARY,
         pat      => qr/^$user_homelib$/,
-        required => 1, };
+        just_warn => 1, required => 1, };
     push @tests, $test;
 
     $test = clone($patron_info_test_template);
@@ -98,7 +128,7 @@ sub create_patron_info_extension_tests {
     push @{$test->{fields}}, {
         field    => FID_PATRON_BIRTHDATE,
         pat      => qr/^$user_birthday$/o,
-        required => 1, };
+        just_warn => 1, required => 1, };
     push @tests, $test;
 
     $test = clone($patron_info_test_template);
@@ -106,7 +136,7 @@ sub create_patron_info_extension_tests {
     push @{$test->{fields}}, {
         field    => FID_PATRON_CLASS,
         pat      => qr/^$user_ptype$/o,
-        required => 1, };
+        just_warn => 1, required => 1, };
     push @tests, $test;
 
     $test = clone($patron_info_test_template);
@@ -114,11 +144,43 @@ sub create_patron_info_extension_tests {
     push @{$test->{fields}}, {
         field    => FID_PATRON_EXPIRE,
         pat      => qr/^20\d\d\d\d\d\d$/o, # presumably this date format works for Envisionware
-        required => 1, };
+        just_warn => 1, required => 1, };
     push @tests, $test;
 }
 
+sub create_patron_status_extension_tests {
+
+    # with SIPServer, add <relais_extensions_to_msg24 enabled="true" /> to the institution config
+    # to test these
+
+    my $test = clone($patron_status_test_template);
+    $test->{id} = "Patron Status home address extension";
+    push @{$test->{fields}}, {
+        field    => FID_HOME_ADDR,
+        pat      => qr/^$user_homeaddr$/o,
+        just_warn => 1, required => 1, };
+    push @tests, $test;
+
+    $test = clone($patron_status_test_template);
+    $test->{id} = "Patron Status email address extension";
+    push @{$test->{fields}}, {
+        field    => FID_EMAIL,
+        pat      => qr/^$user_email$/o,
+        just_warn => 1, required => 1, };
+    push @tests, $test;
+
+    $test = clone($patron_status_test_template);
+    $test->{id} = "Patron Status home phone extension";
+    push @{$test->{fields}}, {
+        field    => FID_HOME_PHONE,
+        pat      => qr/^$user_phone$/o,
+        just_warn => 1, required => 1, };
+    push @tests, $test;
+
+}
+
 create_patron_info_extension_tests();
+create_patron_status_extension_tests();
 
 SIPtest::run_sip_tests(@tests);