]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/perlmods/lib/OpenILS/Utils/TestUtils.pm
LP 1780660: Add more workstation functions to OpenILS::Utils::TestUtils.
[Evergreen.git] / Open-ILS / src / perlmods / lib / OpenILS / Utils / TestUtils.pm
1 package OpenILS::Utils::TestUtils;
2 use base "OpenILS::Utils::Cronscript";
3
4 # The purpose of this module is to consolidate common routines that may
5 # be used by the integration tests in src/perlmods/live_t/
6
7 use strict; use warnings;
8
9 my $apputils = 'OpenILS::Application::AppUtils';
10
11 sub find_workstation {
12     my ($self,$name,$lib) = (shift,shift,shift);
13     my $resp = $apputils->simplereq(
14         'open-ils.actor',
15         'open-ils.actor.workstation.list',
16         $self->authtoken,
17         $lib
18     );
19     if ($resp->{$lib}) {
20         return scalar(grep {$_->name() eq $name} @{$resp->{$lib}});
21     }
22     return 0;
23 }
24
25 sub register_workstation {
26     my ($self,$name,$lib) = (shift,shift,shift);
27     my $resp = $apputils->simplereq(
28         'open-ils.actor',
29         'open-ils.actor.workstation.register',
30         $self->authtoken, $name, $lib);
31     return $resp;
32 }
33
34 sub find_or_register_workstation {
35     my ($self,$name,$lib) = (shift,shift,shift);
36     my $workstation = $self->find_workstation($name, $lib);
37     if (!$workstation) {
38         $workstation = $self->register_workstation($name, $lib);
39     }
40     return $workstation;
41 }
42
43 sub do_checkout {
44     my ($self,$args) = (shift,shift);
45     my $resp = $apputils->simplereq(
46         'open-ils.circ',
47         'open-ils.circ.checkout.full', $self->authtoken, $args);
48     return $resp;
49 }
50
51 sub do_checkin {
52     my ($self,$args) = (shift,shift);
53     my $resp = $apputils->simplereq(
54         'open-ils.circ',
55         'open-ils.circ.checkin', $self->authtoken, $args );
56     return $resp;
57 }
58
59 sub do_checkin_override {
60     my ($self,$args) = (shift,shift);
61     my $resp = $apputils->simplereq(
62         'open-ils.circ',
63         'open-ils.circ.checkin.override', $self->authtoken, $args );
64     return $resp;
65 }
66
67 1;