]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/support-scripts/test-scripts/copy_notes.pl
Fix empty statuses filter
[working/Evergreen.git] / Open-ILS / src / support-scripts / test-scripts / copy_notes.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/ $user $authtoken /;
9 use strict; use warnings;
10
11 my $config              = shift; 
12 my $copyid              = shift;
13 #my $copyid             = 1;
14 my $username    = shift || 'admin';
15 my $password    = shift || 'open-ils';
16
17 my $create_method               = 'open-ils.circ.copy_note.create';
18 my $retrieve_method     = 'open-ils.circ.copy_note.retrieve.all';
19 my $delete_method               = 'open-ils.circ.copy_note.delete';
20
21
22 sub go {
23         osrf_connect($config);
24         oils_login($username, $password);
25         oils_fetch_session($authtoken);
26         create_notes();
27         retrieve_notes();
28         delete_notes();
29 }
30 go();
31
32 #----------------------------------------------------------------
33
34 my @ids_created;
35 sub create_notes {
36
37         for(0..5) {
38                 my $note = Fieldmapper::asset::copy_note->new;
39         
40                 $note->owning_copy($copyid);
41                 $note->creator($user->id);
42                 $note->title("Test Note 1");
43                 $note->value("This copy needs to be fixed - $_");
44                 $note->pub(1);
45         
46                 my $id = simplereq(
47                         'open-ils.circ', $create_method, $authtoken, $note );
48                 oils_event_die($id);
49                 push(@ids_created, $id);
50                 printl("Created copy note $id");
51         }
52 }
53
54 sub retrieve_notes {
55         my $notes = simplereq(
56                 'open-ils.circ', $retrieve_method, 
57                         {authtoken => $authtoken, itemid => $copyid});
58         oils_event_die($notes);
59         printl("Retrieved: [".$_->id."] ".$_->value) for @$notes;
60 }
61
62 sub delete_notes() {
63         for my $id (@ids_created) {
64                 my $stat = simplereq(
65                         'open-ils.circ', $delete_method, $authtoken, $id);
66                 oils_event_die($stat);
67                 printl("Deleted note $id");
68         }
69 }
70
71
72