|
Lines 18-24
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::More tests => 5; |
21 |
use Test::More tests => 9; |
| 22 |
use Test::Exception; |
22 |
use Test::Exception; |
| 23 |
|
23 |
|
| 24 |
use t::lib::TestBuilder; |
24 |
use t::lib::TestBuilder; |
|
Lines 53-65
my $record =
Link Here
|
| 53 |
'<metadata xmlns="http://www.openarchives.org/OAI/2.0/"><oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd"><dc:title>Pièces diverses </dc:title><dc:identifier>ARCH/0320 [cote]</dc:identifier><dc:relation>FR-920509801 [RCR établissement]</dc:relation><dc:relation>Central obrera boliviana [Fonds ou collection]</dc:relation><dc:format>1 carton</dc:format><dc:date>1971/2000</dc:date><dc:type>Archives et manuscrits</dc:type></oai_dc:dc></metadata>'; |
53 |
'<metadata xmlns="http://www.openarchives.org/OAI/2.0/"><oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd"><dc:title>Pièces diverses </dc:title><dc:identifier>ARCH/0320 [cote]</dc:identifier><dc:relation>FR-920509801 [RCR établissement]</dc:relation><dc:relation>Central obrera boliviana [Fonds ou collection]</dc:relation><dc:format>1 carton</dc:format><dc:date>1971/2000</dc:date><dc:type>Archives et manuscrits</dc:type></oai_dc:dc></metadata>'; |
| 54 |
|
54 |
|
| 55 |
my $r = HTTP::OAI::Record->new(); |
55 |
my $r = HTTP::OAI::Record->new(); |
| 56 |
$r->header->datestamp('2017-05-10T09:18:13Z'); |
|
|
| 57 |
$r->metadata( HTTP::OAI::Metadata->new( dom => $record ) ); |
56 |
$r->metadata( HTTP::OAI::Metadata->new( dom => $record ) ); |
| 58 |
|
57 |
|
| 59 |
my $status = $harvester->processRecord($r); |
58 |
my $status = $harvester->processRecord($r); |
| 60 |
is( $status, 'skipped', 'Record with no identifier is skipped' ); |
59 |
is( $status, 'skipped', 'Record with no identifier is skipped' ); |
| 61 |
|
60 |
|
| 62 |
$r->header->identifier('oai:myarchive.org:oid-233'); |
61 |
$r->header->identifier('oai:myarchive.org:oid-233'); |
|
|
62 |
$status = $harvester->processRecord($r); |
| 63 |
is( $status, 'added', 'Record with no date is added' ); |
| 64 |
|
| 65 |
$status = $harvester->processRecord($r); |
| 66 |
is( $status, 'updated', 'Record with no date is updated' ); |
| 67 |
|
| 68 |
$status = $harvester->processRecord($r); |
| 69 |
is( $status, 'updated', 'Record with no date is updated even without force' ); |
| 70 |
|
| 71 |
$r->header->identifier('oai:myarchive.org:oid-234'); |
| 72 |
$r->header->datestamp('2017-05-10T09:18:13Z'); |
| 63 |
|
73 |
|
| 64 |
$status = $harvester->processRecord($r); |
74 |
$status = $harvester->processRecord($r); |
| 65 |
is( $status, 'added', 'Record is added' ); |
75 |
is( $status, 'added', 'Record is added' ); |
|
Lines 75-78
$r->header->datestamp('2018-05-10T09:18:13Z');
Link Here
|
| 75 |
$status = $harvester->processRecord($r); |
85 |
$status = $harvester->processRecord($r); |
| 76 |
is( $status, 'updated', 'When force is not used, record is updated if newer' ); |
86 |
is( $status, 'updated', 'When force is not used, record is updated if newer' ); |
| 77 |
|
87 |
|
|
|
88 |
my $imported_record = Koha::Import::Oaipmh::Biblios->find( { identifier => 'oai:myarchive.org:oid-234' } ); |
| 89 |
my $added_datestamp = $imported_record->datestamp; |
| 90 |
$r->header->datestamp(undef); |
| 91 |
$status = $harvester->processRecord($r); |
| 92 |
$imported_record = Koha::Import::Oaipmh::Biblios->find( { identifier => 'oai:myarchive.org:oid-234' } ); |
| 93 |
my $updated_datestamp = $imported_record->datestamp; |
| 94 |
isnt( |
| 95 |
$added_datestamp, $updated_datestamp, |
| 96 |
'local datestamp is updated even if there is no datestamp in incoming record' |
| 97 |
); |
| 98 |
|
| 78 |
$schema->storage->txn_rollback; |
99 |
$schema->storage->txn_rollback; |
| 79 |
- |
|
|