]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/perlmods/live_t/02-simple_circ.t
Lp#1718459: Remove Debian 7 Wheezy Installation Support
[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
19 #----------------------------------------------------------------
20
21 my $storage_ses = $script->session('open-ils.storage');
22
23 my $user_req = $storage_ses->request('open-ils.storage.direct.actor.user.retrieve', 1);
24 if (my $user_resp = $user_req->recv) {
25     if (my $user = $user_resp->content) {
26         is(
27             ref $user,
28             'Fieldmapper::actor::user',
29             'open-ils.storage.direct.actor.user.retrieve returned aou object'
30         );
31         is(
32             $user->usrname,
33             'admin',
34             'User with id = 1 is admin user'
35         );
36     }
37 }
38
39 my $item_req = $storage_ses->request('open-ils.storage.direct.asset.copy.retrieve', ITEM_ID);
40 if (my $item_resp = $item_req->recv) {
41     if (my $item = $item_resp->content) {
42         is(
43             ref $item,
44             'Fieldmapper::asset::copy',
45             'open-ils.storage.direct.asset.copy.retrieve returned acp object'
46         );
47         is(
48             $item->barcode,
49             ITEM_BARCODE,
50             'Item with id = ' . ITEM_ID . ' has barcode ' . ITEM_BARCODE
51         );
52         ok(
53             $item->status == 7 || $item->status == 0,
54             'Item with id = ' . ITEM_ID . ' has status of Reshelving or Available'
55         );
56     }
57 }
58
59 $script->authenticate({
60     username => 'admin',
61     password => 'demo123',
62     type => 'staff'});
63 ok(
64     $script->authtoken,
65     'Have an authtoken'
66 );
67 my $ws = $script->register_workstation(WORKSTATION_NAME,WORKSTATION_LIB);
68 ok(
69     ! ref $ws,
70     'Registered a new workstation'
71 );
72
73 $script->logout();
74 $script->authenticate({
75     username => 'admin',
76     password => 'demo123',
77     type => 'staff',
78     workstation => WORKSTATION_NAME});
79 ok(
80     $script->authtoken,
81     'Have an authtoken associated with the workstation'
82 );
83
84 my $checkout_resp = $script->do_checkout({
85     patron => 1,
86     barcode => ITEM_BARCODE});
87 is(
88     ref $checkout_resp,
89     'HASH',
90     'Checkout request returned a HASH'
91 );
92 is(
93     $checkout_resp->{ilsevent},
94     0,
95     'Checkout returned a SUCCESS event'
96 );
97    
98 $item_req = $storage_ses->request('open-ils.storage.direct.asset.copy.retrieve', 310);
99 if (my $item_resp = $item_req->recv) {
100     if (my $item = $item_resp->content) {
101         is(
102             $item->status,
103             1,
104             'Item with id = ' . ITEM_ID . ' has status of Checked Out after fresh Storage request'
105         );
106     }
107 }
108
109 my $checkin_resp = $script->do_checkin({
110     barcode => ITEM_BARCODE});
111 is(
112     ref $checkin_resp,
113     'HASH',
114     'Checkin request returned a HASH'
115 );
116 is(
117     $checkin_resp->{ilsevent},
118     0,
119     'Checkin returned a SUCCESS event'
120 );
121
122 $item_req = $storage_ses->request('open-ils.storage.direct.asset.copy.retrieve', ITEM_ID);
123 if (my $item_resp = $item_req->recv) {
124     if (my $item = $item_resp->content) {
125         ok(
126             $item->status == 7 || $item->status == 0,
127             'Item with id = ' . ITEM_ID . ' has status of Reshelving or Available after fresh Storage request'
128         );
129     }
130 }
131
132 $script->logout();
133