]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/support-scripts/test-scripts/checkout.pl
now have non-cataloged items checkouts working with test script
[Evergreen.git] / Open-ILS / src / support-scripts / test-scripts / checkout.pl
1 #!/usr/bin/perl
2
3 #----------------------------------------------------------------
4 # Code for testing the container API
5 #----------------------------------------------------------------
6
7 require '../oils_header.pl';
8 use vars qw/ $apputils $memcache $user $authtoken $authtime /;
9 use strict; use warnings;
10
11 #----------------------------------------------------------------
12 err("\nusage: $0 <config> <oils_login_username> ".
13         " <oils_login_password> <patronid> <copy_barcode> [<type>, <noncat_type>]\n".
14         "Where <type> is one of:\n".
15         "\t'permit' to run the permit only\n".
16         "\t'noncat_permit' to run the permit script against a noncat item\n".
17         "\t'noncat' to check out a noncat item\n".
18         "\t(blank) to do a regular checkout\n" ) unless $ARGV[5];
19 #----------------------------------------------------------------
20
21 my $config              = shift; 
22 my $username    = shift;
23 my $password    = shift;
24 my $patronid    = shift;
25 my $barcode             = shift;
26 my $type                        = shift;
27 my $nc_type             = shift;
28
29 sub go {
30         osrf_connect($config);
31         oils_login($username, $password);
32         do_permit($patronid, $barcode, $type =~ /noncat/ ); 
33         do_checkout($patronid, $barcode, $type =~ /noncat/, $nc_type ) unless ($type =~ /permit/);
34         oils_logout();
35 }
36
37 go();
38
39 #----------------------------------------------------------------
40
41 sub do_permit {
42         my( $patronid, $barcode, $noncat ) = @_;
43
44         my @args = ( $authtoken, 'patron', $patronid );
45         push(@args, (barcode => $barcode)) unless $noncat;
46         push(@args, (noncat => 1, noncat_type => $nc_type )) if $noncat;
47
48         my $resp = simplereq( 
49                 CIRC(), 'open-ils.circ.permit_checkout_', @args );
50         
51         oils_event_die($resp);
52         printl("Permit succeeded for patron $patronid");
53 }
54
55 sub do_checkout {
56         my( $patronid, $barcode, $noncat, $nc_type ) = @_;
57
58         my @args = ($authtoken, 'patron', $patronid);
59         push(@args, (barcode => $barcode)) unless $noncat;
60         push(@args, (noncat => 1, noncat_type => $nc_type )) if $noncat;
61
62         my $resp = osrf_request(
63                 'open-ils.circ', 
64                 'open-ils.circ.checkout', @args );
65         oils_event_die($resp);
66         printl("Checkout succeeded");
67 }
68
69
70
71