3 use Test::More tests => 6;
5 diag("Fetches and updates a bib records MARC data");
7 use strict; use warnings;
11 use MARC::File::XML (BinaryEncoding => 'UTF-8');
12 use OpenILS::Utils::TestUtils;
13 use OpenILS::Utils::Normalize qw/clean_marc/;
14 my $script = OpenILS::Utils::TestUtils->new();
17 my $test_title = 'La canzone italiana del Novecento :';
18 my $test_note = "Live Test Note";
20 # we need auth to access protected APIs
21 $script->authenticate({
23 password => 'demo123',
26 my $authtoken = $script->authtoken;
27 ok($authtoken, 'Have an authtoken');
29 my $ses = $script->session('open-ils.cstore');
30 my $req = $ses->request(
31 'open-ils.cstore.direct.biblio.record_entry.retrieve',
35 if (my $resp = $req->recv) {
36 if ($bre = $resp->content) {
39 'Fieldmapper::biblio::record_entry',
40 'open-ils.cstore.direct.biblio.record_entry.retrieve '.
41 'returned a bre object'
46 my $marc = MARC::Record->new_from_xml($bre->marc);
48 $marc->subfield('245', 'a'),
50 'subfield(245, a) returned expected value'
53 my $field = MARC::Field->new('999','','','a' => $test_note);
54 $marc->append_fields($field);
57 $marc->subfield('999', 'a'),
59 'subfield(999, a) has correct note'
62 $req = $script->session('open-ils.cat')->request(
63 'open-ils.cat.biblio.record.xml.update',
64 $authtoken, $bre->id, clean_marc($marc->as_xml));
66 if (my $resp = $req->recv) {
67 if ($bre = $resp->content) {
70 'Fieldmapper::biblio::record_entry',
71 'open-ils.cat.biblio.record.xml.update returned a bre object'
74 my $marc = MARC::Record->new_from_xml($bre->marc);
77 $marc->subfield('999', 'a'),
79 'Updated MARC subfield(999, a) has correct note'