From 7605ed8a65a2151e42a3e8c20cd8640f81fab962 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 6 Jun 2016 11:14:47 -0400 Subject: [PATCH] LP#1588948 Authority propagation PGTAP test Adds a new general purpose authority->bib propagation pgtap test, covering basic propagation and editor / edit_date propagation. Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- .../sql/Pg/t/authority-update-bib-propagation.pg | 105 +++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 Open-ILS/src/sql/Pg/t/authority-update-bib-propagation.pg diff --git a/Open-ILS/src/sql/Pg/t/authority-update-bib-propagation.pg b/Open-ILS/src/sql/Pg/t/authority-update-bib-propagation.pg new file mode 100644 index 0000000000..4dd5e1506a --- /dev/null +++ b/Open-ILS/src/sql/Pg/t/authority-update-bib-propagation.pg @@ -0,0 +1,105 @@ +BEGIN; + +/* +Started as a test plan for LP#1588948 (authority edits modify bib record +editor and edit_date), but includes general tests for confirming authority +update propagation to bib records. +*/ + +SELECT plan(8); + +INSERT INTO actor.usr (profile, ident_type, usrname, home_ou, family_name, + passwd, first_given_name, expire_date, dob, suffix) + VALUES (13, 1, 'TEST_USER', 1, 'TESTER', 'TEST1234', 'TEST', + NOW() + '3 years'::INTERVAL, NULL, NULL); + +INSERT INTO authority.record_entry (id, marc, last_xact_id) +VALUES (999999100, $$ + nz a22 o 4500999999100LOCAL20160606150106.0 ||||||||||||||||||||||||||||||||||LOCALLOCALDoe, Jane999999100authority +$$, 'test' +); + +INSERT INTO biblio.record_entry (id, editor, edit_date, last_xact_id, marc) + VALUES (1234512345, 1, now() - '15 days'::INTERVAL, 'test', $$ +00620cam a2200205Ka 45001234512345LOCAL20160606145837.0070101s eng d(LOCAL)999999100Doe, JaneTest Record12345123451234512345biblio +$$); + + +-- modify the authority record to propagate changes +UPDATE authority.record_entry SET + editor = CURRVAL('actor.usr_id_seq'), -- test user created above + marc = $$ + nz a22 o 4500999999100LOCAL20160606150106.0 ||||||||||||||||||||||||||||||||||LOCALLOCALDoe, Jane Smith999999100authority +$$ +WHERE id = 999999100; + +SELECT is( + (SELECT value FROM metabib.full_rec + WHERE record = 1234512345 AND tag = '100' and subfield = 'a'), + 'doe, jane smith', + 'Authority field change propagated to bib record' +); + +SELECT is( + (SELECT editor FROM biblio.record_entry WHERE id = 1234512345), + CURRVAL('actor.usr_id_seq')::INTEGER, + 'Bib editor matches authority editor' +); + +SELECT is( + (SELECT DATE(edit_date) FROM biblio.record_entry WHERE id = 1234512345), + CURRENT_DATE, + 'Bib edit_date is updated' +); + +-- Reset the bib data for easier testing + +UPDATE biblio.record_entry + SET editor = 1, edit_date = NOW() - '1 week'::INTERVAL + WHERE id = 1234512345; + +SELECT is( + (SELECT editor FROM biblio.record_entry WHERE id = 1234512345), + 1, + 'Bib editor is reset' +); + +SELECT is( + (SELECT DATE(edit_date) FROM biblio.record_entry WHERE id = 1234512345), + DATE(NOW() - '1 week'::INTERVAL), + 'Bib edit_date is reset' +); + +-- Disable bib edit data propagation by enabled the disable flag +UPDATE config.global_flag SET enabled = TRUE + WHERE name = 'ingest.disable_authority_auto_update_bib_meta'; + +-- modify the authority record to propagate changes +UPDATE authority.record_entry SET + editor = CURRVAL('actor.usr_id_seq'), -- test user created above + marc = $$ + nz a22 o 4500999999100LOCAL20160606150106.0 ||||||||||||||||||||||||||||||||||LOCALLOCALDoe, Jane Double-Smith999999100authority +$$ +WHERE id = 999999100; + +SELECT is( + (SELECT value FROM metabib.full_rec + WHERE record = 1234512345 AND tag = '100' and subfield = 'a'), + 'doe, jane double smith', + 'Authority field change propagated to bib record' +); + +SELECT isnt( + (SELECT editor FROM biblio.record_entry WHERE id = 1234512345), + CURRVAL('actor.usr_id_seq')::INTEGER, + 'Bib editor does not match authority editor' +); + +SELECT isnt( + (SELECT DATE(edit_date) FROM biblio.record_entry WHERE id = 1234512345), + CURRENT_DATE, + 'Bib edit_date is not updated' +); + +ROLLBACK; + -- 2.11.0