|
Lines 52-58
BEGIN {
Link Here
|
| 52 |
# Mocked CGI module in order to be able to send CGI parameters to OAI Server |
52 |
# Mocked CGI module in order to be able to send CGI parameters to OAI Server |
| 53 |
my %param; |
53 |
my %param; |
| 54 |
my $module = Test::MockModule->new('CGI'); |
54 |
my $module = Test::MockModule->new('CGI'); |
| 55 |
$module->mock('Vars', sub { %param; }); |
55 |
$module->mock('Vars', sub { %param; }); |
| 56 |
|
56 |
|
| 57 |
my $schema = Koha::Database->schema; |
57 |
my $schema = Koha::Database->schema; |
| 58 |
$schema->storage->txn_begin; |
58 |
$schema->storage->txn_begin; |
|
Lines 61-83
my $dbh = C4::Context->dbh;
Link Here
|
| 61 |
my $builder = t::lib::TestBuilder->new; |
61 |
my $builder = t::lib::TestBuilder->new; |
| 62 |
|
62 |
|
| 63 |
$dbh->do('SET FOREIGN_KEY_CHECKS = 0'); |
63 |
$dbh->do('SET FOREIGN_KEY_CHECKS = 0'); |
|
|
64 |
$dbh->do("SET time_zone='+00:00'"); |
| 64 |
$dbh->do('TRUNCATE biblio'); |
65 |
$dbh->do('TRUNCATE biblio'); |
| 65 |
$dbh->do('TRUNCATE biblioitems'); |
66 |
$dbh->do('TRUNCATE biblioitems'); |
| 66 |
$dbh->do('TRUNCATE issues'); |
67 |
$dbh->do('TRUNCATE issues'); |
| 67 |
|
68 |
|
| 68 |
# Add 10 biblio records |
69 |
# Add 10 biblio records |
| 69 |
our $tz = DateTime::TimeZone->new( name => 'local' ); |
70 |
my $date_added = DateTime->now() . 'Z'; |
| 70 |
my $date_added = DateTime->now(time_zone =>$tz) . 'Z'; |
|
|
| 71 |
my $date_to = substr($date_added, 0, 10) . 'T23:59:59Z'; |
71 |
my $date_to = substr($date_added, 0, 10) . 'T23:59:59Z'; |
| 72 |
|
|
|
| 73 |
my (@header, @metadata, @record); |
72 |
my (@header, @metadata, @record); |
|
|
73 |
my $sth = $dbh->prepare('SELECT timestamp FROM biblioitems WHERE biblionumber=?'); |
| 74 |
map { |
74 |
map { |
| 75 |
my $record = MARC::Record->new(); |
75 |
my $record = MARC::Record->new(); |
| 76 |
$record->append_fields( MARC::Field->new('245', '', '', 'a' => "Title $_" ) ); |
76 |
$record->append_fields( MARC::Field->new('245', '', '', 'a' => "Title $_" ) ); |
| 77 |
my ($biblionumber) = AddBiblio($record, ''); |
77 |
my ($biblionumber) = AddBiblio($record, ''); |
|
|
78 |
$sth->execute($biblionumber); |
| 79 |
my $timestamp = $sth->fetchrow_array . 'Z'; |
| 80 |
$timestamp =~ s/ /T/; |
| 78 |
$record = GetMarcBiblio($biblionumber); |
81 |
$record = GetMarcBiblio($biblionumber); |
| 79 |
$record = XMLin($record->as_xml_record); |
82 |
$record = XMLin($record->as_xml_record); |
| 80 |
$header[$biblionumber] = { datestamp => $date_added, identifier => "TEST:$biblionumber" }; |
83 |
$header[$biblionumber] = { datestamp => $timestamp, identifier => "TEST:$biblionumber" }; |
| 81 |
delete $record->{$_} for (('xmlns','xmlns:xsi','xsi:schemaLocation')); |
84 |
delete $record->{$_} for (('xmlns','xmlns:xsi','xsi:schemaLocation')); |
| 82 |
$metadata[$biblionumber] = { collection => { |
85 |
$metadata[$biblionumber] = { collection => { |
| 83 |
record => $record, |
86 |
record => $record, |
|
Lines 89-94
map {
Link Here
|
| 89 |
header => $header[$biblionumber], |
92 |
header => $header[$biblionumber], |
| 90 |
metadata => $metadata[$biblionumber], |
93 |
metadata => $metadata[$biblionumber], |
| 91 |
}; |
94 |
}; |
|
|
95 |
sleep 2; |
| 92 |
$biblionumber => undef; |
96 |
$biblionumber => undef; |
| 93 |
} (1..10); |
97 |
} (1..10); |
| 94 |
|
98 |
|
|
Lines 130-136
sub test_query {
Link Here
|
| 130 |
$response = XMLin($stdout); |
134 |
$response = XMLin($stdout); |
| 131 |
} |
135 |
} |
| 132 |
|
136 |
|
| 133 |
is_deeply($response, \%full_expected, $test); |
137 |
unless (is_deeply($response, \%full_expected, $test)) { |
|
|
138 |
diag "PARAM:" . Dump($param) . |
| 139 |
"EXPECTED: " . Dump(\%full_expected) . |
| 140 |
"RESPONSE: " . Dump($response); |
| 141 |
} |
| 134 |
} |
142 |
} |
| 135 |
|
143 |
|
| 136 |
|
144 |
|
|
Lines 144-149
test_query('ListMetadataFormats', {verb => 'ListMetadataFormats'}, {
Link Here
|
| 144 |
}, |
152 |
}, |
| 145 |
{ |
153 |
{ |
| 146 |
metadataNamespace => 'http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim', |
154 |
metadataNamespace => 'http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim', |
|
|
155 |
metadataPrefix => 'marc21', |
| 156 |
schema => 'http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd', |
| 157 |
}, |
| 158 |
{ |
| 159 |
metadataNamespace => 'http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim', |
| 147 |
metadataPrefix => 'marcxml', |
160 |
metadataPrefix => 'marcxml', |
| 148 |
schema => 'http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd', |
161 |
schema => 'http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd', |
| 149 |
}, |
162 |
}, |
|
Lines 163-169
test_query('ListIdentifiers', {verb => 'ListIdentifiers', metadataPrefix => 'mar
Link Here
|
| 163 |
ListIdentifiers => { |
176 |
ListIdentifiers => { |
| 164 |
header => [ @header[1..3] ], |
177 |
header => [ @header[1..3] ], |
| 165 |
resumptionToken => { |
178 |
resumptionToken => { |
| 166 |
content => "marcxml/3/1970-01-01T00:00:00Z/$date_to/", |
179 |
content => "marcxml/3/1970-01-01T00:00:00Z/$date_to//0", |
| 167 |
cursor => 3, |
180 |
cursor => 3, |
| 168 |
}, |
181 |
}, |
| 169 |
}, |
182 |
}, |
|
Lines 173-179
test_query('ListIdentifiers', {verb => 'ListIdentifiers', metadataPrefix => 'mar
Link Here
|
| 173 |
ListIdentifiers => { |
186 |
ListIdentifiers => { |
| 174 |
header => [ @header[1..3] ], |
187 |
header => [ @header[1..3] ], |
| 175 |
resumptionToken => { |
188 |
resumptionToken => { |
| 176 |
content => "marcxml/3/1970-01-01T00:00:00Z/$date_to/", |
189 |
content => "marcxml/3/1970-01-01T00:00:00Z/$date_to//0", |
| 177 |
cursor => 3, |
190 |
cursor => 3, |
| 178 |
}, |
191 |
}, |
| 179 |
}, |
192 |
}, |
|
Lines 181-192
test_query('ListIdentifiers', {verb => 'ListIdentifiers', metadataPrefix => 'mar
Link Here
|
| 181 |
|
194 |
|
| 182 |
test_query( |
195 |
test_query( |
| 183 |
'ListIdentifiers with resumptionToken 1', |
196 |
'ListIdentifiers with resumptionToken 1', |
| 184 |
{ verb => 'ListIdentifiers', resumptionToken => "marcxml/3/1970-01-01T00:00:00Z/$date_to/" }, |
197 |
{ verb => 'ListIdentifiers', resumptionToken => "marcxml/3/1970-01-01T00:00:00Z/$date_to//0" }, |
| 185 |
{ |
198 |
{ |
| 186 |
ListIdentifiers => { |
199 |
ListIdentifiers => { |
| 187 |
header => [ @header[4..6] ], |
200 |
header => [ @header[4..6] ], |
| 188 |
resumptionToken => { |
201 |
resumptionToken => { |
| 189 |
content => "marcxml/6/1970-01-01T00:00:00Z/$date_to/", |
202 |
content => "marcxml/6/1970-01-01T00:00:00Z/$date_to//0", |
| 190 |
cursor => 6, |
203 |
cursor => 6, |
| 191 |
}, |
204 |
}, |
| 192 |
}, |
205 |
}, |
|
Lines 196-207
test_query(
Link Here
|
| 196 |
|
209 |
|
| 197 |
test_query( |
210 |
test_query( |
| 198 |
'ListIdentifiers with resumptionToken 2', |
211 |
'ListIdentifiers with resumptionToken 2', |
| 199 |
{ verb => 'ListIdentifiers', resumptionToken => "marcxml/6/1970-01-01T00:00:00Z/$date_to/" }, |
212 |
{ verb => 'ListIdentifiers', resumptionToken => "marcxml/6/1970-01-01T00:00:00Z/$date_to//0" }, |
| 200 |
{ |
213 |
{ |
| 201 |
ListIdentifiers => { |
214 |
ListIdentifiers => { |
| 202 |
header => [ @header[7..9] ], |
215 |
header => [ @header[7..9] ], |
| 203 |
resumptionToken => { |
216 |
resumptionToken => { |
| 204 |
content => "marcxml/9/1970-01-01T00:00:00Z/$date_to/", |
217 |
content => "marcxml/9/1970-01-01T00:00:00Z/$date_to//0", |
| 205 |
cursor => 9, |
218 |
cursor => 9, |
| 206 |
}, |
219 |
}, |
| 207 |
}, |
220 |
}, |
|
Lines 211-217
test_query(
Link Here
|
| 211 |
|
224 |
|
| 212 |
test_query( |
225 |
test_query( |
| 213 |
'ListIdentifiers with resumptionToken 3, response without resumption', |
226 |
'ListIdentifiers with resumptionToken 3, response without resumption', |
| 214 |
{ verb => 'ListIdentifiers', resumptionToken => "marcxml/9/1970-01-01T00:00:00Z/$date_to/" }, |
227 |
{ verb => 'ListIdentifiers', resumptionToken => "marcxml/9/1970-01-01T00:00:00Z/$date_to//0" }, |
| 215 |
{ |
228 |
{ |
| 216 |
ListIdentifiers => { |
229 |
ListIdentifiers => { |
| 217 |
header => $header[10], |
230 |
header => $header[10], |
|
Lines 231-237
test_query('ListRecords', {verb => 'ListRecords', metadataPrefix => 'marcxml'},
Link Here
|
| 231 |
ListRecords => { |
244 |
ListRecords => { |
| 232 |
record => [ @record[1..3] ], |
245 |
record => [ @record[1..3] ], |
| 233 |
resumptionToken => { |
246 |
resumptionToken => { |
| 234 |
content => "marcxml/3/1970-01-01T00:00:00Z/$date_to/", |
247 |
content => "marcxml/3/1970-01-01T00:00:00Z/$date_to//0", |
| 235 |
cursor => 3, |
248 |
cursor => 3, |
| 236 |
}, |
249 |
}, |
| 237 |
}, |
250 |
}, |
|
Lines 239-249
test_query('ListRecords', {verb => 'ListRecords', metadataPrefix => 'marcxml'},
Link Here
|
| 239 |
|
252 |
|
| 240 |
test_query( |
253 |
test_query( |
| 241 |
'ListRecords with resumptionToken 1', |
254 |
'ListRecords with resumptionToken 1', |
| 242 |
{ verb => 'ListRecords', resumptionToken => "marcxml/3/1970-01-01T00:00:00Z/$date_to/" }, |
255 |
{ verb => 'ListRecords', resumptionToken => "marcxml/3/1970-01-01T00:00:00Z/$date_to//0" }, |
| 243 |
{ ListRecords => { |
256 |
{ ListRecords => { |
| 244 |
record => [ @record[4..6] ], |
257 |
record => [ @record[4..6] ], |
| 245 |
resumptionToken => { |
258 |
resumptionToken => { |
| 246 |
content => "marcxml/6/1970-01-01T00:00:00Z/$date_to/", |
259 |
content => "marcxml/6/1970-01-01T00:00:00Z/$date_to//0", |
| 247 |
cursor => 6, |
260 |
cursor => 6, |
| 248 |
}, |
261 |
}, |
| 249 |
}, |
262 |
}, |
|
Lines 251-261
test_query(
Link Here
|
| 251 |
|
264 |
|
| 252 |
test_query( |
265 |
test_query( |
| 253 |
'ListRecords with resumptionToken 2', |
266 |
'ListRecords with resumptionToken 2', |
| 254 |
{ verb => 'ListRecords', resumptionToken => "marcxml/6/1970-01-01T00:00:00Z/$date_to/" }, |
267 |
{ verb => 'ListRecords', resumptionToken => "marcxml/6/1970-01-01T00:00:00Z/$date_to//0" }, |
| 255 |
{ ListRecords => { |
268 |
{ ListRecords => { |
| 256 |
record => [ @record[7..9] ], |
269 |
record => [ @record[7..9] ], |
| 257 |
resumptionToken => { |
270 |
resumptionToken => { |
| 258 |
content => "marcxml/9/1970-01-01T00:00:00Z/$date_to/", |
271 |
content => "marcxml/9/1970-01-01T00:00:00Z/$date_to//0", |
| 259 |
cursor => 9, |
272 |
cursor => 9, |
| 260 |
}, |
273 |
}, |
| 261 |
}, |
274 |
}, |
|
Lines 264-270
test_query(
Link Here
|
| 264 |
# Last record, so no resumption token |
277 |
# Last record, so no resumption token |
| 265 |
test_query( |
278 |
test_query( |
| 266 |
'ListRecords with resumptionToken 3, response without resumption', |
279 |
'ListRecords with resumptionToken 3, response without resumption', |
| 267 |
{ verb => 'ListRecords', resumptionToken => "marcxml/9/1970-01-01T00:00:00Z/$date_to/" }, |
280 |
{ verb => 'ListRecords', resumptionToken => "marcxml/9/1970-01-01T00:00:00Z/$date_to//0" }, |
| 268 |
{ ListRecords => { |
281 |
{ ListRecords => { |
| 269 |
record => $record[10], |
282 |
record => $record[10], |
| 270 |
}, |
283 |
}, |
| 271 |
- |
|
|