my $apputils = 'OpenILS::Application::AppUtils';
+sub find_workstation {
+ my ($self,$name,$lib) = (shift,shift,shift);
+ my $resp = $apputils->simplereq(
+ 'open-ils.actor',
+ 'open-ils.actor.workstation.list',
+ $self->authtoken,
+ $lib
+ );
+ if ($resp->{$lib}) {
+ return scalar(grep {$_->name() eq $name} @{$resp->{$lib}});
+ }
+ return 0;
+}
+
sub register_workstation {
my ($self,$name,$lib) = (shift,shift,shift);
my $resp = $apputils->simplereq(
return $resp;
}
+sub find_or_register_workstation {
+ my ($self,$name,$lib) = (shift,shift,shift);
+ my $workstation = $self->find_workstation($name, $lib);
+ if (!$workstation) {
+ $workstation = $self->register_workstation($name, $lib);
+ }
+ return $workstation;
+}
+
sub do_checkout {
my ($self,$args) = (shift,shift);
my $resp = $apputils->simplereq(
use constant WORKSTATION_NAME => 'BR1-test-lp1499123_csp_ignore_proximity.t';
use constant WORKSTATION_LIB => 4;
-# Because this may run multiple times, without a DB reload, we search
-# for the workstation before registering it.
-sub find_workstation {
- my $r = $apputils->simplereq(
- 'open-ils.actor',
- 'open-ils.actor.workstation.list',
- $script->authtoken,
- WORKSTATION_LIB
- );
- if ($r->{&WORKSTATION_LIB}) {
- return scalar(grep {$_->name() eq WORKSTATION_NAME} @{$r->{&WORKSTATION_LIB}});
- }
- return 0;
-}
-
sub retrieve_staff_chr {
my $e = shift;
my $staff_chr = $e->retrieve_config_standing_penalty(25);
ok($script->authtoken, 'Initial Login');
SKIP: {
- my $ws = find_workstation();
+ my $ws = $script->find_workstation(WORKSTATION_NAME, WORKSTATION_LIB);
skip 'Workstation exists', 1 if ($ws);
$ws = $script->register_workstation(WORKSTATION_NAME, WORKSTATION_LIB) unless ($ws);
ok(! ref $ws, 'Registered a new workstation');
use constant WORKSTATION_NAME => 'BR1-test-lp1592891_sip_standing_penalties.t';
use constant WORKSTATION_LIB => 4;
-# Because this may run multiple times, without a DB reload, we search
-# for the workstation before registering it.
-sub find_workstation {
- my $r = $apputils->simplereq(
- 'open-ils.actor',
- 'open-ils.actor.workstation.list',
- $script->authtoken,
- WORKSTATION_LIB
- );
- if ($r->{&WORKSTATION_LIB}) {
- return scalar(grep {$_->name() eq WORKSTATION_NAME} @{$r->{&WORKSTATION_LIB}});
- }
- return 0;
-}
-
sub retrieve_penalty {
my $e = shift;
my $penalty = shift;
ok($script->authtoken, 'Initial Login');
SKIP: {
- my $ws = find_workstation();
+ my $ws = $script->find_workstation(WORKSTATION_NAME, WORKSTATION_LIB);
skip 'Workstation exists', 1 if ($ws);
$ws = $script->register_workstation(WORKSTATION_NAME, WORKSTATION_LIB) unless ($ws);
ok(! ref $ws, 'Registered a new workstation');
CBARCODE => 'CONC4000036'
};
-# Because this may run multiple times, without a DB reload, we search
-# for the workstation before registering it. Takes an authtoken, the
-# id of the workstation lib, and the name of the workstation.
-sub find_workstation {
- my ($authtoken, $lib, $workstation) = @_;
- my $r = $apputils->simplereq(
- 'open-ils.actor',
- 'open-ils.actor.workstation.list',
- $authtoken,
- $lib
- );
- if ($r->{$lib}) {
- return scalar(grep {$_->name() eq $workstation} @{$r->{$lib}});
- }
- return 0;
-}
-
# Store authtokens
my @authtoken = ();
});
# Register workstation at BR1.
-unless (find_workstation($authtoken[0], BR1_ID, BR1_WORKSTATION)) {
+unless ($script->find_workstation(BR1_WORKSTATION, BR1_ID)) {
$script->register_workstation(BR1_WORKSTATION, BR1_ID);
}
});
# Register workstation at BR3.
-unless (find_workstation($authtoken[1], BR3_ID, BR3_WORKSTATION)) {
+unless ($script->find_workstation(BR3_WORKSTATION, BR3_ID)) {
$script->register_workstation(BR3_WORKSTATION, BR3_ID);
}
COPY_ID => 2503,
};
-# Because this may run multiple times, without a DB reload, we search
-# for the workstation before registering it. Takes an authtoken, the
-# id of the workstation lib, and the name of the workstation.
-sub find_or_register_workstation {
- my ($authtoken, $lib, $workstation) = @_;
- my $ws;
- my $r = $U->simplereq(
- 'open-ils.actor',
- 'open-ils.actor.workstation.list',
- $authtoken,
- $lib
- );
- if ($r && $r->{$lib}) {
- $ws = grep {$_->name() eq $workstation} @{$r->{$lib}};
- }
- unless ($ws) {
- $ws = $script->register_workstation($workstation, $lib);
- }
- return $ws;
-}
-
-
# Keep track of hold ids, so we can cancel them later.
my @holds = ();
);
# Register workstation.
-my $ws = find_or_register_workstation($authtoken, BR1_ID, BR1_WORKSTATION);
+my $ws = $script->find_or_register_workstation(BR1_WORKSTATION, BR1_ID);
ok(
! ref $ws,
'Found or registered workstation'