Lines 61-78
my $patron = $builder->build_object(
Link Here
|
61 |
} |
61 |
} |
62 |
); |
62 |
); |
63 |
my $unauth_password = 'thePassword000'; |
63 |
my $unauth_password = 'thePassword000'; |
64 |
$patron->set_password( |
64 |
$patron->set_password( { password => $unauth_password, skip_validattion => 1 } ); |
65 |
{ password => $unauth_password, skip_validattion => 1 } ); |
|
|
66 |
my $unauth_userid = $patron->userid; |
65 |
my $unauth_userid = $patron->userid; |
67 |
my $patron_id = $patron->borrowernumber; |
66 |
my $patron_id = $patron->borrowernumber; |
68 |
|
67 |
|
69 |
my $item1 = $builder->build_sample_item; |
68 |
my $item1 = $builder->build_sample_item; |
70 |
my $item1_id = $item1->id; |
69 |
my $item1_id = $item1->id; |
71 |
|
70 |
|
72 |
my $itemtype = $builder->build( { source => 'Itemtype' } )->{itemtype}; |
71 |
my $itemtype = $builder->build( { source => 'Itemtype' } )->{itemtype}; |
73 |
my $biblio_2 = $builder->build_sample_biblio; |
72 |
my $biblio_2 = $builder->build_sample_biblio; |
74 |
my $item_2 = $builder->build_sample_item( |
73 |
my $item_2 = $builder->build_sample_item( { biblionumber => $biblio_2->biblionumber, itype => $itemtype } ); |
75 |
{ biblionumber => $biblio_2->biblionumber, itype => $itemtype } ); |
|
|
76 |
my $item_2_barcode = $item_2->barcode; |
74 |
my $item_2_barcode = $item_2->barcode; |
77 |
my $item_2_id = $item_2->id; |
75 |
my $item_2_id = $item_2->id; |
78 |
|
76 |
|
Lines 146-176
my $reserve_id = C4::Reserves::AddReserve(
Link Here
|
146 |
); |
144 |
); |
147 |
|
145 |
|
148 |
# empty checkin |
146 |
# empty checkin |
149 |
$t->post_ok( "//$userid:$password@/api/v1/checkin" => json => {} ) |
147 |
$t->post_ok( "//$userid:$password@/api/v1/checkin" => json => {} )->status_is(400); |
150 |
->status_is(400); |
|
|
151 |
|
148 |
|
152 |
# checkin on unknow item id |
149 |
# checkin on unknown item id |
153 |
$t->post_ok( "//$userid:$password@/api/v1/checkin" => json => |
150 |
$t->post_ok( "//$userid:$password@/api/v1/checkin" => json => { item_id => $non_existent_item_id } )->status_is(404) |
154 |
{ item_id => $non_existent_item_id } )->status_is(404) |
151 |
->json_is( { error => 'Item not found', error_code => 'ITEM_NOT_FOUND' } ); |
155 |
->json_is( { error => 'Item not found', error_code => 'ITEM_NOT_FOUND' } ); |
|
|
156 |
|
152 |
|
157 |
# checkin with unknow barcode |
153 |
# checkin with unknown barcode |
158 |
$t->post_ok( "//$userid:$password@/api/v1/checkin" => json => |
154 |
$t->post_ok( "//$userid:$password@/api/v1/checkin" => json => { external_id => $non_existent_item_barcode } ) |
159 |
{ external_id => $non_existent_item_barcode } )->status_is(404) |
155 |
->status_is(404)->json_is( { error => 'Item not found', error_code => 'ITEM_NOT_FOUND' } ); |
160 |
->json_is( { error => 'Item not found', error_code => 'ITEM_NOT_FOUND' } ); |
|
|
161 |
|
156 |
|
162 |
# not isued |
157 |
# not isued |
163 |
$t->post_ok( "//$userid:$password@/api/v1/checkin" => json => |
158 |
$t->post_ok( |
164 |
{ item_id => $not_issued_item_id, library_id => $branchcode } ) |
159 |
"//$userid:$password@/api/v1/checkin" => json => { item_id => $not_issued_item_id, library_id => $branchcode } ) |
165 |
->status_is(403)->json_is( '/returned' => 0 ) |
160 |
->status_is(403)->json_is( '/returned' => 0 )->json_has( '/messages' => { NotIssued => $not_issued_item_barcode } ); |
166 |
->json_has( '/messages' => { NotIssued => $not_issued_item_barcode } ); |
|
|
167 |
|
161 |
|
168 |
# checkin okay |
162 |
# checkin okay |
169 |
$t->post_ok( "//$userid:$password@/api/v1/checkin" => json => |
163 |
$t->post_ok( "//$userid:$password@/api/v1/checkin" => json => { item_id => $item1_id, library_id => $branchcode } ) |
170 |
{ item_id => $item1_id, library_id => $branchcode } )->status_is(201) |
164 |
->status_is(201)->json_is( '/returned' => 1 ) |
171 |
->json_is( '/returned' => 1 ) |
165 |
->json_has( '/messages' => { TransferTrigger => 'ReturnToHome', WasReturned => '1' } ); |
172 |
->json_has( |
|
|
173 |
'/messages' => { TransferTrigger => 'ReturnToHome', WasReturned => '1' } ); |
174 |
|
166 |
|
175 |
#mismatch of item_id and barcode when both given |
167 |
#mismatch of item_id and barcode when both given |
176 |
$t->post_ok( |
168 |
$t->post_ok( |
Lines 182-192
$t->post_ok(
Link Here
|
182 |
)->status_is(409); |
174 |
)->status_is(409); |
183 |
|
175 |
|
184 |
# reserved item |
176 |
# reserved item |
185 |
$t->post_ok( "//$userid:$password@/api/v1/checkin" => json => |
177 |
$t->post_ok( "//$userid:$password@/api/v1/checkin" => json => { item_id => $item_2_id, library_id => $branchcode } ) |
186 |
{ item_id => $item_2_id, library_id => $branchcode } )->status_is(201) |
178 |
->status_is(201)->json_is( '/returned' => 1 )->json_has( |
187 |
->json_is( '/returned' => 1 )->json_has( |
|
|
188 |
'/messages' => { WasReturned => '1' }, |
179 |
'/messages' => { WasReturned => '1' }, |
189 |
'/ResFound' => { "ResFound" => "Reserved" } |
180 |
'/ResFound' => { "ResFound" => "Reserved" } |
190 |
); |
181 |
); |
191 |
|
182 |
|
192 |
$schema->storage->txn_rollback; |
183 |
$schema->storage->txn_rollback; |
193 |
- |
|
|