]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/support-scripts/test-scripts/copy_locations.pl
adding copy_location related code ... module plus test script and related events
[Evergreen.git] / Open-ILS / src / support-scripts / test-scripts / copy_locations.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> <name> <org>\n".
14         "Where <name> is the copy location name and <org> is the \n".
15         "org that houses the new location object\n") unless $ARGV[4];
16 #----------------------------------------------------------------
17
18 my $config              = shift; 
19 my $username    = shift;
20 my $password    = shift;
21 my $name                        = shift;
22 my $org                 = shift;
23
24 sub go {
25         osrf_connect($config);
26         oils_login($username, $password);
27         my $cl =create_cl($name, $org);
28         update_cl($cl);
29 #       print_cl($org);
30         delete_cl($cl);
31 }
32
33 go();
34
35 #----------------------------------------------------------------
36
37 sub create_cl {
38         my( $name, $org ) = @_;
39
40         my $cl = Fieldmapper::asset::copy_location->new;
41         $cl->owning_lib($org);
42         $cl->name($name);
43         $cl->circulate(0);
44         $cl->opac_visible(0);
45         $cl->holdable(0);
46
47         my $resp = simplereq(
48                 CIRC(), 'open-ils.circ.copy_location.create', $authtoken, $cl );
49
50         oils_event_die($resp);
51         printl("Copy location $name successfully created");
52         $cl->id($resp);
53         return $cl;
54 }
55
56 sub print_cl {
57         my( $org ) = @_;
58         debug( simplereq(
59                 CIRC(), 'open-ils.circ.copy_location.retrieve.all', $authtoken, $org ) );
60 }
61
62 sub update_cl {
63         my $cl = shift;
64         $cl->name( 'test_' . $cl->name );
65         my $resp = simplereq(
66                 CIRC(), 'open-ils.circ.copy_location.update', $authtoken, $cl );
67         oils_event_die($resp);
68         printl("Successfully set copy location name to ".$cl->name);
69 }
70
71 sub delete_cl {
72         my $cl = shift;
73         my $resp = simplereq(
74                 CIRC(), 'open-ils.circ.copy_location.delete', $authtoken, $cl->id );
75         oils_event_die($resp);
76         printl("Copy location successfully deleted");
77 }
78
79