]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/t/authority-update-bib-propagation.pg
LP1615805 No inputs after submit in patron search (AngularJS)
[Evergreen.git] / Open-ILS / src / sql / Pg / t / authority-update-bib-propagation.pg
1 BEGIN;
2
3 /* 
4 Started as a test plan for LP#1588948 (authority edits modify bib record
5 editor and edit_date), but includes general tests for confirming authority
6 update propagation to bib records.
7 */
8
9 SELECT plan(9);
10
11 INSERT INTO actor.usr (profile, ident_type, usrname, home_ou, family_name,
12             passwd, first_given_name, expire_date, dob, suffix)
13     VALUES (13, 1, 'TEST_USER', 1, 'TESTER', 'TEST1234', 'TEST',
14             NOW() + '3 years'::INTERVAL, NULL, NULL);
15
16 INSERT INTO authority.record_entry (id, marc, last_xact_id)
17 VALUES (999999100, $$
18 <record    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"    xmlns="http://www.loc.gov/MARC21/slim"><leader>     nz  a22     o  4500</leader><controlfield tag="001">999999100</controlfield><controlfield tag="003">LOCAL</controlfield><controlfield tag="005">20160606150106.0</controlfield><controlfield tag="008">      ||||||||||||||||||||||||||||||||||</controlfield><datafield tag="040" ind1=" " ind2=" "><subfield code="a">LOCAL</subfield><subfield code="c">LOCAL</subfield></datafield><datafield tag="100" ind1=" " ind2=" "><subfield code="a">Doe, Jane</subfield></datafield><datafield tag="901" ind1=" " ind2=" "><subfield code="c">999999100</subfield><subfield code="t">authority</subfield></datafield></record>
19 $$, 'test'
20 );
21
22 INSERT INTO biblio.record_entry (id, editor, edit_date, last_xact_id, marc)
23     VALUES (1234512345, 1, now() - '15 days'::INTERVAL, 'test', $$
24 <record    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"    xmlns="http://www.loc.gov/MARC21/slim"><leader>00620cam a2200205Ka 4500</leader><controlfield tag="001">1234512345</controlfield><controlfield tag="003">LOCAL</controlfield><controlfield tag="005">20160606145837.0</controlfield><controlfield tag="008">070101s                            eng d</controlfield><datafield tag="100" ind1=" " ind2=" "><subfield code="0">(LOCAL)999999100</subfield><subfield code="a">Doe, Jane</subfield></datafield><datafield tag="245" ind1=" " ind2=" "><subfield code="a">Test Record</subfield></datafield><datafield tag="901" ind1=" " ind2=" "><subfield code="a">1234512345</subfield><subfield code="b"></subfield><subfield code="c">1234512345</subfield><subfield code="t">biblio</subfield></datafield></record>
25 $$);
26
27
28 -- modify the authority record to propagate changes
29 UPDATE authority.record_entry SET 
30     editor = CURRVAL('actor.usr_id_seq'), -- test user created above
31     marc = $$
32 <record    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"    xmlns="http://www.loc.gov/MARC21/slim"><leader>     nz  a22     o  4500</leader><controlfield tag="001">999999100</controlfield><controlfield tag="003">LOCAL</controlfield><controlfield tag="005">20160606150106.0</controlfield><controlfield tag="008">      ||||||||||||||||||||||||||||||||||</controlfield><datafield tag="040" ind1=" " ind2=" "><subfield code="a">LOCAL</subfield><subfield code="c">LOCAL</subfield></datafield><datafield tag="100" ind1=" " ind2=" "><subfield code="a">Doe, Jane Smith</subfield></datafield><datafield tag="901" ind1=" " ind2=" "><subfield code="c">999999100</subfield><subfield code="t">authority</subfield></datafield></record>
33 $$
34 WHERE id = 999999100;
35
36 SELECT is(
37     (SELECT value FROM metabib.full_rec 
38         WHERE record = 1234512345 AND tag = '100' and subfield = 'a'),
39     'doe, jane smith',
40     'Authority field change propagated to bib record'
41 );
42
43 SELECT is(
44     (SELECT editor FROM biblio.record_entry WHERE id = 1234512345),
45     CURRVAL('actor.usr_id_seq')::INTEGER,
46     'Bib editor matches authority editor'
47 );
48
49 SELECT is(
50     (SELECT DATE(edit_date) FROM biblio.record_entry WHERE id = 1234512345),
51     CURRENT_DATE,
52     'Bib edit_date is updated'
53 );
54
55 -- Apply a change to the authority record that has no effect on the bib.
56
57 UPDATE biblio.record_entry 
58     SET editor = 1, edit_date = NOW() - '1 week'::INTERVAL
59     WHERE id = 1234512345;
60
61 UPDATE authority.record_entry SET 
62     editor = CURRVAL('actor.usr_id_seq'), -- test user created above
63     marc = $$
64 <record    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"    xmlns="http://www.loc.gov/MARC21/slim"><leader>     nz  a22     o  4500</leader><controlfield tag="001">999999100</controlfield><controlfield tag="003">LOCAL</controlfield><controlfield tag="005">20160606150106.0</controlfield><controlfield tag="008">      ||||||||||||||||||||||||||||||||||</controlfield><datafield tag="040" ind1=" " ind2=" "><subfield code="a">LOCAL</subfield><subfield code="c">LOCAL</subfield></datafield><datafield tag="100" ind1=" " ind2=" "><subfield code="a">Doe, Jane Smith</subfield></datafield><datafield tag="901" ind1=" " ind2=" "><subfield code="c">999999100</subfield><subfield code="t">authority</subfield><subfield code="x">test</subfield></datafield></record>
65 $$
66 WHERE id = 999999100;
67
68 SELECT isnt(
69     (SELECT DATE(edit_date) FROM biblio.record_entry WHERE id = 1234512345),
70     CURRENT_DATE,
71     'Authority change with no effect does not update bib record'
72 );
73
74 -- Reset the bib data for easier testing
75
76 UPDATE biblio.record_entry 
77     SET editor = 1, edit_date = NOW() - '1 week'::INTERVAL 
78     WHERE id = 1234512345;
79
80 SELECT is(
81     (SELECT editor FROM biblio.record_entry WHERE id = 1234512345),
82     1,
83     'Bib editor is reset'
84 );
85
86 SELECT is(
87     (SELECT DATE(edit_date) FROM biblio.record_entry WHERE id = 1234512345),
88     DATE(NOW() - '1 week'::INTERVAL),
89     'Bib edit_date is reset'
90 );
91
92 -- Disable bib edit data propagation by enabled the disable flag
93 UPDATE config.global_flag SET enabled = TRUE
94     WHERE name = 'ingest.disable_authority_auto_update_bib_meta';
95
96 -- modify the authority record to propagate changes
97 UPDATE authority.record_entry SET 
98     editor = CURRVAL('actor.usr_id_seq'), -- test user created above
99     marc = $$
100 <record    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"    xmlns="http://www.loc.gov/MARC21/slim"><leader>     nz  a22     o  4500</leader><controlfield tag="001">999999100</controlfield><controlfield tag="003">LOCAL</controlfield><controlfield tag="005">20160606150106.0</controlfield><controlfield tag="008">      ||||||||||||||||||||||||||||||||||</controlfield><datafield tag="040" ind1=" " ind2=" "><subfield code="a">LOCAL</subfield><subfield code="c">LOCAL</subfield></datafield><datafield tag="100" ind1=" " ind2=" "><subfield code="a">Doe, Jane Double-Smith</subfield></datafield><datafield tag="901" ind1=" " ind2=" "><subfield code="c">999999100</subfield><subfield code="t">authority</subfield></datafield></record>
101 $$
102 WHERE id = 999999100;
103
104 SELECT is(
105     (SELECT value FROM metabib.full_rec 
106         WHERE record = 1234512345 AND tag = '100' and subfield = 'a'),
107     'doe, jane double smith',
108     'Authority field change propagated to bib record'
109 );
110
111 SELECT isnt(
112     (SELECT editor FROM biblio.record_entry WHERE id = 1234512345),
113     CURRVAL('actor.usr_id_seq')::INTEGER,
114     'Bib editor does not match authority editor'
115 );
116
117 SELECT isnt(
118     (SELECT DATE(edit_date) FROM biblio.record_entry WHERE id = 1234512345),
119     CURRENT_DATE,
120     'Bib edit_date is not updated'
121 );
122
123 ROLLBACK;
124