LP#1497322: add Perl live_t regression and unit tests for patron searching
authorGalen Charlton <gmc@equinoxinitiative.org>
Mon, 30 Apr 2018 20:14:52 +0000 (16:14 -0400)
committerMike Rylander <mrylander@gmail.com>
Tue, 22 May 2018 19:54:35 +0000 (15:54 -0400)
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/perlmods/live_t/27-lp1497322-patron-search-by-profile.t [new file with mode: 0644]

diff --git a/Open-ILS/src/perlmods/live_t/27-lp1497322-patron-search-by-profile.t b/Open-ILS/src/perlmods/live_t/27-lp1497322-patron-search-by-profile.t
new file mode 100644 (file)
index 0000000..b07fa5b
--- /dev/null
@@ -0,0 +1,62 @@
+#!perl
+use strict; use warnings;
+
+use Test::More tests => 4;
+
+diag("Tests searching for patrons by profile");
+
+use DateTime;
+use OpenILS::Utils::TestUtils;
+my $script = OpenILS::Utils::TestUtils->new();
+our $apputils = 'OpenILS::Application::AppUtils';
+$script->bootstrap;
+
+$script->authenticate({
+    username => 'admin',
+    password => 'demo123',
+    type => 'staff'
+});
+
+ok($script->authtoken, 'Have an authtoken');
+
+my $results = $apputils->simplereq(
+    'open-ils.actor',
+    'open-ils.actor.patron.search.advanced.fleshed.atomic',
+    $script->authtoken,
+    {"family_name" => {"value" => "smith", "group" =>  0}},
+    10,
+    [],
+    undef,
+    1,
+    ["cards"]
+);
+
+cmp_ok(@$results, '>=', 1, 'Patron search on "Smith" returns at least one result');
+
+$results = $apputils->simplereq(
+    'open-ils.actor',
+    'open-ils.actor.patron.search.advanced.fleshed.atomic',
+    $script->authtoken,
+    {"profile" => {"value" => 3, "group" =>  0}},
+    10,
+    [],
+    undef,
+    1,
+    ["cards"]
+);
+
+cmp_ok(@$results, '==', 0, 'Patron search profile 3 (staff) in group 0 returns at zero results');
+
+$results = $apputils->simplereq(
+    'open-ils.actor',
+    'open-ils.actor.patron.search.advanced.fleshed.atomic',
+    $script->authtoken,
+    {"profile" => {"value" => 3, "group" =>  5}},
+    10,
+    [],
+    undef,
+    1,
+    ["cards"]
+);
+
+cmp_ok(@$results, '>=', 1, 'Patron search profile 3 (staff) in group 5 returns at least one result');