]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/perlmods/live_t/02-simple_circ.t
LP#1670407 Add tests for xact_finish close/re-open
[working/Evergreen.git] / Open-ILS / src / perlmods / live_t / 02-simple_circ.t
1 #!perl
2
3 use Test::More tests => 14;
4
5 diag("Test circulation of item CONC70000345 against the admin user.");
6
7 use constant WORKSTATION_NAME => 'BR4-test-02-simple-circ.t';
8 use constant WORKSTATION_LIB => 7;
9 use constant ITEM_BARCODE => 'CONC70000345';
10 use constant ITEM_ID => 310;
11
12 use strict; use warnings;
13
14 use OpenILS::Utils::TestUtils;
15 my $script = OpenILS::Utils::TestUtils->new();
16
17 #----------------------------------------------------------------
18 # The tests...  assumes stock sample data, full-auto install by
19 # eg_wheezy_installer.sh, etc.
20 #----------------------------------------------------------------
21
22 my $storage_ses = $script->session('open-ils.storage');
23
24 my $user_req = $storage_ses->request('open-ils.storage.direct.actor.user.retrieve', 1);
25 if (my $user_resp = $user_req->recv) {
26     if (my $user = $user_resp->content) {
27         is(
28             ref $user,
29             'Fieldmapper::actor::user',
30             'open-ils.storage.direct.actor.user.retrieve returned aou object'
31         );
32         is(
33             $user->usrname,
34             'admin',
35             'User with id = 1 is admin user'
36         );
37     }
38 }
39
40 my $item_req = $storage_ses->request('open-ils.storage.direct.asset.copy.retrieve', ITEM_ID);
41 if (my $item_resp = $item_req->recv) {
42     if (my $item = $item_resp->content) {
43         is(
44             ref $item,
45             'Fieldmapper::asset::copy',
46             'open-ils.storage.direct.asset.copy.retrieve returned acp object'
47         );
48         is(
49             $item->barcode,
50             ITEM_BARCODE,
51             'Item with id = ' . ITEM_ID . ' has barcode ' . ITEM_BARCODE
52         );
53         ok(
54             $item->status == 7 || $item->status == 0,
55             'Item with id = ' . ITEM_ID . ' has status of Reshelving or Available'
56         );
57     }
58 }
59
60 $script->authenticate({
61     username => 'admin',
62     password => 'demo123',
63     type => 'staff'});
64 ok(
65     $script->authtoken,
66     'Have an authtoken'
67 );
68 my $ws = $script->register_workstation(WORKSTATION_NAME,WORKSTATION_LIB);
69 ok(
70     ! ref $ws,
71     'Registered a new workstation'
72 );
73
74 $script->logout();
75 $script->authenticate({
76     username => 'admin',
77     password => 'demo123',
78     type => 'staff',
79     workstation => WORKSTATION_NAME});
80 ok(
81     $script->authtoken,
82     'Have an authtoken associated with the workstation'
83 );
84
85 my $checkout_resp = $script->do_checkout({
86     patron => 1,
87     barcode => ITEM_BARCODE});
88 is(
89     ref $checkout_resp,
90     'HASH',
91     'Checkout request returned a HASH'
92 );
93 is(
94     $checkout_resp->{ilsevent},
95     0,
96     'Checkout returned a SUCCESS event'
97 );
98    
99 $item_req = $storage_ses->request('open-ils.storage.direct.asset.copy.retrieve', 310);
100 if (my $item_resp = $item_req->recv) {
101     if (my $item = $item_resp->content) {
102         is(
103             $item->status,
104             1,
105             'Item with id = ' . ITEM_ID . ' has status of Checked Out after fresh Storage request'
106         );
107     }
108 }
109
110 my $checkin_resp = $script->do_checkin({
111     barcode => ITEM_BARCODE});
112 is(
113     ref $checkin_resp,
114     'HASH',
115     'Checkin request returned a HASH'
116 );
117 is(
118     $checkin_resp->{ilsevent},
119     0,
120     'Checkin returned a SUCCESS event'
121 );
122
123 $item_req = $storage_ses->request('open-ils.storage.direct.asset.copy.retrieve', ITEM_ID);
124 if (my $item_resp = $item_req->recv) {
125     if (my $item = $item_resp->content) {
126         ok(
127             $item->status == 7 || $item->status == 0,
128             'Item with id = ' . ITEM_ID . ' has status of Reshelving or Available after fresh Storage request'
129         );
130     }
131 }
132
133 $script->logout();
134