Bug 9848: SIP tests, fix in 10renew_all.t (additionnal checkin)
authorAdrien Saurat <adrien.saurat@biblibre.com>
Tue, 19 Mar 2013 16:00:40 +0000 (17:00 +0100)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Thu, 5 Mar 2015 10:47:31 +0000 (11:47 +0100)
Adds a checkin operation at the beginning of the test.
Otherwise, a former test leaves the test item checked out
and this generates an error.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>

C4/SIP/t/10renew_all.t

index 23baea0..2967293 100644 (file)
@@ -18,6 +18,27 @@ my $enable_template = {
     fields => [],
 };
 
+# reset_checkin_templates will be used to reset the status of the items if needed
+# If "make test" is used (all tests at once), after the tests 08 and 09, the item stays checked out and this raises an error here
+# so we begin with a Checkin, awaiting for the minimal answer : ^10 (Checkin response)
+# Both results (101 and 100, for OK and NON OK) must be accepted, because if we run this test alone, the item won't necessarily be checked out
+# and the checkin attempt will then result in a "100" code, which is not a problem (we are just preparing the renewal tests)
+my @reset_checkin_templates = (
+    {
+        id => "Renew All: prep: check in $item_barcode (used in previous tests)",
+        msg => "09N20060102    08423620060113    084235AP$item_owner|AO$instid|AB$item_barcode|AC$password|",
+        pat    => qr/^10/,
+        fields => [],
+    },
+    {
+        id => "Renew All: prep: check in $item2_barcode (used in previous tests)",
+        msg => "09N20060102    08423620060113    084235AP$item2_owner|AO$instid|AB$item2_barcode|AC$password|",
+        pat    => qr/^10/,
+        fields => [],
+    }
+);
+
+# Checkout as a preparation for renewal
 my @checkout_templates = (
        {    id => "Renew All: prep: check out $item_barcode to $user_barcode",
                msg => "11YN20060329    203000                  AO$instid|AA$user_barcode|AB$item_barcode|AC$password|",
@@ -29,17 +50,6 @@ my @checkout_templates = (
                fields => [],}
 );
 
-my @checkin_templates = (
-       {    id => "Renew All: prep: check in $item_barcode",
-               msg => "09N20060102    08423620060113    084235AP$item_owner|AO$instid|AB$item_barcode|AC$password|",
-               pat => qr/^101YNN$datepat/,
-               fields => [],},
-       {    id => "Renew All: prep: check in $item2_barcode",
-               msg => "09N20060102    08423620060113    084235AP$item2_owner|AO$instid|AB$item2_barcode|AC$password|",
-               pat => qr/^101YNN$datepat/,
-               fields => [],}
-);
-
 my $renew_all_test_template = {
         id => "Renew All: patron ($user_barcode) with 1 item ($item_barcode) checked out, no patron password",
        msg => "6520060102    084236AO$instid|AA$user_barcode|",
@@ -54,17 +64,32 @@ my $renew_all_test_template = {
        ]
 };
 
+# check the book in, when done testing
+my @checkin_templates = (
+    {
+        id => "Renew All: prep: check in $item_barcode",
+        msg => "09N20060102    08423620060113    084235AP$item_owner|AO$instid|AB$item_barcode|AC$password|",
+        pat    => qr/^101YNN$datepat/,
+        fields => [],
+    },
+    {
+        id => "Renew All: prep: check in $item2_barcode",
+        msg => "09N20060102    08423620060113    084235AP$item2_owner|AO$instid|AB$item2_barcode|AC$password|",
+        pat    => qr/^101YNN$datepat/,
+        fields => [],
+    }
+);
+
+
+
 my @tests = (
             $SIPtest::login_test,
             $SIPtest::sc_status_test,
-#           $enable_template,
-            $checkout_templates[0],
-            $renew_all_test_template,
-            $checkin_templates[0],     # check the book in, when done testing
             );
 
 my $test;
 
+# WIP?
 $test = clone($renew_all_test_template);
 $test->{id} = 'Renew All: Valid patron, two items checked out';
 $test->{pat} = qr/^66100020000$datepat/;
@@ -88,7 +113,7 @@ $test->{fields} = [
               $SIPtest::field_specs{(FID_PRINT_LINE)},
                  ];
 
-push @tests, $checkout_templates[0], $test, $checkin_templates[0];
+push @tests, $reset_checkin_templates[0], $checkout_templates[0], $test, $checkin_templates[0];
 
 $test = clone($renew_all_test_template);
 $test->{id} = 'Renew All: invalid patron';