add src/Pg/live_t/
[working/Evergreen.git] / Open-ILS / src / sql / Pg / live_t / 0824.item_import_defaults.pg
1 \set ECHO
2 \set QUIET 1
3 -- Turn off echo and keep things quiet.
4
5 -- Format the output for nice TAP.
6 \pset format unaligned
7 \pset tuples_only true
8 \pset pager
9
10 -- Revert all changes on failure.
11 \set ON_ERROR_ROLLBACK 1
12 \set ON_ERROR_STOP true
13 \set QUIET 1
14
15 -- let's do this thing
16 BEGIN;
17
18 SELECT plan(2);
19
20 INSERT INTO actor.org_unit_setting (org_unit,name,value) VALUES
21 (4,'vandelay.item.barcode.auto','true'),
22 (4,'vandelay.item.circ_modifier.default','"BOOK"'),
23 (4,'vandelay.item.call_number.auto','true');
24
25 INSERT INTO vandelay.bib_queue (owner,name,item_attr_def)
26 VALUES (
27     1,
28     'tmp test queue '||RANDOM(),
29     (SELECT id FROM vandelay.import_item_attr_definition WHERE name = 'Evergreen 852 export format') -- Hope the schema is stock...
30 );
31
32 INSERT INTO vandelay.queued_bib_record (marc,queue)
33 VALUES (
34     $$<record xmlns="http://www.loc.gov/MARC21/slim">
35 <leader>00663ncm a2200229Ia 4500</leader>
36 <controlfield tag="001">ocm20612671</controlfield><controlfield tag="005">20090604115400.0</controlfield>
37 <controlfield tag="008">891108s1989    mnupp    i     n    eng d</controlfield>
38 <datafield ind1=" " ind2=" " tag="020"><subfield code="z">HL00361126 :</subfield><subfield code="c">$14.95</subfield></datafield>
39 <datafield ind1=" " ind2=" " tag="040"><subfield code="a">TUL</subfield><subfield code="c">TUL</subfield><subfield code="d">UtOrBLW</subfield></datafield>
40 <datafield ind1=" " ind2=" " tag="049"><subfield code="a">MRQA</subfield></datafield>
41 <datafield ind1=" " ind2=" " tag="092"><subfield code="a">782.421630264</subfield><subfield code="b">S6986 1989</subfield></datafield>
42 <datafield ind1="0" ind2="0" tag="245"><subfield code="a">Songs of the 60's :</subfield><subfield code="b">piano, vocal, guitar.</subfield></datafield>
43 <datafield ind1=" " ind2=" " tag="260"><subfield code="a">Winona, MN :</subfield><subfield code="b">H. Leonard,</subfield><subfield code="c">c1989.</subfield></datafield>
44 <datafield ind1=" " ind2=" " tag="300"><subfield code="a">1 score (175 p.) :</subfield><subfield code="b">ill. ;</subfield><subfield code="c">31 cm.</subfield></datafield>
45 <datafield ind1=" " ind2="4" tag="440"><subfield code="a">Decade series</subfield></datafield>
46 <datafield ind1=" " ind2=" " tag="500"><subfield code="a">With a preface by Stanley Green.</subfield></datafield>
47 <datafield ind1=" " ind2="0" tag="650"><subfield code="a">Popular music</subfield><subfield code="y">1961-1970</subfield></datafield>
48 <datafield ind1="0" ind2=" " tag="740"><subfield code="a">Songs of the sixties.</subfield></datafield>
49 <datafield ind1=" " ind2=" " tag="830"><subfield code="a">DE (Series)</subfield></datafield>
50 <datafield tag="852" ind1="4" ind2=" "><subfield code="c">Stacks</subfield><subfield code="b">BR1</subfield><subfield code="j">CN-label</subfield><subfield code="b">BR1</subfield><subfield code="p">BC1234567890</subfield><subfield code="z">Available</subfield></datafield><!-- full from Z -->
51 <datafield ind1="0" ind2="0" tag="913"><subfield code="a">*SOT60S99000</subfield></datafield>
52 </record>$$,
53     CURRVAL('vandelay.queue_id_seq')
54 );
55
56 /*
57 SELECT * FROM vandelay.ingest_items(
58     CURRVAL('vandelay.queued_record_id_seq'),
59     (SELECT item_attr_def FROM vandelay.bib_queue WHERE id = CURRVAL('vandelay.queue_id_seq'))
60 );
61 */
62
63 SELECT isnt_empty(
64     $$SELECT * FROM vandelay.ingest_items(
65         CURRVAL('vandelay.queued_record_id_seq'),
66         (SELECT item_attr_def FROM vandelay.bib_queue WHERE id = CURRVAL('vandelay.queue_id_seq'))
67     ) WHERE circ_modifier = 'BOOK' AND barcode = 'BC1234567890';$$,
68     'Should have a row with barcode BC1234567890 and auto-circ mod of BOOK'
69 );
70
71
72 INSERT INTO vandelay.queued_bib_record (marc,queue)
73 VALUES (
74     $$<record xmlns="http://www.loc.gov/MARC21/slim">
75 <leader>00663ncm a2200229Ia 4500</leader>
76 <controlfield tag="001">ocm20612671</controlfield><controlfield tag="005">20090604115400.0</controlfield>
77 <controlfield tag="008">891108s1989    mnupp    i     n    eng d</controlfield>
78 <datafield ind1=" " ind2=" " tag="020"><subfield code="z">HL00361126 :</subfield><subfield code="c">$14.95</subfield></datafield>
79 <datafield ind1=" " ind2=" " tag="040"><subfield code="a">TUL</subfield><subfield code="c">TUL</subfield><subfield code="d">UtOrBLW</subfield></datafield>
80 <datafield ind1=" " ind2=" " tag="049"><subfield code="a">MRQA</subfield></datafield>
81 <datafield ind1=" " ind2=" " tag="092"><subfield code="a">782.421630264</subfield><subfield code="b">S6986 1989</subfield></datafield>
82 <datafield ind1="0" ind2="0" tag="245"><subfield code="a">Songs of the 60's :</subfield><subfield code="b">piano, vocal, guitar.</subfield></datafield>
83 <datafield ind1=" " ind2=" " tag="260"><subfield code="a">Winona, MN :</subfield><subfield code="b">H. Leonard,</subfield><subfield code="c">c1989.</subfield></datafield>
84 <datafield ind1=" " ind2=" " tag="300"><subfield code="a">1 score (175 p.) :</subfield><subfield code="b">ill. ;</subfield><subfield code="c">31 cm.</subfield></datafield>
85 <datafield ind1=" " ind2="4" tag="440"><subfield code="a">Decade series</subfield></datafield>
86 <datafield ind1=" " ind2=" " tag="500"><subfield code="a">With a preface by Stanley Green.</subfield></datafield>
87 <datafield ind1=" " ind2="0" tag="650"><subfield code="a">Popular music</subfield><subfield code="y">1961-1970</subfield></datafield>
88 <datafield ind1="0" ind2=" " tag="740"><subfield code="a">Songs of the sixties.</subfield></datafield>
89 <datafield ind1=" " ind2=" " tag="830"><subfield code="a">DE (Series)</subfield></datafield>
90 <datafield tag="852" ind1="4" ind2=" "><subfield code="c">Stacks</subfield><subfield code="b">BR1</subfield><subfield code="b">BR1</subfield><subfield code="z">Available</subfield></datafield><!-- missing barcode and call number -->
91 <datafield ind1="0" ind2="0" tag="913"><subfield code="a">*SOT60S99000</subfield></datafield>
92 </record>$$,
93     CURRVAL('vandelay.queue_id_seq')
94 );
95
96 /*
97 SELECT * FROM vandelay.ingest_items(
98     CURRVAL('vandelay.queued_record_id_seq'),
99     (SELECT item_attr_def FROM vandelay.bib_queue WHERE id = CURRVAL('vandelay.queue_id_seq'))
100 );
101 */
102
103 SELECT isnt_empty(
104     $$SELECT * FROM vandelay.ingest_items(
105         CURRVAL('vandelay.queued_record_id_seq'),
106         (SELECT item_attr_def FROM vandelay.bib_queue WHERE id = CURRVAL('vandelay.queue_id_seq'))
107     ) WHERE circ_modifier = 'BOOK' AND barcode IS NULL AND call_number is NULL; -- null barcode means "use auto"$$,
108     'Should have a row with a NULL barcode and call number, auto-circ mod of BOOK'
109 );
110
111 SELECT * FROM finish();
112 ROLLBACK;
113