]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/support-scripts/test-scripts/circ_rules.pl
Docs: 2.8 Patron Message Center
[Evergreen.git] / Open-ILS / src / support-scripts / test-scripts / circ_rules.pl
1 #/usr/bin/perl
2 use strict; use warnings;
3 use lib q|../../../perlmods/lib/|;
4 use Time::HiRes qw/time/;
5 use OpenILS::Application::Circ::ScriptBuilder;
6 require '../oils_header.pl';
7 use vars qw/ $user $authtoken $apputils /;
8
9 # ---------------------------------------------------------------------
10 # SCRIPT VARS
11 # ----------------------------------------------------------------------
12 #my $patronid                                   = 3;
13 my $patronid                                    = 1000502;
14 my $copyid                                              = 8000107;
15 my $patron_items_out                    = 11;
16 my $patron_overdue_count        = 11;
17 my $patron_fines                                = 20;
18
19 # these are not currently tested in the scripts
20 my $is_renewal                                  = 0;
21 my $is_non_cat                                  = 0;
22 my $is_hold                                             = 0;
23 my $non_cat_type                                = 1;
24 # ---------------------------------------------------------------------
25
26
27
28 my $bsconfig = shift;
29 my $script = shift;
30
31 die "$0: <bootstrap> <absolute_script_path>\n" unless $script;
32
33 my $path;
34
35 ($path, $script) = ($script =~ m#(/.*/)(.*)#);
36 osrf_connect($bsconfig);
37
38 my $s = time;
39 my $runner = OpenILS::Application::Circ::ScriptBuilder->build(
40         {
41                 copy_id                                         => $copyid,
42                 patron_id                                       => $patronid,
43                 fetch_patron_circ_info  => 1,
44                 flesh_age_protect                       => 1,
45                 _direct                                         => {
46                         isNonCat                => $is_non_cat,
47                         isRenewal       => $is_renewal,
48                         nonCatType      => $non_cat_type,
49                 }
50         }
51 );
52
53
54 # ---------------------------------------------------------------------
55 # Override the default log functions for convenience
56 # ---------------------------------------------------------------------
57 $runner->insert(log_activity    => sub { print "@_\n"; return 1;} );
58 $runner->insert(log_error               => sub { print "@_\n"; return 1;} );
59 $runner->insert(log_warn                => sub { print "@_\n"; return 1;} );
60 $runner->insert(log_info                => sub { print "@_\n"; return 1;} );
61 $runner->insert(log_debug               => sub { print "@_\n"; return 1;} );
62 $runner->insert(log_internal    => sub { print "@_\n"; return 1;} );
63
64
65 #$runner->add_path('/openils/var/web/opac/common/js');
66 $runner->add_path($path);
67 $runner->add_path("$path/../");
68 #$runner->add_path("$path/../catalog/");
69
70
71 # ---------------------------------------------------------------------
72 # Run the script
73 # ---------------------------------------------------------------------
74 print "\nLoading script: $script\n";
75 print "\n" . '-'x70 . "\n";
76
77 $runner->load($script);
78 my $result = $runner->run or die "Script died: $@";
79
80 my $end = time - $s;
81
82
83 # ---------------------------------------------------------------------
84 # Print out any events that occurred
85 # ---------------------------------------------------------------------
86 print "\n" . '-'x70 . "\n";
87
88 my $events = $result->{events};
89 my $ievents = $result->{infoEvents};
90 my $fevents = $result->{fatalEvents};
91
92 print "events = @$events\n";
93 print "info events = @$ievents\n";
94 print "fatal events = @$fevents\n";
95
96 print "\ntime = $end\n";
97
98 sub show_events {
99         my $t = shift;
100         my $e = shift;
101         my @e;
102
103         if($e and @e = split(/,/, $e)) {
104                 print "$t : $_\n" for @e;
105
106         } else {
107                 print "No $t occurred\n";
108         } 
109 }
110
111 print "\n";
112
113
114
115