Initial set of tests
authordjfiander <djfiander>
Fri, 26 May 2006 02:12:48 +0000 (02:12 +0000)
committerdjfiander <djfiander>
Fri, 26 May 2006 02:12:48 +0000 (02:12 +0000)
t/04patron_status.t [new file with mode: 0644]
t/05block_patron.t [new file with mode: 0644]
t/06patron_enable.t [new file with mode: 0644]

diff --git a/t/04patron_status.t b/t/04patron_status.t
new file mode 100644 (file)
index 0000000..ebec04e
--- /dev/null
@@ -0,0 +1,100 @@
+#!/usr/bin/perl
+# patron_status: test Patron Status Response
+
+use strict;
+use warnings;
+use Clone qw(clone);
+
+use Sip::Constants qw(:all);
+
+use SIPtest qw($datepat $textpat);
+
+my $patron_status_test_template = {
+    id => 'Patron Status: valid patron, no patron password',
+    msg => '2300120060101    084237AOUWOLS|AAdjfiander|ACterminal password|',
+    pat => qr/^24 [ Y]{13}001$datepat/,
+    fields => [
+              $SIPtest::field_specs{(FID_INST_ID)},
+              $SIPtest::field_specs{(FID_SCREEN_MSG)},
+              $SIPtest::field_specs{(FID_PRINT_LINE)},
+              { field    => FID_PATRON_ID,
+                pat      => qr/^djfiander$/,
+                required => 1, },
+              { field    => FID_PERSONAL_NAME,
+                pat      => qr/^David J\. Fiander$/,
+                required => 1, },
+              { field    => FID_VALID_PATRON,
+                pat      => qr/^Y$/,
+                # Not required by the spec, but by the test
+                required => 1, },
+              $SIPtest::field_specs{(FID_CURRENCY)},
+              { field    => FID_FEE_AMT,
+                pat      => $textpat,
+                required => 0, },
+              ], };
+
+my @tests = (
+            $SIPtest::login_test,
+            $SIPtest::sc_status_test,
+            clone($patron_status_test_template),
+            );
+
+# Invalid patron
+my $test = clone($patron_status_test_template);
+
+$test->{id} = 'Patron Status invalid id';
+$test->{msg} =~ s/AAdjfiander\|/AAberick|/;
+
+# The test assumes that the language sent by the terminal is
+# just echoed back for invalid patrons.
+$test->{pat} = qr/^24Y[ Y]{13}001$datepat/; 
+
+delete $test->{fields};
+$test->{fields} = [
+                  $SIPtest::field_specs{(FID_INST_ID)},
+                  $SIPtest::field_specs{(FID_SCREEN_MSG)},
+                  $SIPtest::field_specs{(FID_PRINT_LINE)},
+                  { field    => FID_PATRON_ID,
+                    pat      => qr/^berick$/,
+                    required => 1, },
+                  { field    => FID_PERSONAL_NAME,
+                    pat      => qr/^$/,
+                    required => 1, },
+                  { field    => FID_VALID_PATRON,
+                    pat      => qr/^N$/,
+                    required => 1, },
+                  ];
+
+push @tests, $test;
+
+# Valid patron, invalid patron password
+$test = clone($patron_status_test_template);
+$test->{id} = 'Patron Status: Valid patron, invalid patron password';
+$test->{msg} .= (FID_PATRON_PWD) . 'badpwd|';
+$test->{pat} = qr/^24[ Y]{14}001$datepat/;
+delete $test->{fields};
+$test->{fields} = [
+                $SIPtest::field_specs{(FID_INST_ID)},
+                $SIPtest::field_specs{(FID_SCREEN_MSG)},
+                $SIPtest::field_specs{(FID_PRINT_LINE)},
+                { field    => FID_PATRON_ID,
+                  pat      => qr/^djfiander$/,
+                  required => 1, },
+                { field    => FID_PERSONAL_NAME,
+                  pat      => qr/^David J\. Fiander$/,
+                  required => 1, },
+                { field    => FID_VALID_PATRON,
+                  pat      => qr/^Y$/,
+                  required => 1, },
+                { field    => FID_VALID_PATRON_PWD,
+                  pat      => qr/^N$/,
+                  required => 1, },
+                ];
+push @tests, $test;
+
+# TODO: Need multiple patrons to test each individual 
+# status field
+
+SIPtest::run_sip_tests(@tests);
+
+1;
diff --git a/t/05block_patron.t b/t/05block_patron.t
new file mode 100644 (file)
index 0000000..187d90c
--- /dev/null
@@ -0,0 +1,45 @@
+#!/usr/bin/perl
+# block_patron: test Block Patron Response
+
+use strict;
+use warnings;
+use Clone qw(clone);
+
+use Sip::Constants qw(:all);
+
+use SIPtest qw($datepat $textpat);
+
+my $block_patron_test_template = {
+    id => 'Block Patron: valid patron, card not retained',
+    msg => "01N20060102    084238AOUWOLS|ALHe's a jerk|AAdjfiander|ACterminal password|",
+    # response to block patron is a patron status message
+    pat => qr/^24Y[ Y]{13}000$datepat/,
+    fields => [
+              $SIPtest::field_specs{(FID_INST_ID)},
+              $SIPtest::field_specs{(FID_SCREEN_MSG)},
+              $SIPtest::field_specs{(FID_PRINT_LINE)},
+              { field    => FID_PATRON_ID,
+                pat      => qr/^djfiander$/,
+                required => 1, },
+              { field    => FID_PERSONAL_NAME,
+                pat      => qr/^David J\. Fiander$/,
+                required => 1, },
+              { field    => FID_VALID_PATRON,
+                pat      => qr/^Y$/,
+                # Not required by the spec, but by the test
+                required => 1, },
+              $SIPtest::field_specs{(FID_CURRENCY)},
+              { field    => FID_FEE_AMT,
+                pat      => $textpat,
+                required => 0, },
+              ], };
+
+my @tests = (
+            $SIPtest::login_test,
+            $SIPtest::sc_status_test,
+            clone($block_patron_test_template),
+            );
+
+SIPtest::run_sip_tests(@tests);
+
+1;
diff --git a/t/06patron_enable.t b/t/06patron_enable.t
new file mode 100644 (file)
index 0000000..3f7de35
--- /dev/null
@@ -0,0 +1,40 @@
+#!/usr/bin/perl
+# patron_enable: test  Patron Enable Response
+
+use strict;
+use warnings;
+use Clone qw(clone);
+
+use Sip::Constants qw(:all);
+
+use SIPtest qw($datepat $textpat);
+
+my $patron_enable_test_template = {
+    id => 'Patron Enable: valid patron',
+    msg => "2520060102    084238AOUWOLS|AAdjfiander|",
+    pat => qr/^26 [ Y]{13}000$datepat/,
+    fields => [
+              $SIPtest::field_specs{(FID_INST_ID)},
+              $SIPtest::field_specs{(FID_SCREEN_MSG)},
+              $SIPtest::field_specs{(FID_PRINT_LINE)},
+              { field    => FID_PATRON_ID,
+                pat      => qr/^djfiander$/,
+                required => 1, },
+              { field    => FID_PERSONAL_NAME,
+                pat      => qr/^David J\. Fiander$/,
+                required => 1, },
+              { field    => FID_VALID_PATRON,
+                pat      => qr/^Y$/,
+                # Not required by the spec, but by the test
+                required => 1, },
+              ], };
+
+my @tests = (
+            $SIPtest::login_test,
+            $SIPtest::sc_status_test,
+            clone($patron_enable_test_template),
+            );
+
+SIPtest::run_sip_tests(@tests);
+
+1;