add a TestUtils library for live_t
authorJason Etheridge <jason@esilibrary.com>
Thu, 22 Aug 2013 16:48:53 +0000 (12:48 -0400)
committerJason Etheridge <jason@esilibrary.com>
Thu, 22 Aug 2013 19:55:56 +0000 (15:55 -0400)
Based it off of Cronscript.  Added a cache method to Cronscript for getting at
memcached.  TestUtils currently has methods for checkin, checkout, and
workstation registration.

Open-ILS/src/perlmods/lib/OpenILS/Utils/Cronscript.pm.in
Open-ILS/src/perlmods/lib/OpenILS/Utils/TestUtils.pm [new file with mode: 0644]

index e0f7ba4..32ac711 100644 (file)
@@ -393,6 +393,14 @@ sub authtime {
     return $self->{authtime};
 }
 
+sub cache {
+    my $self = shift;
+    my $cache = "OpenSRF::Utils::Cache";
+    $cache->use;
+    $self->{memcache} = $cache->new('global') unless $self->{memcache};
+    return $self->{memcache};
+}
+
 1;
 __END__
 
diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Utils/TestUtils.pm b/Open-ILS/src/perlmods/lib/OpenILS/Utils/TestUtils.pm
new file mode 100644 (file)
index 0000000..c98f39d
--- /dev/null
@@ -0,0 +1,36 @@
+package OpenILS::Utils::TestUtils;
+use base "OpenILS::Utils::Cronscript";
+
+# The purpose of this module is to consolidate common routines that may
+# be used by the integration tests in src/perlmods/live_t/
+
+use strict; use warnings;
+
+my $apputils = 'OpenILS::Application::AppUtils';
+
+sub register_workstation {
+    my ($self,$name,$lib) = (shift,shift,shift);
+    my $resp = $apputils->simplereq(
+        'open-ils.actor',
+        'open-ils.actor.workstation.register',
+        $self->authtoken, $name, $lib);
+    return $resp;
+}
+
+sub do_checkout {
+    my ($self,$args) = (shift,shift);
+    my $resp = $apputils->simplereq(
+        'open-ils.circ',
+        'open-ils.circ.checkout.full', $self->authtoken, $args);
+    return $resp;
+}
+
+sub do_checkin {
+    my ($self,$args) = (shift,shift);
+    my $resp = $apputils->simplereq(
+        'open-ils.circ',
+        'open-ils.circ.checkin', $self->authtoken, $args );
+    return $resp;
+}
+
+1;