require "helper" require "minitest/autorun" class TestHoldings < HoldingsTestCase def test_has_holding_ids record = load_fixture("holdings_7658449.xml").records.first assert_equal "10746154", record.holding_id end def test_location_name record = load_fixture("holdings_7658449.xml").records.first assert_equal 'Butler Stacks (Enter at the Butler Circulation Desk)', record.location_name end def test_call_number record = load_fixture("holdings_7658449.xml").records.first assert_equal 'GB500 .G23', record.call_number record2 = load_fixture("holdings_7658454.xml").records.first assert_equal 'REF GB450 .G23 FF', record2.call_number end def test_summary_holdings record = load_fixture("holdings_7658449.xml").records.first assert_kind_of Array, record.summary_holdings assert_equal 'v.1-2', record.summary_holdings.first record2 = load_fixture("holdings_7658454.xml").records.first assert_kind_of Array, record2.summary_holdings assert_equal 'v.1-2', record2.summary_holdings[0] assert_equal 'v.3-4', record2.summary_holdings[1] assert_nil record2.summary_holdings[2] record3 = load_fixture("holdings_6269409.xml").records.first assert_kind_of Array, record3.summary_holdings assert_equal [], record3.summary_holdings record4 = load_fixture("holdings_8889994.xml").records.first assert_kind_of Array, record4.summary_holdings assert_equal [], record3.summary_holdings, '866 fields with no 866 a' end def test_notes_852_single_occurrence record = load_fixture("holdings_4949188.xml").records assert_kind_of Array, record[0].notes_852 assert_equal 'znote text', record[0].notes_852.first, 'Single 852 $z' assert_kind_of Array, record[1].notes_852 assert_equal [], record[1].notes_852, 'No 852 $z' end def test_notes_852_multiple_occurrences record = load_fixture("holdings_4949188_2.xml").records assert_kind_of Array, record[1].notes_852 assert_equal 'znote 1', record[1].notes_852[0], 'First 852 $z' assert_equal 'znote 2', record[1].notes_852[1], 'Second 852 $z' end def test_notes_866_single_occurrence record = load_fixture("holdings_4949188.xml").records assert_kind_of Array, record[0].notes_866 assert_equal '866 note text', record[0].notes_866.first, 'Single 866 $z' assert_kind_of Array, record[1].notes_866 assert_equal [], record[1].notes_852, 'No 852 $z' end def test_notes_866_multiple_occurrences record = load_fixture("holdings_4949188_2.xml").records assert_kind_of Array, record[1].notes_866 assert_equal '866 znote 1', record[1].notes_866[0], 'First 866 $z' assert_equal '866 znote 2', record[1].notes_866[1], 'Second 866 $z' end def test_notes_866_no_occurrences record = load_fixture("holdings_7658449.xml").records.first assert_kind_of Array, record.notes_866 assert_equal [], record.notes_866, '866 fields with no 866 z' end def test_notes_combined record = load_fixture("holdings_4949188.xml").records assert_kind_of Array, record[0].notes assert_equal 'znote text', record[0].notes[0], 'Single 852 $z' assert_equal '866 note text', record[0].notes[1], 'Single 866 $z' end def test_shelving_title record = load_fixture("holdings_8891001.xml").records.first assert_kind_of String, record.shelving_title assert_equal 'Shelving title', record.shelving_title, '852 l' end def test_supplements record = load_fixture("holdings_8891001.xml").records.first assert_kind_of Array, record.supplements assert_equal 'Supplement', record.supplements[0], '867 fields' end def test_indexes record = load_fixture("holdings_8891001.xml").records.first assert_kind_of Array, record.indexes assert_equal 'Index', record.indexes[0], '868 fields' end def test_reproduction_note record = load_fixture("holdings_8891001.xml").records.first assert_kind_of String, record.shelving_title assert_equal 'Microfilm. 1950-1963. Webster, N.Y. : Photographic Sciences Corp., 1974- 2 microfilm reels ; 35 mm.', record.reproduction_note, '843 field' end def test_urls_simple_case record = load_fixture("holdings_8891001.xml").records.first assert_kind_of Array, record.urls assert_equal 'http://www.columbia.edu', record.urls.first[:url] assert_equal 'Part 1 Full text', record.urls.first[:link_text] end def test_urls_multiple_urls record = load_fixture("holdings_8891001_2.xml").records[1] assert_kind_of Array, record.urls assert_equal 3, record.urls.length assert_equal 'http://www.columbia.edu', record.urls.first[:url] assert_equal 'http://www.columbia.edu', record.urls.first[:link_text] assert_equal 'http://libraries.columbia.edu', record.urls[1][:url] assert_equal 'Library Website', record.urls[1][:link_text] assert_equal 'http://website 1', record.urls[2][:url] assert_equal 'Part 1', record.urls[2][:link_text] end def test_temp_location_substitution record = load_fixture("holdings_4191079.xml").records[1] assert_equal 'Butler Reserves, 208 Butler', record.location_name, 'location name' assert_equal [], record.temp_locations, 'temp location array' record = load_fixture("holdings_4191079.xml").records[3] assert_equal 'Butler Stacks (Enter at the Butler Circulation Desk)', record.location_name, 'location name' assert_equal ["v.2 Shelved in Butler Stacks Folios"], record.temp_locations, 'temp location array' end def test_online_record record = load_fixture("holdings_5656993.xml").records[0] assert_equal 'Online', record.location_name, 'location name' assert_equal 'online', record.item_status[:status] end def test_services_orders record = load_fixture('holdings_8615744.xml').records.first assert_kind_of Array, record.services assert_equal ["borrow_direct", "ill"], record.services, 'status 0' record = load_fixture('holdings_8267323.xml').records.first assert_kind_of Array, record.services assert_equal ["in_process"], record.services, "status 1" record = load_fixture('holdings_7471326.xml').records.first assert_kind_of Array, record.services assert_equal ["on_order", "borrow_direct", "ill"], record.services, "status 4" record = load_fixture('holdings_8918502.xml').records.first assert_kind_of Array, record.orders assert_equal ["on_order", "borrow_direct", "ill"], record.services, "status 8" end def test_services_checkout_patron record = load_fixture("holdings_4191079.xml").records[0] assert_equal 'not_available', record.item_status[:status] assert_equal ["recall_hold", "borrow_direct", "ill"], record.services, 'recall, BD, ILL' record = load_fixture("holdings_4191079.xml").records[2] assert_equal 'some_available', record.item_status[:status] assert_equal ["doc_delivery", "recall_hold", "borrow_direct", "ill"], record.services, 'recall, BD, ILL' end def test_services_checkout_status_patron record = load_fixture("holdings_4191079.xml").records[1] assert_equal 'not_available', record.item_status[:status] assert_equal ["borrow_direct", "ill"], record.services, 'BD, ILL' record = load_fixture("holdings_4191079.xml").records[3] assert_equal 'some_available', record.item_status[:status] assert_equal ["doc_delivery", "borrow_direct", "ill"], record.services, 'BD, ILL' end def test_services_offsite record = load_fixture("holdings_6249927.xml").records[1] assert_equal 'some_available', record.item_status[:status] assert_equal ["offsite", "borrow_direct", "ill"], record.services record = load_fixture("holdings_1717646.xml").records.first assert_equal 'available', record.item_status[:status] assert_equal 'Offsite - Place Request for delivery within 2 business days', record.location_name assert_equal ["offsite"], record.services end end