From 8ab630642cf7331a3cbb3d216f376ff837e7ed52 Mon Sep 17 00:00:00 2001 From: Kathy Lussier Date: Mon, 23 May 2016 19:17:36 -0400 Subject: [PATCH] LP#1447746: Fix lp957466_update_date_and_source regression test The new code introduced through LP1447746 adding an update_bib_source flag to Vandelay merge profiles broke a test that was verifying the bib source and edit fields were updated in Vandelay uploads. This patch fixes the test and also adds a new test to ensure the flag works as expected when set to both true and false. It also renames the test since the it's now testing the newer code rather than the previous expected behavior. Signed-off-by: Kathy Lussier Signed-off-by: Ben Shum --- .../lp1447746_update_date_and_source.pg | 137 ++++++++++++++++++ .../lp957466_update_date_and_source.pg | 80 ---------- 2 files changed, 137 insertions(+), 80 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/t/regress/lp1447746_update_date_and_source.pg delete mode 100644 Open-ILS/src/sql/Pg/t/regress/lp957466_update_date_and_source.pg diff --git a/Open-ILS/src/sql/Pg/t/regress/lp1447746_update_date_and_source.pg b/Open-ILS/src/sql/Pg/t/regress/lp1447746_update_date_and_source.pg new file mode 100644 index 0000000000..7ffeb3ce25 --- /dev/null +++ b/Open-ILS/src/sql/Pg/t/regress/lp1447746_update_date_and_source.pg @@ -0,0 +1,137 @@ +BEGIN; + +SELECT plan(8); + +------------------------- +-- Setup test environment +-- User w/ library card +-- Vandelay settings (merge profile, queue) +-- "Pre-loaded" bib record to be overlayed +-- Matching bib 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, update_bib_source) + VALUES (1, 'TEST', '901c', TRUE); + +--XXX: Do we need to create a custom item_attr_def? +-- If def 1 was deleted from an install, this will break +INSERT INTO vandelay.bib_queue (owner, name, item_attr_def) + VALUES (CURRVAL('actor.usr_id_seq'), 'TEST', 1); + +INSERT INTO biblio.record_entry (id, edit_date, last_xact_id, marc) + VALUES (1234512345, now() - '15 days'::INTERVAL, 'TEST', + '00374nam a22001212 4500A101401-214316420140506000000.09780199588480 (Trade Paper)USD 11.95 ListHaigh, JohnAuthorProbabilityOxford University Press, Incorporated2012-05-04144 p.16..84 l. X 11..63 w. in.biblio'); + +INSERT INTO vandelay.queued_bib_record (queue, bib_source, purpose, marc) + SELECT CURRVAL('vandelay.queue_id_seq'), 2, 'overlay', + '00374nam a22001212 4500A101401-214316420140506000000.09780199588480 (Trade Paper)USD 11.95 ListHaigh, JohnAuthorProbabilityOxford University Press, Incorporated2012-05-04144 p.16..84 l. X 11..63 w. in.biblio1234512345' + || barcode || '' + FROM actor.card + WHERE id = CURRVAL('actor.card_id_seq'); + +----------------------- +-- Import the record -- +----------------------- +SELECT ok( + ( + SELECT vandelay.overlay_bib_record( queued_record, eg_record, + CURRVAL('vandelay.merge_profile_id_seq')::int ) + FROM vandelay.bib_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 biblio.record_entry ORDER BY id DESC LIMIT 1), + CURRVAL('actor.usr_id_seq'), + 'Editor was updated' +); + +SELECT is( + (SELECT edit_date::date FROM biblio.record_entry ORDER BY id DESC LIMIT 1), + CURRENT_DATE, + 'Edit Date was updated' +); + +SELECT is( + (SELECT source FROM biblio.record_entry ORDER BY id DESC LIMIT 1), + 2, + 'Record source was updated' +); + +-------------------------------- +-- Set up test to verify a false +-- update_bib_source flag will +-- not update editor, edit date +-- and source +-------------------------------- + +UPDATE vandelay.merge_profile + SET update_bib_source = FALSE + WHERE name = 'TEST'; + +INSERT INTO biblio.record_entry (id, source, edit_date, last_xact_id, marc) + VALUES (9876598764, 1, now() - '15 days'::INTERVAL, 'TEST', + '01047cam a22003498a 4500339CONS20090505140900.0001129s2001 ctu c 001 0 eng 00065571 0761322507 (lib. bdg.)(MAnMC)807579(OCoLC)ocm45661816DLCDLCDPLMRQUtOrBLWpcclcacMRQA523.421JFarndon, JohnPlanets and their moons /John Farndon.Brookfield, CT :Copper Beech Books,c2001.32 p. :col. ill. ;27 cm.biblio'); + +INSERT INTO vandelay.queued_bib_record (queue, bib_source, purpose, marc) + SELECT CURRVAL('vandelay.queue_id_seq'), 2, 'overlay', + '01047cam a22003498a 4500339CONS20090505140900.0001129s2001 ctu c 001 0 eng 00065571 0761322507 (lib. bdg.)(MAnMC)807579(OCoLC)ocm45661816DLCDLCDPLMRQUtOrBLWpcclcacMRQA523.421JFarndon, JohnPlanets and their moons /John Farndon.Brookfield, CT :Copper Beech Books,c2001.32 p. :col. ill. ;27 cm.biblio9876598764' + || barcode || '' + FROM actor.card + WHERE id = CURRVAL('actor.card_id_seq'); + +------------------------ +-- Import the new record +------------------------ +SELECT ok( + ( + SELECT vandelay.overlay_bib_record( queued_record, eg_record, + CURRVAL('vandelay.merge_profile_id_seq')::int ) + FROM vandelay.bib_match + WHERE queued_record = CURRVAL('vandelay.queued_record_id_seq') + ), + 'Function call succeeded' +); + +------------------------------------ +-- Test for no new values of editor, +-- edit date, and source +------------------------------------ +SELECT isnt( + (SELECT editor::bigint FROM biblio.record_entry ORDER BY id DESC LIMIT 1), + CURRVAL('actor.usr_id_seq'), + 'Editor was not updated' +); + +SELECT isnt( + (SELECT edit_date::date FROM biblio.record_entry ORDER BY id DESC LIMIT 1), + CURRENT_DATE, + 'Edit Date was not updated' +); + +SELECT isnt( + (SELECT source FROM biblio.record_entry ORDER BY id DESC LIMIT 1), + 2, + 'Record source was not updated' +); + +ROLLBACK; diff --git a/Open-ILS/src/sql/Pg/t/regress/lp957466_update_date_and_source.pg b/Open-ILS/src/sql/Pg/t/regress/lp957466_update_date_and_source.pg deleted file mode 100644 index 969c31bb86..0000000000 --- a/Open-ILS/src/sql/Pg/t/regress/lp957466_update_date_and_source.pg +++ /dev/null @@ -1,80 +0,0 @@ -BEGIN; - -SELECT plan(4); - -------------------------- --- Setup test environment --- User w/ library card --- Vandelay settings (merge profile, queue) --- "Pre-loaded" bib record to be overlayed --- Matching bib 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'); - ---XXX: Do we need to create a custom item_attr_def? --- If def 1 was deleted from an install, this will break -INSERT INTO vandelay.bib_queue (owner, name, item_attr_def) - VALUES (CURRVAL('actor.usr_id_seq'), 'TEST', 1); - -INSERT INTO biblio.record_entry (id, edit_date, last_xact_id, marc) - VALUES (1234512345, now() - '15 days'::INTERVAL, 'TEST', - '00374nam a22001212 4500A101401-214316420140506000000.09780199588480 (Trade Paper)USD 11.95 ListHaigh, JohnAuthorProbabilityOxford University Press, Incorporated2012-05-04144 p.16..84 l. X 11..63 w. in.biblio'); - -INSERT INTO vandelay.queued_bib_record (queue, bib_source, purpose, marc) - SELECT CURRVAL('vandelay.queue_id_seq'), 2, 'overlay', - '00374nam a22001212 4500A101401-214316420140506000000.09780199588480 (Trade Paper)USD 11.95 ListHaigh, JohnAuthorProbabilityOxford University Press, Incorporated2012-05-04144 p.16..84 l. X 11..63 w. in.biblio1234512345' - || barcode || '' - FROM actor.card - WHERE id = CURRVAL('actor.card_id_seq'); - ------------------------ --- Import the record -- ------------------------ -SELECT ok( - ( - SELECT vandelay.overlay_bib_record( queued_record, eg_record, - CURRVAL('vandelay.merge_profile_id_seq')::int ) - FROM vandelay.bib_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 biblio.record_entry ORDER BY id DESC LIMIT 1), - CURRVAL('actor.usr_id_seq'), - 'Editor was updated' -); - -SELECT is( - (SELECT edit_date::date FROM biblio.record_entry ORDER BY id DESC LIMIT 1), - CURRENT_DATE, - 'Edit Date was updated' -); - -SELECT is( - (SELECT source FROM biblio.record_entry ORDER BY id DESC LIMIT 1), - 2, - 'Record source was updated' -); - -ROLLBACK; -- 2.43.2