Lines 18-23
Link Here
|
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
|
|
21 |
use Test::Deep qw( cmp_deeply re ); |
21 |
use Test::MockTime qw/set_fixed_time restore_time/; |
22 |
use Test::MockTime qw/set_fixed_time restore_time/; |
22 |
|
23 |
|
23 |
use Test::More tests => 31; |
24 |
use Test::More tests => 31; |
Lines 74-85
$dbh->do('DELETE FROM oai_sets');
Link Here
|
74 |
|
75 |
|
75 |
set_fixed_time(CORE::time()); |
76 |
set_fixed_time(CORE::time()); |
76 |
|
77 |
|
77 |
my $base_datetime = dt_from_string(); |
78 |
my $base_datetime = dt_from_string(undef, undef, 'UTC'); |
78 |
my $date_added = $base_datetime->ymd . ' ' .$base_datetime->hms . 'Z'; |
79 |
my $date_added = $base_datetime->ymd . ' ' .$base_datetime->hms . 'Z'; |
79 |
my $date_to = substr($date_added, 0, 10) . 'T23:59:59Z'; |
80 |
my $date_to = substr($date_added, 0, 10) . 'T23:59:59Z'; |
80 |
my (@header, @marcxml, @oaidc, @marcxml_transformed); |
81 |
my (@header, @marcxml, @oaidc, @marcxml_transformed); |
81 |
my $sth = $dbh->prepare('UPDATE biblioitems SET timestamp=? WHERE biblionumber=?'); |
82 |
my $sth = $dbh->prepare('UPDATE biblioitems SET timestamp=? WHERE biblionumber=?'); |
82 |
my $sth2 = $dbh->prepare('UPDATE biblio_metadata SET timestamp=? WHERE biblionumber=?'); |
83 |
my $sth2 = $dbh->prepare('UPDATE biblio_metadata SET timestamp=? WHERE biblionumber=?'); |
|
|
84 |
my $first_bn = 0; |
83 |
|
85 |
|
84 |
# Add biblio records |
86 |
# Add biblio records |
85 |
foreach my $index ( 0 .. NUMBER_OF_MARC_RECORDS - 1 ) { |
87 |
foreach my $index ( 0 .. NUMBER_OF_MARC_RECORDS - 1 ) { |
Lines 94-99
foreach my $index ( 0 .. NUMBER_OF_MARC_RECORDS - 1 ) {
Link Here
|
94 |
$record->append_fields( MARC::Field->new('952', '', '', 'a' => "Code" ) ); |
96 |
$record->append_fields( MARC::Field->new('952', '', '', 'a' => "Code" ) ); |
95 |
} |
97 |
} |
96 |
my ($biblionumber) = AddBiblio($record, ''); |
98 |
my ($biblionumber) = AddBiblio($record, ''); |
|
|
99 |
$first_bn = $biblionumber unless $first_bn; |
97 |
my $timestamp = $base_datetime->ymd . ' ' .$base_datetime->hms; |
100 |
my $timestamp = $base_datetime->ymd . ' ' .$base_datetime->hms; |
98 |
$sth->execute($timestamp,$biblionumber); |
101 |
$sth->execute($timestamp,$biblionumber); |
99 |
$sth2->execute($timestamp,$biblionumber); |
102 |
$sth2->execute($timestamp,$biblionumber); |
Lines 174-180
sub test_query {
Link Here
|
174 |
} |
177 |
} |
175 |
|
178 |
|
176 |
delete $response->{responseDate}; |
179 |
delete $response->{responseDate}; |
177 |
unless (is_deeply($response, \%full_expected, $test)) { |
180 |
unless (cmp_deeply($response, \%full_expected, $test)) { |
178 |
diag |
181 |
diag |
179 |
"PARAM:" . Dump($param) . |
182 |
"PARAM:" . Dump($param) . |
180 |
"EXPECTED:" . Dump(\%full_expected) . |
183 |
"EXPECTED:" . Dump(\%full_expected) . |
Lines 215-221
test_query('ListIdentifiers', {verb => 'ListIdentifiers', metadataPrefix => 'mar
Link Here
|
215 |
ListIdentifiers => { |
218 |
ListIdentifiers => { |
216 |
header => [ @header[0..2] ], |
219 |
header => [ @header[0..2] ], |
217 |
resumptionToken => { |
220 |
resumptionToken => { |
218 |
content => "marcxml/3/1970-01-01T00:00:00Z/$date_to//0/0", |
221 |
content => re( qr{^marcxml/3/1970-01-01T00:00:00Z/$date_to//0/0/\d+$} ), |
219 |
cursor => 3, |
222 |
cursor => 3, |
220 |
}, |
223 |
}, |
221 |
}, |
224 |
}, |
Lines 225-231
test_query('ListIdentifiers', {verb => 'ListIdentifiers', metadataPrefix => 'mar
Link Here
|
225 |
ListIdentifiers => { |
228 |
ListIdentifiers => { |
226 |
header => [ @header[0..2] ], |
229 |
header => [ @header[0..2] ], |
227 |
resumptionToken => { |
230 |
resumptionToken => { |
228 |
content => "marcxml/3/1970-01-01T00:00:00Z/$date_to//0/0", |
231 |
content => re( qr{^marcxml/3/1970-01-01T00:00:00Z/$date_to//0/0/\d+$} ), |
229 |
cursor => 3, |
232 |
cursor => 3, |
230 |
}, |
233 |
}, |
231 |
}, |
234 |
}, |
Lines 233-244
test_query('ListIdentifiers', {verb => 'ListIdentifiers', metadataPrefix => 'mar
Link Here
|
233 |
|
236 |
|
234 |
test_query( |
237 |
test_query( |
235 |
'ListIdentifiers with resumptionToken 1', |
238 |
'ListIdentifiers with resumptionToken 1', |
236 |
{ verb => 'ListIdentifiers', resumptionToken => "marcxml/3/1970-01-01T00:00:00Z/$date_to//0/0" }, |
239 |
{ verb => 'ListIdentifiers', resumptionToken => "marcxml/3/1970-01-01T00:00:00Z/$date_to//0/0/" . ($first_bn + 3) }, |
237 |
{ |
240 |
{ |
238 |
ListIdentifiers => { |
241 |
ListIdentifiers => { |
239 |
header => [ @header[3..5] ], |
242 |
header => [ @header[3..5] ], |
240 |
resumptionToken => { |
243 |
resumptionToken => { |
241 |
content => "marcxml/6/1970-01-01T00:00:00Z/$date_to//0/0", |
244 |
content => re( qr{^marcxml/6/1970-01-01T00:00:00Z/$date_to//0/0/\d+$} ), |
242 |
cursor => 6, |
245 |
cursor => 6, |
243 |
}, |
246 |
}, |
244 |
}, |
247 |
}, |
Lines 247-258
test_query(
Link Here
|
247 |
|
250 |
|
248 |
test_query( |
251 |
test_query( |
249 |
'ListIdentifiers with resumptionToken 2', |
252 |
'ListIdentifiers with resumptionToken 2', |
250 |
{ verb => 'ListIdentifiers', resumptionToken => "marcxml/6/1970-01-01T00:00:00Z/$date_to//0/0" }, |
253 |
{ verb => 'ListIdentifiers', resumptionToken => "marcxml/6/1970-01-01T00:00:00Z/$date_to//0/0/" . ($first_bn + 6) }, |
251 |
{ |
254 |
{ |
252 |
ListIdentifiers => { |
255 |
ListIdentifiers => { |
253 |
header => [ @header[6..8] ], |
256 |
header => [ @header[6..8] ], |
254 |
resumptionToken => { |
257 |
resumptionToken => { |
255 |
content => "marcxml/9/1970-01-01T00:00:00Z/$date_to//0/0", |
258 |
content => re( qr{^marcxml/9/1970-01-01T00:00:00Z/$date_to//0/0/\d+$} ), |
256 |
cursor => 9, |
259 |
cursor => 9, |
257 |
}, |
260 |
}, |
258 |
}, |
261 |
}, |
Lines 261-267
test_query(
Link Here
|
261 |
|
264 |
|
262 |
test_query( |
265 |
test_query( |
263 |
'ListIdentifiers with resumptionToken 3, response without resumption', |
266 |
'ListIdentifiers with resumptionToken 3, response without resumption', |
264 |
{ verb => 'ListIdentifiers', resumptionToken => "marcxml/9/1970-01-01T00:00:00Z/$date_to//0/0" }, |
267 |
{ verb => 'ListIdentifiers', resumptionToken => "marcxml/9/1970-01-01T00:00:00Z/$date_to//0/0/" . ($first_bn + 9) }, |
265 |
{ |
268 |
{ |
266 |
ListIdentifiers => { |
269 |
ListIdentifiers => { |
267 |
header => $header[9], |
270 |
header => $header[9], |
Lines 280-286
test_query('ListRecords marcxml', {verb => 'ListRecords', metadataPrefix => 'mar
Link Here
|
280 |
ListRecords => { |
283 |
ListRecords => { |
281 |
record => [ @marcxml[0..2] ], |
284 |
record => [ @marcxml[0..2] ], |
282 |
resumptionToken => { |
285 |
resumptionToken => { |
283 |
content => "marcxml/3/1970-01-01T00:00:00Z/$date_to//0/0", |
286 |
content => re( qr{^marcxml/3/1970-01-01T00:00:00Z/$date_to//0/0/\d+$} ), |
284 |
cursor => 3, |
287 |
cursor => 3, |
285 |
}, |
288 |
}, |
286 |
}, |
289 |
}, |
Lines 288-298
test_query('ListRecords marcxml', {verb => 'ListRecords', metadataPrefix => 'mar
Link Here
|
288 |
|
291 |
|
289 |
test_query( |
292 |
test_query( |
290 |
'ListRecords marcxml with resumptionToken 1', |
293 |
'ListRecords marcxml with resumptionToken 1', |
291 |
{ verb => 'ListRecords', resumptionToken => "marcxml/3/1970-01-01T00:00:00Z/$date_to//0/0" }, |
294 |
{ verb => 'ListRecords', resumptionToken => "marcxml/3/1970-01-01T00:00:00Z/$date_to//0/0/" . ($first_bn + 3) }, |
292 |
{ ListRecords => { |
295 |
{ ListRecords => { |
293 |
record => [ @marcxml[3..5] ], |
296 |
record => [ @marcxml[3..5] ], |
294 |
resumptionToken => { |
297 |
resumptionToken => { |
295 |
content => "marcxml/6/1970-01-01T00:00:00Z/$date_to//0/0", |
298 |
content => re( qr{^marcxml/6/1970-01-01T00:00:00Z/$date_to//0/0/\d+$} ), |
296 |
cursor => 6, |
299 |
cursor => 6, |
297 |
}, |
300 |
}, |
298 |
}, |
301 |
}, |
Lines 300-310
test_query(
Link Here
|
300 |
|
303 |
|
301 |
test_query( |
304 |
test_query( |
302 |
'ListRecords marcxml with resumptionToken 2', |
305 |
'ListRecords marcxml with resumptionToken 2', |
303 |
{ verb => 'ListRecords', resumptionToken => "marcxml/6/1970-01-01T00:00:00Z/$date_to//0/0" }, |
306 |
{ verb => 'ListRecords', resumptionToken => "marcxml/6/1970-01-01T00:00:00Z/$date_to//0/0/" . ($first_bn + 6) }, |
304 |
{ ListRecords => { |
307 |
{ ListRecords => { |
305 |
record => [ @marcxml[6..8] ], |
308 |
record => [ @marcxml[6..8] ], |
306 |
resumptionToken => { |
309 |
resumptionToken => { |
307 |
content => "marcxml/9/1970-01-01T00:00:00Z/$date_to//0/0", |
310 |
content => re( qr{^marcxml/9/1970-01-01T00:00:00Z/$date_to//0/0/\d+$} ), |
308 |
cursor => 9, |
311 |
cursor => 9, |
309 |
}, |
312 |
}, |
310 |
}, |
313 |
}, |
Lines 313-319
test_query(
Link Here
|
313 |
# Last record, so no resumption token |
316 |
# Last record, so no resumption token |
314 |
test_query( |
317 |
test_query( |
315 |
'ListRecords marcxml with resumptionToken 3, response without resumption', |
318 |
'ListRecords marcxml with resumptionToken 3, response without resumption', |
316 |
{ verb => 'ListRecords', resumptionToken => "marcxml/9/1970-01-01T00:00:00Z/$date_to//0/0" }, |
319 |
{ verb => 'ListRecords', resumptionToken => "marcxml/9/1970-01-01T00:00:00Z/$date_to//0/0/" . ($first_bn + 9) }, |
317 |
{ ListRecords => { |
320 |
{ ListRecords => { |
318 |
record => $marcxml[9], |
321 |
record => $marcxml[9], |
319 |
}, |
322 |
}, |
Lines 323-329
test_query('ListRecords oai_dc', {verb => 'ListRecords', metadataPrefix => 'oai_
Link Here
|
323 |
ListRecords => { |
326 |
ListRecords => { |
324 |
record => [ @oaidc[0..2] ], |
327 |
record => [ @oaidc[0..2] ], |
325 |
resumptionToken => { |
328 |
resumptionToken => { |
326 |
content => "oai_dc/3/1970-01-01T00:00:00Z/$date_to//0/0", |
329 |
content => re( qr{^oai_dc/3/1970-01-01T00:00:00Z/$date_to//0/0/\d+$} ), |
327 |
cursor => 3, |
330 |
cursor => 3, |
328 |
}, |
331 |
}, |
329 |
}, |
332 |
}, |
Lines 331-341
test_query('ListRecords oai_dc', {verb => 'ListRecords', metadataPrefix => 'oai_
Link Here
|
331 |
|
334 |
|
332 |
test_query( |
335 |
test_query( |
333 |
'ListRecords oai_dc with resumptionToken 1', |
336 |
'ListRecords oai_dc with resumptionToken 1', |
334 |
{ verb => 'ListRecords', resumptionToken => "oai_dc/3/1970-01-01T00:00:00Z/$date_to//0/0" }, |
337 |
{ verb => 'ListRecords', resumptionToken => "oai_dc/3/1970-01-01T00:00:00Z/$date_to//0/0/" . ($first_bn + 3) }, |
335 |
{ ListRecords => { |
338 |
{ ListRecords => { |
336 |
record => [ @oaidc[3..5] ], |
339 |
record => [ @oaidc[3..5] ], |
337 |
resumptionToken => { |
340 |
resumptionToken => { |
338 |
content => "oai_dc/6/1970-01-01T00:00:00Z/$date_to//0/0", |
341 |
content => re( qr{^oai_dc/6/1970-01-01T00:00:00Z/$date_to//0/0/\d+$} ), |
339 |
cursor => 6, |
342 |
cursor => 6, |
340 |
}, |
343 |
}, |
341 |
}, |
344 |
}, |
Lines 343-353
test_query(
Link Here
|
343 |
|
346 |
|
344 |
test_query( |
347 |
test_query( |
345 |
'ListRecords oai_dc with resumptionToken 2', |
348 |
'ListRecords oai_dc with resumptionToken 2', |
346 |
{ verb => 'ListRecords', resumptionToken => "oai_dc/6/1970-01-01T00:00:00Z/$date_to//0/0" }, |
349 |
{ verb => 'ListRecords', resumptionToken => "oai_dc/6/1970-01-01T00:00:00Z/$date_to//0/0/" . ($first_bn + 6) }, |
347 |
{ ListRecords => { |
350 |
{ ListRecords => { |
348 |
record => [ @oaidc[6..8] ], |
351 |
record => [ @oaidc[6..8] ], |
349 |
resumptionToken => { |
352 |
resumptionToken => { |
350 |
content => "oai_dc/9/1970-01-01T00:00:00Z/$date_to//0/0", |
353 |
content => re( qr{^oai_dc/9/1970-01-01T00:00:00Z/$date_to//0/0/\d+$} ), |
351 |
cursor => 9, |
354 |
cursor => 9, |
352 |
}, |
355 |
}, |
353 |
}, |
356 |
}, |
Lines 356-362
test_query(
Link Here
|
356 |
# Last record, so no resumption token |
359 |
# Last record, so no resumption token |
357 |
test_query( |
360 |
test_query( |
358 |
'ListRecords oai_dc with resumptionToken 3, response without resumption', |
361 |
'ListRecords oai_dc with resumptionToken 3, response without resumption', |
359 |
{ verb => 'ListRecords', resumptionToken => "oai_dc/9/1970-01-01T00:00:00Z/$date_to//0/0" }, |
362 |
{ verb => 'ListRecords', resumptionToken => "oai_dc/9/1970-01-01T00:00:00Z/$date_to//0/0/" . ($first_bn + 9) }, |
360 |
{ ListRecords => { |
363 |
{ ListRecords => { |
361 |
record => $oaidc[9], |
364 |
record => $oaidc[9], |
362 |
}, |
365 |
}, |
Lines 369-375
test_query('ListRecords marcxml with xsl transformation',
Link Here
|
369 |
{ ListRecords => { |
372 |
{ ListRecords => { |
370 |
record => [ @marcxml_transformed[0..2] ], |
373 |
record => [ @marcxml_transformed[0..2] ], |
371 |
resumptionToken => { |
374 |
resumptionToken => { |
372 |
content => "marcxml/3/1970-01-01T00:00:00Z/$date_to//0/0", |
375 |
content => re( qr{^marcxml/3/1970-01-01T00:00:00Z/$date_to//0/0/\d+$} ), |
373 |
cursor => 3, |
376 |
cursor => 3, |
374 |
} |
377 |
} |
375 |
}, |
378 |
}, |
376 |
- |
|
|