From: Bill Erickson Date: Wed, 1 Jun 2016 15:51:00 +0000 (-0400) Subject: LP#1587639 Vand. authority updates PGTAP X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=720cb4391ec0149632fbaf9687edf58a4a1d1142;p=evergreen%2Fpines.git LP#1587639 Vand. authority updates PGTAP Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/src/sql/Pg/t/vandelay-auth-import.sql b/Open-ILS/src/sql/Pg/t/vandelay-auth-import.sql new file mode 100644 index 0000000000..1b11dee3ff --- /dev/null +++ b/Open-ILS/src/sql/Pg/t/vandelay-auth-import.sql @@ -0,0 +1,73 @@ +BEGIN; + +SELECT plan(3); + +------------------------- +-- Setup test environment +-- User w/ library card +-- Vandelay settings (merge profile, queue) +-- "Pre-loaded" authority record to be overlayed +-- Matching authority record added to Vandelay queue +-- including 905u with user barcode +------------------------- + +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 actor.card (barcode, usr) + VALUES ('TEST_BARCODE', CURRVAL('actor.usr_id_seq')); + +UPDATE actor.usr + SET card = CURRVAL('actor.card_id_seq') + WHERE id = CURRVAL('actor.usr_id_seq'); + +INSERT INTO vandelay.merge_profile + (owner, name, preserve_spec) VALUES (1, 'TEST', '901c'); + +INSERT INTO vandelay.authority_queue (owner, name) + VALUES (CURRVAL('actor.usr_id_seq'), 'TEST'); + +INSERT INTO authority.record_entry (id, edit_date, last_xact_id, marc) + VALUES (1234512345, now() - '15 days'::INTERVAL, 'TEST', + '00208nz a2200097o 45 073CONS20021207110052.0021207n| acannaabn |n aac d(IISG)IISGa11554924IISGIISGMaloy, Eileenauthority'); + +INSERT INTO vandelay.queued_authority_record (queue, purpose, marc) + SELECT CURRVAL('vandelay.queue_id_seq'), 'overlay', + '00208nz a2200097o 45 073CONS20021207110052.0021207n| acannaabn |n aac d(IISG)IISGa11554924IISGIISGMaloy, Eileen1234512345authority' + || barcode || '' + FROM actor.card + WHERE id = CURRVAL('actor.card_id_seq'); + +----------------------- +-- Import the record -- +----------------------- +SELECT ok( + ( + SELECT vandelay.overlay_authority_record(queued_record, eg_record, + CURRVAL('vandelay.merge_profile_id_seq')::int ) + FROM vandelay.authority_match + WHERE queued_record = CURRVAL('vandelay.queued_record_id_seq') + ), + 'Function call succeeded' +); + +--------------------------------- +-- Test for new values of editor, +-- edit date, and source +--------------------------------- +SELECT is( + (SELECT editor::bigint FROM authority.record_entry ORDER BY id DESC LIMIT 1), + CURRVAL('actor.usr_id_seq'), + 'Editor was updated' +); + +SELECT is( + (SELECT edit_date::date FROM authority.record_entry ORDER BY id DESC LIMIT 1), + CURRENT_DATE, + 'Edit Date was updated' +); + +ROLLBACK; +