]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/sql/Pg/t/vandelay-auth-import.sql
LP1773452: Repeating copy alerts
[working/Evergreen.git] / Open-ILS / src / sql / Pg / t / vandelay-auth-import.sql
1 BEGIN;
2
3 SELECT plan(3);
4
5 -------------------------
6 -- Setup test environment
7 --   User w/ library card
8 --   Vandelay settings (merge profile, queue)
9 --   "Pre-loaded" authority record to be overlayed
10 --   Matching authority record added to Vandelay queue
11 --     including 905u with user barcode
12 -------------------------
13
14 INSERT INTO actor.usr (profile, ident_type, usrname, home_ou, family_name,
15             passwd, first_given_name, expire_date, dob, suffix)
16     VALUES (13, 1, 'TEST_USER', 1, 'TESTER', 'TEST1234', 'TEST',
17             NOW() + '3 years'::INTERVAL, NULL, NULL);
18
19 INSERT INTO actor.card (barcode, usr)
20     VALUES ('TEST_BARCODE', CURRVAL('actor.usr_id_seq'));
21
22 UPDATE actor.usr
23     SET card = CURRVAL('actor.card_id_seq')
24     WHERE id = CURRVAL('actor.usr_id_seq');
25
26 INSERT INTO vandelay.merge_profile 
27     (owner, name, preserve_spec) VALUES (1, 'TEST', '901c');
28
29 INSERT INTO vandelay.authority_queue (owner, name)
30     VALUES (CURRVAL('actor.usr_id_seq'), 'TEST');
31
32 INSERT INTO authority.record_entry (id, edit_date, last_xact_id, marc)
33     VALUES (1234512345, now() - '15 days'::INTERVAL, 'TEST',
34    '<record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.loc.gov/MARC21/slim" xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"><leader>00208nz  a2200097o  45 0</leader><controlfield tag="001">73</controlfield><controlfield tag="003">CONS</controlfield><controlfield tag="005">20021207110052.0</controlfield><controlfield tag="008">021207n| acannaabn          |n aac     d</controlfield><datafield tag="035" ind1=" " ind2=" "><subfield code="a">(IISG)IISGa11554924</subfield></datafield><datafield tag="040" ind1=" " ind2=" "><subfield code="a">IISG</subfield><subfield code="c">IISG</subfield></datafield><datafield tag="100" ind1="0" ind2=" "><subfield code="a">Maloy, Eileen</subfield></datafield><datafield tag="901" ind1=" " ind2=" "><subfield code="t">authority</subfield></datafield></record>');
35
36 INSERT INTO vandelay.queued_authority_record (queue, purpose, marc)
37     SELECT CURRVAL('vandelay.queue_id_seq'), 'overlay',
38     '<record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.loc.gov/MARC21/slim" xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"><leader>00208nz  a2200097o  45 0</leader><controlfield tag="001">73</controlfield><controlfield tag="003">CONS</controlfield><controlfield tag="005">20021207110052.0</controlfield><controlfield tag="008">021207n| acannaabn          |n aac     d</controlfield><datafield tag="035" ind1=" " ind2=" "><subfield code="a">(IISG)IISGa11554924</subfield></datafield><datafield tag="040" ind1=" " ind2=" "><subfield code="a">IISG</subfield><subfield code="c">IISG</subfield></datafield><datafield tag="100" ind1="0" ind2=" "><subfield code="a">Maloy, Eileen</subfield></datafield><datafield tag="901" ind1=" " ind2=" "><subfield code="c">1234512345</subfield><subfield code="t">authority</subfield></datafield><datafield tag="905" ind1=" " ind2=" "><subfield code="u">' 
39         || barcode || '</subfield></datafield></record>'
40     FROM actor.card
41     WHERE id = CURRVAL('actor.card_id_seq');
42
43 -----------------------
44 -- Import the record --
45 -----------------------
46 SELECT ok(
47     (
48         SELECT vandelay.overlay_authority_record(queued_record, eg_record,
49             CURRVAL('vandelay.merge_profile_id_seq')::int )
50         FROM vandelay.authority_match
51         WHERE queued_record = CURRVAL('vandelay.queued_record_id_seq')
52     ),
53     'Function call succeeded'
54 );
55
56 ---------------------------------
57 -- Test for new values of editor,
58 -- edit date, and source
59 ---------------------------------
60 SELECT is(
61     (SELECT editor::bigint FROM authority.record_entry ORDER BY id DESC LIMIT 1),
62     CURRVAL('actor.usr_id_seq'),
63     'Editor was updated'
64 );
65
66 SELECT is(
67     (SELECT edit_date::date FROM authority.record_entry ORDER BY id DESC LIMIT 1),
68     CURRENT_DATE,
69     'Edit Date was updated'
70 );
71
72 ROLLBACK;
73