require "helper" require "minitest/autorun" class TestCollectionOutput < HoldingsTestCase def test_for_hash_output coll = load_fixture("holdings_7658449.xml") output = coll.to_hash assert_kind_of Hash, output assert_kind_of Array, output[:records] assert_equal '10746154', output[:records].first[:holding_id] assert_equal 'GB500 .G23', output[:records].first[:call_number] end def test_item_elements_in_hash_output coll = load_fixture("holdings_4191079.xml") output = coll.to_hash assert_equal '1', output[:records].first[:item_count] coll = load_fixture("holdings_5351573.xml") output = coll.to_hash coll = load_fixture("holdings_1052500.xml") output = coll.to_hash(:output_type => :condensed) # assert_equal '', output end def test_condensed_holdings_output_full coll = load_fixture("holdings_5351573.xml") output = coll.to_hash(:output_type => :condensed) assert_kind_of Hash, output coll = load_fixture("holdings_8430339.xml") output = coll.to_hash(:output_type => :condensed) assert_kind_of Array, output[:condensed_holdings_full] assert_equal 'Butler Stacks (Enter at the Butler Circulation Desk)', output[:condensed_holdings_full].first[:location_name] coll = load_fixture("holdings_2606957.xml") output = coll.to_hash(:output_type => :condensed) assert_kind_of Array, output[:condensed_holdings_full] assert_equal 'not_available', output[:condensed_holdings_full].first[:copies].first[:items]["Missing 2011-07-28. Try Borrow Direct or ILL."][:status] assert_equal ["recall_hold", "borrow_direct", "ill"], output[:condensed_holdings_full].first[:services] assert_equal 'not_available', output[:condensed_holdings_full].first[:status] coll = load_fixture("holdings_7658454.xml") output = coll.to_hash(:output_type => :condensed) assert_kind_of Array, output[:condensed_holdings_full] assert_equal 'Notes: Some volumes have multiple copies', output[:condensed_holdings_full].first[:copies].first[:notes] assert_equal 'v.2 Shelved in Butler Reference, 301 Butler (Non-Circulating)', output[:condensed_holdings_full].first[:copies].first[:temp_locations].first coll = load_fixture("holdings_8615744.xml") output = coll.to_hash(:output_type => :condensed) assert_kind_of Array, output[:condensed_holdings_full] assert_equal 'Order Information: In the Pre-Order Process. Try Borrow Direct or ILL.', output[:condensed_holdings_full].first[:copies].first[:orders] coll = load_fixture("holdings_8661671.xml") output = coll.to_hash(:output_type => :condensed) assert_kind_of Array, output[:condensed_holdings_full] assert_equal ["11739902", "11739903", "11740343"], output[:condensed_holdings_full][1][:holding_id] coll = load_fixture("holdings_1052500.xml") output = coll.to_hash(:output_type => :condensed) assert_equal 'Library has: v.1851:Sept.-2003:Dec.14, 2004:Jan.-2011:Aug.', output[:condensed_holdings_full][3][:copies][0][:summary_holdings] coll = load_fixture("holdings_5602687.xml") output = coll.to_hash(:output_type => :condensed) assert_equal "Donor: Gift; Paul Levitz; 2012.", output[:condensed_holdings_full][0][:copies][0][:donor_info] coll = load_fixture("holdings_2320514.xml") output = coll.to_hash(:output_type => :condensed) assert_equal "4", output[:condensed_holdings_full][1][:copies][0][:urls][0][:ind1] assert_equal "0", output[:condensed_holdings_full][1][:copies][0][:urls][0][:ind2] assert_equal "http://www.neighborhoodpreservationcenter.org/db/bb_files/OUR-LADY-OF-LOURDES.pdf", output[:condensed_holdings_full][1][:copies][0][:urls][0][:url] assert_equal "http://www.neighborhoodpreservationcenter.org/db/bb_files/OUR-LADY-OF-LOURDES.pdf", output[:condensed_holdings_full][1][:copies][0][:urls][0][:link_text] end def test_condensed_holdings_output_brief coll = load_fixture("holdings_5351573.xml") output = coll.to_hash(:output_type => :condensed, :content_type => :brief) assert_kind_of Hash, output coll = load_fixture("holdings_8430339.xml") output = coll.to_hash(:output_type => :condensed, :content_type => :brief) assert_kind_of Array, output[:condensed_holdings_brief] assert_equal 'Butler Stacks (Enter at the Butler Circulation Desk)', output[:condensed_holdings_brief].first[:location_name] assert_equal 'BL80.3 .D74 2011', output[:condensed_holdings_brief].first[:call_number] assert_equal 'available', output[:condensed_holdings_brief].first[:status] assert_equal ["doc_delivery"], output[:condensed_holdings_brief].first[:services] coll = load_fixture("holdings_2606957.xml") output = coll.to_hash(:output_type => :condensed, :content_type => :brief) assert_kind_of Array, output[:condensed_holdings_brief] assert_equal ["recall_hold", "borrow_direct", "ill"], output[:condensed_holdings_brief].first[:services] assert_equal 'not_available', output[:condensed_holdings_brief].first[:status] end def test_condensed_holdings_output_full_brief_messages coll = load_fixture("holdings_4191079.xml") output = coll.to_hash(:output_type => :condensed, :message_type => :short_message) assert_kind_of Array, output[:condensed_holdings_full] assert_equal 'Checked out, due 2011-09-30', output[:condensed_holdings_full].first[:copies].first[:items].keys.first assert_equal 'v.2 Checked out, due 2011-09-30', output[:condensed_holdings_full][2][:copies].first[:items].keys.first end end