require 'coveralls'
Coveralls.wear!
require 'test/unit'
require File.expand_path("../../lib/exlibris-primo.rb", __FILE__)
# VCR is used to 'record' HTTP interactions with
# third party services used in tests, and play em
# back. Useful for efficiency, also useful for
# testing code against API's that not everyone
# has access to -- the responses can be cached
# and re-used.
require 'vcr'
require 'webmock'
# To allow us to do real HTTP requests in a VCR.turned_off, we
# have to tell webmock to let us.
WebMock.allow_net_connect!(:net_http_connect_on_start => true)
VCR.configure do |c|
c.cassette_library_dir = 'test/vcr_cassettes'
# webmock needed for HTTPClient testing
c.hook_into :webmock
# c.debug_logger = $stderr
end
# Silly way to not have to rewrite all our tests if we
# temporarily disable VCR, make VCR.use_cassette a no-op
# instead of no-such-method.
if ! defined? VCR
module VCR
def self.use_cassette(*args)
yield
end
end
end
class Test::Unit::TestCase
def assert_request_children(request, expected_root, &block)
document = Nokogiri::XML(request.to_xml)
assert_kind_of Nokogiri::XML::Document, document
children = document.root.children
assert_equal 1, children.size
assert_equal "request", document.root.name
children.each do |child|
assert child.cdata?
request_document = Nokogiri::XML(child.inner_text)
assert_equal "http://www.exlibris.com/primo/xsd/wsRequest", request_document.namespaces["xmlns"]
assert_equal "http://www.exlibris.com/primo/xsd/primoview/uicomponents", request_document.namespaces["xmlns:uic"]
assert_equal expected_root, request_document.root.name
request_document.root.children.each do |sub_child|
yield sub_child
end
end
end
protected :assert_request_children
# Reversed expectation and actual because of ruby 1.8
def assert_request(request, expected_root, *expected_args)
document = Nokogiri::XML(request.to_xml)
request_document = Nokogiri::XML(document.root.children.first.inner_text)
assert_equal(request_document.root.children.size, expected_args.size)
assert_request_children(request, expected_root) do |child|
child_xml = xmlize(child)
assert_equal expected_args.shift, child_xml
end
end
protected :assert_request
def yaml_primo_configuration
Exlibris::Primo.configure do |config|
config.load_yaml File.expand_path("../support/config.yml", __FILE__)
end
end
def reset_primo_configuration
Exlibris::Primo.configure do |config|
config.base_url = nil
config.institution = nil
config.institutions = nil
config.libraries = nil
config.availability_statuses = nil
end
end
protected :reset_primo_configuration
def xmlize(element)
element.to_xml(
:encoding => 'UTF-8',
:indent => 0,
:save_with => Nokogiri::XML::Node::SaveOptions::AS_XML | Nokogiri::XML::Node::SaveOptions::NO_DECLARATION).strip
end
def dedupmgr_record_xml
""+
""+
"$$V000932393$$Onyu_aleph000932393"+
"$$V002959842$$Onyu_aleph002959842"+
"$$Vnyu_aleph$$Onyu_aleph000932393"+
"$$Vnyu_aleph$$Onyu_aleph002959842"+
"dedupmrg17343091"+
"$$VNYU01$$Onyu_aleph000932393"+
"$$VNYU01$$Onyu_aleph002959842"+
"$$VMARC21$$Onyu_aleph000932393"+
"$$VMARC21$$Onyu_aleph002959842"+
"$$VAleph$$Onyu_aleph000932393"+
"$$VAleph$$Onyu_aleph002959842"+
"$$VNYU01000932393$$Onyu_aleph000932393"+
"$$VNYU01002959842$$Onyu_aleph002959842"+
""+
""+
"journal"+
"The New York times"+
"New-York N.Y. : H.J. Raymond & Co."+
"1857-"+
"New York (N.Y.) -- Newspapers; New York County (N.Y.) -- Newspapers; Electronic journals"+
"eng"+
"$$Cearlier_title $$VNew-York daily times"+
"Access is restricted to users affiliated with licensed institutions."+
""+
""+
"$$INYU$$LBWEB$$1Internet Resources$$2(Newspaper Electronic access )$$Scheck_holdings$$XNYU50$$YBWEB$$ZBNYUI$$Onyu_aleph000932393"+
"$$INYU$$LBOBST$$1Microform$$2(Film/Per Non-circulating )$$Scheck_holdings$$5N$$XNYU50$$YBOBST$$ZMFORM$$Onyu_aleph002959842"+
"$$ICU$$LCU$$1Microform Periodicals$$2(Non-circulating )$$Savailable$$31$$40$$5N$$60$$XNYU50$$YCU$$ZMICRP$$Onyu_aleph002959842"+
"$$ICU$$LCU$$1Periodicals$$2(Non-circulating )$$Savailable$$31$$40$$5N$$60$$XNYU50$$YCU$$ZPERIO$$Onyu_aleph002959842"+
"$$INYU$$LBWEB$$1Internet Resources$$2(Newspaper Electronic access )$$Scheck_holdings$$XNYU50$$YBWEB$$ZBNYUI$$Onyu_aleph002959842"+
"$$INYU$$LREI$$1Reference$$2(Newspaper Non-circulating )$$Scheck_holdings$$XNYU50$$YNREI$$ZREF$$Onyu_aleph002959842"+
"$$INS$$LNSSC$$1Periodicals$$2(Non-circulating )$$Scheck_holdings$$XNYU50$$YTNSSC$$ZPERIO$$Onyu_aleph002959842"+
"$$ICU$$Savailable"+
"$$INYU$$Scheck_holdings"+
"$$INS$$Scheck_holdings"+
"available"+
"NYU"+
"NYUAD"+
"NYU"+
"CU"+
"NS"+
"NYUAD"+
"nyu_aleph000932393"+
"nyu_aleph002959842"+
""+
""+
"$$V$$Taleph_holdings$$Onyu_aleph000932393"+
"$$V$$Taleph_holdings$$Onyu_aleph002959842"+
"$$V$$Taleph_backlink$$DMore bibliographic information$$Onyu_aleph000932393"+
"$$V$$Taleph_backlink$$DMore bibliographic information$$Onyu_aleph002959842"+
"$$V$$Uhttps://ezproxy.library.nyu.edu/login?url=http://proquest.umi.com/pqdweb?RQT=318&VName=PQD&clientid=9269&pmid=7818$$D1995 - Current Access via Proquest$$INYU$$Onyu_aleph000932393"+
"$$V$$Uhttps://ezproxy.library.nyu.edu/login?url=http://proquest.umi.com/pqdweb?RQT=318&VName=PQD&clientid=9269&pmid=7818$$Elinktosrc_code$$INYUAD$$Onyu_aleph000932393"+
"$$V$$Uhttps://ezproxy.library.nyu.edu/login?url=http://proquest.umi.com/pqdweb?RQT=318&VName=PQD&clientid=9269&pmid=7818$$D1995 - Current Access via Proquest$$INYUAD$$Onyu_aleph000932393"+
"$$V$$Uhttps://ezproxy.library.nyu.edu/login?url=http://www.nytimes.com/$$DOnline version:$$INYU$$Onyu_aleph002959842"+
"$$V$$Uhttps://ezproxy.library.nyu.edu/login?url=http://www.nytimes.com/$$DOnline version:$$INYUAD$$Onyu_aleph002959842"+
"$$V$$Uhttps://ezproxy.library.nyu.edu/login?url=http://web.lexis-nexis.com/universe$$DOnline access via Lexis-Nexis Academic Universe: Full-text available from 1980-$$INYU$$Onyu_aleph002959842"+
"$$V$$Uhttps://ezproxy.library.nyu.edu/login?url=http://web.lexis-nexis.com/universe$$DOnline access via Lexis-Nexis Academic Universe: Full-text available from 1980-$$INYUAD$$Onyu_aleph002959842"+
"$$V$$Uhttps://ezproxy.library.nyu.edu/login?url=http://www.umi.com/pqdauto$$DOnline access via ProQuest:$$INYU$$Onyu_aleph002959842"+
"$$V$$Uhttps://ezproxy.library.nyu.edu/login?url=http://www.umi.com/pqdauto$$DOnline access via ProQuest:$$INYUAD$$Onyu_aleph002959842"+
"$$V$$Uhttps://ezproxy.library.nyu.edu/login?url=http://toc.example.com$$DExample TOC$$INYUAD$$Onyu_aleph002959842"+
"$$V$$Uhttps://ezproxy.library.nyu.edu/login?url=http://addlink.example.com$$DExample Related Link$$INYUAD$$Onyu_aleph002959842"+
"$$V$$Topenurl_journal$$Onyu_aleph000932393"+
"$$V$$Topenurl_journal$$Onyu_aleph002959842"+
"$$V$$Topenurlfull_journal$$Onyu_aleph000932393"+
"$$V$$Topenurlfull_journal$$Onyu_aleph002959842"+
"$$TpersistentUrl$$DCopy item link"+
"$$Tworldcat_oclc$$DCheck other libraries (WorldCat®)"+
""+
""+
"Mellon Project."+
"ProQuest Information and Learning Company."+
"The New York times"+
"New York (N.Y.) Newspapers"+
"New York County (N.Y.) Newspapers"+
"Electronic journals"+
"Niyū Yūrk (N.Y.)"+
"Niu-yüeh (N.Y.)"+
"Nyuyok (N.Y.)"+
"Nyu-Yorḳ (N.Y.)"+
"New York City (N.Y.)"+
"New Amsterdam (N.Y.)"+
"Nu Yorḳ (N.Y.)"+
"Nuyorḳ (N.Y.)"+
"Novi Jork (N.Y.)"+
"Nowy Jork (N.Y.)"+
"Nova Iorque (N.Y.)"+
"Ni͡u Ĭork (N.Y.)"+
"Nueva York (N.Y.)"+
"H.J. Raymond & Co.],"+
"Latest issue consulted: Vol. 151, no. 52,028 (Feb. 13, 2002)."+
"[electronic resource]."+
"United States New York New York New York."+
"nyu_aleph"+
"nyu_aleph000932393"+
"0362-4331"+
"journal"+
"1857"+
"9999"+
"New York times on the web."+
"New York times large type weekly"+
"New-York semi-weekly times"+
"New-York weekly times"+
"Semi-weekly times (New York, N.Y.)"+
"New York times on the Web"+
"Little times"+
"New-York daily times"+
"BWEB"+
"BWEB Internet Resources"+
"nyu_aleph"+
"NYU"+
"NYUAD"+
"BOBST"+
"IFA"+
"IFAC"+
"ISAW"+
"COUR"+
"REI"+
"BWEB"+
"BWEB Internet Resources"+
"nyu_aleph"+
"NYU"+
"NYUAD"+
"BOBST"+
"IFA"+
"IFAC"+
"ISAW"+
"COUR"+
"REI"+
"Combined New York morning newspapers"+
"Combined New York Sunday newspapers"+
"Newspaper"+
"H.J. Raymond & Co.],"+
"The New York times."+
"History"+
"History Africa"+
"History East Asia"+
"History Europe"+
"History Latin America and Caribbean"+
"History Middle East"+
"History North America"+
"History Slavic"+
"Dance"+
"Performing arts"+
"Theater"+
"Government information New York State and City Recommended"+
"Electronic indexes"+
"Electronic newspapers"+
"Dancing"+
"Information, Government"+
"Show business"+
"Professional theater"+
"Theatre"+
"Dramatics"+
"nyu_aleph002959842"+
"New York semi-weekly times"+
"New York times on the web"+
"BOBST Microform"+
"CU"+
"CU Microform Periodicals"+
"CU Periodicals"+
"NREI"+
"NREI Reference"+
"TNSSC"+
"TNSSC Periodicals"+
"NS"+
"NSSC"+
"CPER"+
"BOBST Microform"+
"CU"+
"CU Microform Periodicals"+
"CU Periodicals"+
"NREI"+
"NREI Reference"+
"TNSSC"+
"TNSSC Periodicals"+
"NS"+
"NSSC"+
"CPER"+
"N.Y. times"+
"Film/Per"+
""+
""+
"New York times"+
"1857"+
"1857"+
""+
""+
"eng"+
"1857"+
"New York (N.Y.)–Newspapers"+
"New York County (N.Y.)–Newspapers"+
"available"+
"online_resources"+
"journals"+
"journals"+
"Newspapers"+
"Electronic journals"+
"BOBST"+
"IFA"+
"IFAC"+
"ISAW"+
"COUR"+
"REI"+
"Internet Resources"+
"United States"+
"New York"+
"New York."+
"History"+
"History–Africa"+
"History–East Asia"+
"History–Europe"+
"History–Latin America and Caribbean"+
"History–Middle East"+
"History–North America"+
"History–Slavic"+
"Dance"+
"Performing arts"+
"Theater"+
"Government information–New York State and City–Recommended"+
"BOBST"+
"CU"+
"NREI"+
"NSSC"+
"Electronic indexes"+
"Electronic newspapers"+
"NSSC"+
"CPER"+
"Microform"+
"Microform Periodicals"+
"Periodicals"+
"Reference"+
"21490924"+
"5"+
""+
""+
"2"+
"0362-4331"+
"newyorktimes"+
"new"+
"0362-4331"+
"1857"+
"new york times"+
"new york times"+
"nyu"+
"new"+
""+
""+
"1"+
"$$Knew york times$$AT"+
""+
""+
"$$VNYU$$Onyu_aleph000932393"+
"$$VNYUAD$$Onyu_aleph000932393"+
"$$VOnline Resource$$Onyu_aleph000932393"+
"$$VNYU$$Onyu_aleph002959842"+
"$$VCU$$Onyu_aleph002959842"+
"$$VNS$$Onyu_aleph002959842"+
"$$VNYUAD$$Onyu_aleph002959842"+
"$$VOnline Resource$$Onyu_aleph002959842"+
""+
""+
"Newspaper"+
""+
""+
"1"+
"1"+
""+
""+
"The New York times"+
"Combined New York morning newspapers"+
"1857"+
"1857-"+
"NYTIAO"+
"journal"+
"journal"+
"JOUR"+
"New-York [N.Y."+
"H.J. Raymond & Co.]"+
"BWEB"+
"Online Resource"+
"The New York times."+
"N.Y. times"+
"0362-4331"+
"1645522"+
"sn 78004456"+
"BOBSTBOBSTBWEBNREICUCUTNSSC"+
""+
""
end
def record_xml
""+
""+
"000062856"+
"nyu_aleph"+
"nyu_aleph000062856"+
"NYU01"+
"NYU01000062856"+
"MARC21"+
"Aleph"+
""+
""+
"book"+
"Travels with my aunt"+
"Graham Greene 1904-1991."+
"Deluxe ed."+
"New York : Penguin Books"+
"2004"+
"xvi, 254 p. ; 22 cm."+
"$$Cisbn$$V0143039008; $$Cisbn$$V9780143039006"+
"British -- Foreign countries -- Fiction; Women travelers -- Fiction; Older women -- Fiction; Travelers -- Fiction; Retirees -- Fiction; Aunts -- Fiction; Humorous stories"+
"eng"+
"$$Cseries $$VPenguin classics"+
""+
"$$INYU$$LBOBST$$1Main Collection$$2(PR6013.R44 T7 2004 )$$Sunavailable$$31$$41$$5N$$61$$XNYU50$$YBOBST$$ZMAIN"+
"nyu_aleph000062856"+
"NYU"+
"$$INYU$$Sunavailable"+
"unavailable"+
""+
""+
"$$Topenurl_journal"+
"$$Taleph_backlink$$DMore bibliographic information"+
"$$Tamazon_thumb"+
"$$Tamazon_toc$$DCheck for Amazon Search Inside"+
"$$Topenurlfull_journal"+
"$$Taleph_holdings"+
"$$TpersistentUrl$$DCopy item link"+
"$$Tamazon_uc$$DCheck Amazon"+
"$$Tworldcat_isbn$$DCheck other libraries (WorldCat®)"+
"$$Tsyndetics_excerpt$$DExcerpt from item"+
""+
""+
"Graham, Greene 1904-1991."+
"Greene, Graham, 1904-1991."+
"Greene, G"+
"Graham Greene ; introduction by Gloria Emerson."+
"Greene, Henry Graham, 1904-1991"+
"Gŭrin, Gŭreŏm, 1904-1991"+
"Grin, Greham, 1904-1991"+
"Grīna, Grāhama, 1904-1991"+
"Grin, Grėm, 1904-1991"+
"格拉姆・葛林, 1904-1991"+
"Grīns, Greiems, 1904-1991"+
"Grīns, G. (Greiems), 1904-1991"+
"Travels with my aunt /"+
"British Foreign countries Fiction"+
"Women travelers Fiction"+
"Older women Fiction"+
"Travelers Fiction"+
"Retirees Fiction"+
"Aunts Fiction"+
"Humorous stories"+
"People, Retired"+
"Retired persons"+
"Retired people"+
"Travelers, Women"+
"Britishers"+
"British people"+
"Britons (British)"+
"Brits"+
"Aged women"+
"Penguin Books,"+
"\"Graham Greene centennial, 1904-2004\"--Cover."+
"nyu_aleph"+
"nyu_aleph000062856"+
"0143039008"+
"9780143039006"+
"9780143"0390069"+
"book"+
"2004"+
"1969"+
"Penguin classics"+
"BOBST"+
"BOBST Main Collection"+
"nyu_aleph"+
"NYU"+
"BOBST"+
"BOBST Main Collection"+
"nyu_aleph"+
"NYU"+
"PR6013.R44 T7 2004"+
"PR6013 .R44 T7 2004"+
"Penguin Books,"+
""+
""+
"Travels with my aunt /"+
"2004"+
"Greene, Graham, 1904-1991."+
"2004"+
""+
""+
"eng"+
"2004"+
"British–Foreign countries–Fiction"+
"Women travelers–Fiction"+
"Older women–Fiction"+
"Travelers–Fiction"+
"Retirees–Fiction"+
"Aunts–Fiction"+
"BOBST"+
"books"+
"books"+
"Greene, G"+
"Fiction"+
"Humorous stories"+
"BOBST"+
"Main Collection"+
"P - Language and literature.–English literature"+
"49340863"+
"5"+
""+
""+
"1"+
"2004559272"+
"0143039008;9780143039006"+
"travelswithmyaunt"+
"2004"+
"2004559272"+
"0143039008;9780143039006"+
"travelswithmyaunt"+
"2004"+
"travels with my aunt"+
"nyu"+
"xvi, 254 p. ;"+
"penguin books"+
"greene graham 1904 1991"+
""+
""+
"1"+
"$$Kgreene graham 1904 1991$$AA"+
"$$Kbooktravels with my aunt$$AT"+
""+
""+
"NYU"+
"Physical Item"+
""+
""+
"PR6013.R44"+
""+
""+
"1"+
"1"+
""+
""+
"Greene"+
"Graham,"+
"Greene, Graham, 1904-1991"+
"Travels with my aunt"+
"Penguin classics"+
"2004"+
"2004."+
"0143039008"+
"9780143039006"+
"book"+
"book"+
"BOOK"+
"Includes bibliographical references (p. xv-xvi)."+
"New York"+
"Penguin Books"+
"56781200"+
"2004559272"+
"BOBST"+
"Physical Item"+
""+
""
end
def record_invalid_frbr_xml
""+
""+
"000062856"+
"nyu_aleph"+
"nyu_aleph000062856"+
"NYU01"+
"NYU01000062856"+
"MARC21"+
"Aleph"+
""+
""+
"book"+
"Travels with my aunt"+
"Graham Greene 1904-1991."+
"Deluxe ed."+
"New York : Penguin Books"+
"2004"+
"xvi, 254 p. ; 22 cm."+
"$$Cisbn$$V0143039008; $$Cisbn$$V9780143039006"+
"British -- Foreign countries -- Fiction; Women travelers -- Fiction; Older women -- Fiction; Travelers -- Fiction; Retirees -- Fiction; Aunts -- Fiction; Humorous stories"+
"eng"+
"$$Cseries $$VPenguin classics"+
""+
"$$INYU$$LBOBST$$1Main Collection$$2(PR6013.R44 T7 2004 )$$Sunavailable$$31$$41$$5N$$61$$XNYU50$$YBOBST$$ZMAIN"+
"nyu_aleph000062856"+
"NYU"+
"$$INYU$$Sunavailable"+
"unavailable"+
""+
""+
"$$Topenurl_journal"+
"$$Taleph_backlink$$DMore bibliographic information"+
"$$Tamazon_thumb"+
"$$Tamazon_toc$$DCheck for Amazon Search Inside"+
"$$Topenurlfull_journal"+
"$$Taleph_holdings"+
"$$TpersistentUrl$$DCopy item link"+
"$$Tamazon_uc$$DCheck Amazon"+
"$$Tworldcat_isbn$$DCheck other libraries (WorldCat®)"+
"$$Tsyndetics_excerpt$$DExcerpt from item"+
""+
""+
"Graham, Greene 1904-1991."+
"Greene, Graham, 1904-1991."+
"Greene, G"+
"Graham Greene ; introduction by Gloria Emerson."+
"Greene, Henry Graham, 1904-1991"+
"Gŭrin, Gŭreŏm, 1904-1991"+
"Grin, Greham, 1904-1991"+
"Grīna, Grāhama, 1904-1991"+
"Grin, Grėm, 1904-1991"+
"格拉姆・葛林, 1904-1991"+
"Grīns, Greiems, 1904-1991"+
"Grīns, G. (Greiems), 1904-1991"+
"Travels with my aunt /"+
"British Foreign countries Fiction"+
"Women travelers Fiction"+
"Older women Fiction"+
"Travelers Fiction"+
"Retirees Fiction"+
"Aunts Fiction"+
"Humorous stories"+
"People, Retired"+
"Retired persons"+
"Retired people"+
"Travelers, Women"+
"Britishers"+
"British people"+
"Britons (British)"+
"Brits"+
"Aged women"+
"Penguin Books,"+
"\"Graham Greene centennial, 1904-2004\"--Cover."+
"nyu_aleph"+
"nyu_aleph000062856"+
"0143039008"+
"9780143039006"+
"9780143"0390069"+
"book"+
"2004"+
"1969"+
"Penguin classics"+
"BOBST"+
"BOBST Main Collection"+
"nyu_aleph"+
"NYU"+
"BOBST"+
"BOBST Main Collection"+
"nyu_aleph"+
"NYU"+
"PR6013.R44 T7 2004"+
"PR6013 .R44 T7 2004"+
"Penguin Books,"+
""+
""+
"Travels with my aunt /"+
"2004"+
"Greene, Graham, 1904-1991."+
"2004"+
""+
""+
"eng"+
"2004"+
"British–Foreign countries–Fiction"+
"Women travelers–Fiction"+
"Older women–Fiction"+
"Travelers–Fiction"+
"Retirees–Fiction"+
"Aunts–Fiction"+
"BOBST"+
"books"+
"books"+
"Greene, G"+
"Fiction"+
"Humorous stories"+
"BOBST"+
"Main Collection"+
"P - Language and literature.–English literature"+
"49340863"+
"6"+
""+
""+
"1"+
"2004559272"+
"0143039008;9780143039006"+
"travelswithmyaunt"+
"2004"+
"2004559272"+
"0143039008;9780143039006"+
"travelswithmyaunt"+
"2004"+
"travels with my aunt"+
"nyu"+
"xvi, 254 p. ;"+
"penguin books"+
"greene graham 1904 1991"+
""+
""+
"1"+
"$$Kgreene graham 1904 1991$$AA"+
"$$Kbooktravels with my aunt$$AT"+
""+
""+
"NYU"+
"Physical Item"+
""+
""+
"PR6013.R44"+
""+
""+
"1"+
"1"+
""+
""+
"Greene"+
"Graham,"+
"Greene, Graham, 1904-1991"+
"Travels with my aunt"+
"Penguin classics"+
"2004"+
"2004."+
"0143039008"+
"9780143039006"+
"book"+
"book"+
"BOOK"+
"Includes bibliographical references (p. xv-xvi)."+
"New York"+
"Penguin Books"+
"56781200"+
"2004559272"+
"BOBST"+
"Physical Item"+
""+
""
end
end