umlaut 3.0.0alpha1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +7 -0
- data/README.md +49 -0
- data/Rakefile +37 -0
- data/app/assets/images/error.gif +0 -0
- data/app/assets/images/export_bg_bot.gif +0 -0
- data/app/assets/images/export_bg_mid.gif +0 -0
- data/app/assets/images/export_bg_top.gif +0 -0
- data/app/assets/images/famfamfam/book_open.png +0 -0
- data/app/assets/images/famfamfam/cross.png +0 -0
- data/app/assets/images/famfamfam/page_sound.gif +0 -0
- data/app/assets/images/famfamfam/page_text.gif +0 -0
- data/app/assets/images/famfamfam/page_up.gif +0 -0
- data/app/assets/images/famfamfam/page_white.png +0 -0
- data/app/assets/images/famfamfam/readme.html +1495 -0
- data/app/assets/images/famfamfam/tiny_cross.png +0 -0
- data/app/assets/images/frame_remove.gif +0 -0
- data/app/assets/images/ico_go.gif +0 -0
- data/app/assets/images/jhu_findit.gif +0 -0
- data/app/assets/images/list_closed.png +0 -0
- data/app/assets/images/list_open.png +0 -0
- data/app/assets/images/more_info.gif +0 -0
- data/app/assets/images/rails.png +0 -0
- data/app/assets/images/request.gif +0 -0
- data/app/assets/images/spinner.gif +0 -0
- data/app/assets/javascripts/umlaut/ajax_windows.js +35 -0
- data/app/assets/javascripts/umlaut/ensure_window_size.js.erb +34 -0
- data/app/assets/javascripts/umlaut/expand_contract_toggle.js +25 -0
- data/app/assets/javascripts/umlaut/search_autocomplete.js +46 -0
- data/app/assets/javascripts/umlaut/simple_visible_toggle.js +8 -0
- data/app/assets/javascripts/umlaut/update_html.js +152 -0
- data/app/assets/javascripts/umlaut.js +17 -0
- data/app/assets/stylesheets/umlaut.css +857 -0
- data/app/controllers/application_controller.rb +14 -0
- data/app/controllers/export_email_controller.rb +123 -0
- data/app/controllers/js_helper_controller.rb +10 -0
- data/app/controllers/link_router_controller.rb +87 -0
- data/app/controllers/open_search_controller.rb +9 -0
- data/app/controllers/resolve_controller.rb +288 -0
- data/app/controllers/resource_controller.rb +83 -0
- data/app/controllers/search_controller.rb +328 -0
- data/app/controllers/search_methods/sfx3.rb +148 -0
- data/app/controllers/search_methods/sfx4.rb +257 -0
- data/app/controllers/search_methods/sfx_api.rb +47 -0
- data/app/controllers/store_controller.rb +64 -0
- data/app/controllers/umlaut/controller_behavior.rb +20 -0
- data/app/controllers/umlaut/controller_logic.rb +96 -0
- data/app/controllers/umlaut/error_handling.rb +48 -0
- data/app/controllers/umlaut_controller.rb +112 -0
- data/app/helpers/application_helper.rb +4 -0
- data/app/helpers/emailer_helper.rb +43 -0
- data/app/helpers/export_email_helper.rb +34 -0
- data/app/helpers/open_search_helper.rb +7 -0
- data/app/helpers/resolve_helper.rb +225 -0
- data/app/helpers/search_helper.rb +50 -0
- data/app/helpers/umlaut/footer_helper.rb +64 -0
- data/app/helpers/umlaut/helper.rb +62 -0
- data/app/helpers/umlaut/html_head_helper.rb +37 -0
- data/app/helpers/umlaut/url_generation.rb +77 -0
- data/app/mailers/emailer.rb +48 -0
- data/app/models/clickthrough.rb +2 -0
- data/app/models/collection.rb +259 -0
- data/app/models/crossref_lookup.rb +2 -0
- data/app/models/dispatched_service.rb +58 -0
- data/app/models/permalink.rb +29 -0
- data/app/models/referent.rb +473 -0
- data/app/models/referent_value.rb +14 -0
- data/app/models/request.rb +449 -0
- data/app/models/service_response.rb +179 -0
- data/app/models/service_store.rb +59 -0
- data/app/models/service_type_value.rb +58 -0
- data/app/models/service_wave.rb +150 -0
- data/app/models/sfx_db/az_additional_title.rb +11 -0
- data/app/models/sfx_db/az_letter_group.rb +11 -0
- data/app/models/sfx_db/az_title.rb +38 -0
- data/app/models/sfx_db/az_title_v2.rb +34 -0
- data/app/models/sfx_db/isbn.rb +12 -0
- data/app/models/sfx_db/issn.rb +12 -0
- data/app/models/sfx_db/object.rb +35 -0
- data/app/models/sfx_db/object_portfolio.rb +6 -0
- data/app/models/sfx_db/publisher.rb +10 -0
- data/app/models/sfx_db/sfx_db_base.rb +54 -0
- data/app/models/sfx_db/target.rb +9 -0
- data/app/models/sfx_db/target_service.rb +10 -0
- data/app/models/sfx_db/title.rb +10 -0
- data/app/models/sfx_db.rb +10 -0
- data/app/models/sfx_url.rb +35 -0
- data/app/views/emailer/citation.text.erb +28 -0
- data/app/views/emailer/short_citation.text.erb +8 -0
- data/app/views/export_email/_email.html.erb +25 -0
- data/app/views/export_email/_send_email.html.erb +3 -0
- data/app/views/export_email/_send_txt.html.erb +3 -0
- data/app/views/export_email/_txt.html.erb +62 -0
- data/app/views/export_email/email.html.erb +3 -0
- data/app/views/export_email/send_email.html.erb +1 -0
- data/app/views/export_email/send_txt.html.erb +1 -0
- data/app/views/export_email/txt.html.erb +3 -0
- data/app/views/js_helper/loader.erb.js +13 -0
- data/app/views/layouts/umlaut.html.erb +52 -0
- data/app/views/open_search/index.html.erb +9 -0
- data/app/views/resolve/_api_in_progress.xml.erb +21 -0
- data/app/views/resolve/_background_progress.html.erb +51 -0
- data/app/views/resolve/_background_updater.html.erb +38 -0
- data/app/views/resolve/_citation.html.erb +87 -0
- data/app/views/resolve/_coins.html.erb +1 -0
- data/app/views/resolve/_compact_citation.html.erb +33 -0
- data/app/views/resolve/_cover_image.html.erb +35 -0
- data/app/views/resolve/_fulltext.html.erb +55 -0
- data/app/views/resolve/_help.html.erb +17 -0
- data/app/views/resolve/_holding.html.erb +91 -0
- data/app/views/resolve/_related_items.html.erb +35 -0
- data/app/views/resolve/_search_inside.html.erb +62 -0
- data/app/views/resolve/_section_display.html.erb +49 -0
- data/app/views/resolve/_service_errors.html.erb +29 -0
- data/app/views/resolve/_standard_response_item.html.erb +89 -0
- data/app/views/resolve/api.xml.builder +72 -0
- data/app/views/resolve/background_status.html.erb +26 -0
- data/app/views/resolve/index.html.erb +73 -0
- data/app/views/resolve/partial_html_sections.xml.erb +30 -0
- data/app/views/search/_a_to_z.html.erb +6 -0
- data/app/views/search/_citation.html.erb +94 -0
- data/app/views/search/_pager.html.erb +60 -0
- data/app/views/search/books.html.erb +103 -0
- data/app/views/search/journal_search.html.erb +90 -0
- data/app/views/search/journals.html.erb +167 -0
- data/app/views/search/opensearch_description.rxml +10 -0
- data/app/views/testing/index.html.erb +1 -0
- data/app/views/umlaut/README +5 -0
- data/app/views/umlaut/error.html.erb +45 -0
- data/db/migrate/01_umlaut_init.rb +113 -0
- data/db/orig_fixed_data/service_type_values.yml +120 -0
- data/db/seeds.rb +7 -0
- data/lib/CronTab.rb +192 -0
- data/lib/aws_product_sign.rb +146 -0
- data/lib/exlibris/aleph/patron.rb +64 -0
- data/lib/exlibris/aleph/record.rb +54 -0
- data/lib/exlibris/aleph/rest_api.rb +29 -0
- data/lib/exlibris/primo/holding.rb +192 -0
- data/lib/exlibris/primo/rsrc.rb +17 -0
- data/lib/exlibris/primo/searcher.rb +276 -0
- data/lib/exlibris/primo/source/aleph.rb +46 -0
- data/lib/exlibris/primo/source/distribution/nyu_aleph.rb +323 -0
- data/lib/exlibris/primo/toc.rb +17 -0
- data/lib/exlibris/primo_ws.rb +140 -0
- data/lib/generators/templates/umlaut_services.yml +237 -0
- data/lib/generators/umlaut/asset_hooks_generator.rb +44 -0
- data/lib/generators/umlaut/install_generator.rb +110 -0
- data/lib/hip3/bib.rb +291 -0
- data/lib/hip3/bib_searcher.rb +302 -0
- data/lib/hip3/custom_field_lookup.rb +44 -0
- data/lib/hip3/holding.rb +50 -0
- data/lib/hip3/item.rb +65 -0
- data/lib/hip3/receipt.rb +7 -0
- data/lib/hip3/serial_copy.rb +82 -0
- data/lib/holding.rb +32 -0
- data/lib/marc_helper.rb +254 -0
- data/lib/metadata_helper.rb +312 -0
- data/lib/opensearch_feed.rb +398 -0
- data/lib/opensearch_query.rb +98 -0
- data/lib/referent_filter.rb +16 -0
- data/lib/referent_filters/dissertation_catch.rb +45 -0
- data/lib/section_renderer.rb +503 -0
- data/lib/service.rb +336 -0
- data/lib/service_adaptors/ajax_export.rb +37 -0
- data/lib/service_adaptors/amazon.rb +412 -0
- data/lib/service_adaptors/blacklight.rb +327 -0
- data/lib/service_adaptors/book_finder.rb +40 -0
- data/lib/service_adaptors/bx.rb +51 -0
- data/lib/service_adaptors/cover_thing.rb +73 -0
- data/lib/service_adaptors/elsevier_cover.rb +57 -0
- data/lib/service_adaptors/email_export.rb +10 -0
- data/lib/service_adaptors/ezproxy.rb +171 -0
- data/lib/service_adaptors/google_book_search.rb +442 -0
- data/lib/service_adaptors/gpo.rb +124 -0
- data/lib/service_adaptors/hathi_trust.rb +308 -0
- data/lib/service_adaptors/hip3_service.rb +150 -0
- data/lib/service_adaptors/hip_holding_search.rb +237 -0
- data/lib/service_adaptors/internet_archive.rb +488 -0
- data/lib/service_adaptors/isbn_db.rb +86 -0
- data/lib/service_adaptors/isi.rb +258 -0
- data/lib/service_adaptors/jcr.rb +146 -0
- data/lib/service_adaptors/opac.rb +351 -0
- data/lib/service_adaptors/open_library.rb +316 -0
- data/lib/service_adaptors/open_library_cover.rb +73 -0
- data/lib/service_adaptors/primo_service.rb +392 -0
- data/lib/service_adaptors/primo_source.rb +78 -0
- data/lib/service_adaptors/pubmed.rb +133 -0
- data/lib/service_adaptors/request_to_fixture.rb +68 -0
- data/lib/service_adaptors/scopus.rb +295 -0
- data/lib/service_adaptors/sfx-new.rb +557 -0
- data/lib/service_adaptors/sfx.rb +566 -0
- data/lib/service_adaptors/sfx_backchannel_record.rb +69 -0
- data/lib/service_adaptors/txt_holding_export.rb +32 -0
- data/lib/service_adaptors/ulrichs_cover.rb +57 -0
- data/lib/service_adaptors/ulrichs_link.rb +47 -0
- data/lib/service_adaptors/worldcat.rb +116 -0
- data/lib/service_adaptors/worldcat_identities.rb +591 -0
- data/lib/tasks/umlaut.rake +134 -0
- data/lib/umlaut/default_configuration.rb +5 -0
- data/lib/umlaut/routes.rb +136 -0
- data/lib/umlaut/version.rb +3 -0
- data/lib/umlaut.rb +37 -0
- data/lib/umlaut_configurable.rb +343 -0
- data/lib/umlaut_http.rb +100 -0
- data/lib/xml_schema_helper.rb +109 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/umlaut_controller.rb +112 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config/application.rb +45 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database-jhu.yml +44 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +34 -0
- data/test/dummy/config/environments/production.rb +60 -0
- data/test/dummy/config/environments/test.rb +39 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +10 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +61 -0
- data/test/dummy/config/umlaut_services.yml +237 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/migrate/20111228211210_umlaut_init.rb +113 -0
- data/test/dummy/db/schema.rb +124 -0
- data/test/dummy/log/development.log +12981 -0
- data/test/dummy/log/production.log +0 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +26 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/tmp/cache/assets/C5F/340/sprockets%2F99692920160b7a279b86a80415b79db7 +0 -0
- data/test/dummy/tmp/cache/assets/C70/4D0/sprockets%2F034ad2036e623081bd352800786dfe80 +0 -0
- data/test/dummy/tmp/cache/assets/C73/920/sprockets%2Fd371318f22900492fd180f17c5e2a504 +9268 -0
- data/test/dummy/tmp/cache/assets/C80/980/sprockets%2Fc94807409c1523d43e18d25f35d93c41 +0 -0
- data/test/dummy/tmp/cache/assets/C8F/780/sprockets%2Fe47e28558116fb5f8038754e60d1961d +11769 -0
- data/test/dummy/tmp/cache/assets/CAA/EB0/sprockets%2F1d179210e8b76f1ea63c802688a015e4 +9271 -0
- data/test/dummy/tmp/cache/assets/CBB/9C0/sprockets%2F706f28923fb754cad04b9107c89986a1 +0 -0
- data/test/dummy/tmp/cache/assets/CBF/B60/sprockets%2F08ca89671549936265dcb673bf02e36f +0 -0
- data/test/dummy/tmp/cache/assets/CC9/9F0/sprockets%2F306166316e2cafd13c15e62b51a2339d +0 -0
- data/test/dummy/tmp/cache/assets/CF6/F20/sprockets%2F5b2ffa1103079dfd555197838f87a99f +0 -0
- data/test/dummy/tmp/cache/assets/CF7/2B0/sprockets%2F25a7c73655bd3598173b39d9f98bcd46 +862 -0
- data/test/dummy/tmp/cache/assets/CFE/080/sprockets%2F37fe9f4255baddbd549a659914929398 +0 -0
- data/test/dummy/tmp/cache/assets/D22/060/sprockets%2F9aec77b768e91a802d284271c58e2f7e +21357 -0
- data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/D33/6D0/sprockets%2F500129c57f1146e556ec3aacd6cd38c1 +0 -0
- data/test/dummy/tmp/cache/assets/D33/FD0/sprockets%2F2ba0b4e6334a77b923e5f770381bb2bf +0 -0
- data/test/dummy/tmp/cache/assets/D42/C20/sprockets%2Fbcf14e437b1582bf93b77670acf8e090 +21353 -0
- data/test/dummy/tmp/cache/assets/D50/A30/sprockets%2F7d8b294ac433db5d056538f8cf7c66b9 +0 -0
- data/test/dummy/tmp/cache/assets/D54/ED0/sprockets%2F71c9fa01091d432b131da3bb73faf3d4 +872 -0
- data/test/dummy/tmp/cache/assets/D65/590/sprockets%2Fc1bb92fc3406a126b7dd302edc96d629 +0 -0
- data/test/dummy/tmp/cache/assets/D71/6B0/sprockets%2Fde558b71b494cf09b1bf055c8dff0353 +0 -0
- data/test/dummy/tmp/cache/assets/D72/610/sprockets%2Fa8c708eeb30ef93de34d755d4f45d023 +859 -0
- data/test/dummy/tmp/cache/assets/D76/AD0/sprockets%2Fe2158cde93188cf5ab6457bc6d6602ec +0 -0
- data/test/dummy/tmp/cache/assets/D7A/E40/sprockets%2F9622ffcc499a57627cd1bb18fe31b8e4 +11772 -0
- data/test/dummy/tmp/cache/assets/D84/210/sprockets%2Fabd0103ccec2b428ac62c94e4c40b384 +0 -0
- data/test/dummy/tmp/cache/assets/D9B/770/sprockets%2F8aacf02eb7dbb0949704b28f27b87e0b +0 -0
- data/test/dummy/tmp/cache/assets/DA6/A80/sprockets%2F92e26d8e58d5bcc8b8f6c25d1b05b9c1 +0 -0
- data/test/dummy/tmp/cache/assets/DE8/790/sprockets%2Fd1333bde2b9aafcc712d11dd09ab35d8 +0 -0
- data/test/dummy/tmp/cache/assets/DF7/F30/sprockets%2F7bc16c4109b17fabe29f8ddbbf732d1c +374 -0
- data/test/dummy/tmp/cache/assets/E03/570/sprockets%2F493bdc0ac14cd4f57fdfe4253f992bde +0 -0
- data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/E0B/4B0/sprockets%2F7988df51a61c81ce6ede4a2d4c8cce4f +377 -0
- data/test/dummy/tmp/cache/assets/E5F/960/sprockets%2Fdc007b6cad5c7ef08e33ec28cfff0ef6 +0 -0
- data/test/fixtures/dispatched_services.yml +5 -0
- data/test/fixtures/permalinks.yml +5 -0
- data/test/fixtures/referent_values.yml +1734 -0
- data/test/fixtures/referents.yml +156 -0
- data/test/fixtures/requests.yml +284 -0
- data/test/fixtures/service_responses.yml +5 -0
- data/test/fixtures/sfx_urls.yml +4 -0
- data/test/performance/browsing_test.rb +9 -0
- data/test/test_helper.rb +10 -0
- data/test/umlaut_test.rb +7 -0
- data/test/unit/aleph_patron_test.rb +39 -0
- data/test/unit/aleph_record_benchmarks.rb +28 -0
- data/test/unit/aleph_record_test.rb +30 -0
- data/test/unit/aws_product_sign_test.rb +93 -0
- data/test/unit/collection_test.rb +76 -0
- data/test/unit/google_book_search_test.rb +101 -0
- data/test/unit/primo_searcher_test.rb +403 -0
- data/test/unit/primo_service_test.rb +939 -0
- data/test/unit/primo_ws_test.rb +131 -0
- data/test/unit/service_response_test.rb +9 -0
- data/test/unit/service_test.rb +33 -0
- metadata +580 -0
data/test/test_helper.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
+
require "rails/test_help"
|
6
|
+
|
7
|
+
Rails.backtrace_cleaner.remove_silencers!
|
8
|
+
|
9
|
+
# Load support files
|
10
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
data/test/umlaut_test.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
class AlephPatronTest < ActiveSupport::TestCase
|
3
|
+
def setup
|
4
|
+
@primo_config = YAML.load_file("#{Rails.root}/config/umlaut_config/primo.yml")
|
5
|
+
@nyu_aleph_config = @primo_config["sources"]["nyu_aleph"]
|
6
|
+
@rest_url = @nyu_aleph_config["rest_url"]
|
7
|
+
@aleph_doc_library = "NYU01"
|
8
|
+
@aleph_doc_number = "000062856"
|
9
|
+
@nyuidn = "N12162279"
|
10
|
+
@aleph_adm_library = "NYU50"
|
11
|
+
@aleph_item_id = "NYU50000062856000010"
|
12
|
+
@aleph_renew_item_id = "NYU50000647049"
|
13
|
+
@pickup_location = "BOBST"
|
14
|
+
@bogus_url = "http://library.nyu.edu/bogus"
|
15
|
+
end
|
16
|
+
|
17
|
+
# Test exception handling for bogus response.
|
18
|
+
def test_bogus_response
|
19
|
+
patron = Exlibris::Aleph::Patron.new(@nyuidn, @bogus_url)
|
20
|
+
assert_raise(REXML::ParseException) { patron.loans }
|
21
|
+
assert_raise(REXML::ParseException) { patron.renew_loans() }
|
22
|
+
assert_raise(REXML::ParseException) { patron.renew_loans(@aleph_renew_item_id) }
|
23
|
+
assert_raise(RuntimeError) { patron.place_hold(@aleph_adm_library, @aleph_doc_library, @aleph_doc_number, @aleph_item_id, {:pickup_location => @pickup_location}) }
|
24
|
+
end
|
25
|
+
|
26
|
+
# Test search for a single Primo document.
|
27
|
+
def test_patron
|
28
|
+
patron = Exlibris::Aleph::Patron.new(@nyuidn, @rest_url)
|
29
|
+
loans = patron.loans
|
30
|
+
assert_nil(patron.error, "Failure in #{patron.class} while getting loans: #{patron.error}")
|
31
|
+
#renew_loans = patron.renew_loans()
|
32
|
+
#assert_nil(patron.error, "Failure in #{patron.class} while renewing all loans: #{patron.error}")
|
33
|
+
#renew_loans = patron.renew_loans(@aleph_renew_item_id)
|
34
|
+
#assert_nil(patron.error, "Failure in #{patron.class} while renewing loan #{@aleph_renew_item_id}: #{patron.error}")
|
35
|
+
assert_raise(RuntimeError) { patron.place_hold(@aleph_adm_library, @aleph_doc_library, @aleph_doc_number, @aleph_item_id, {}) }
|
36
|
+
place_hold = patron.place_hold(@aleph_adm_library, @aleph_doc_library, @aleph_doc_number, @aleph_item_id, {:pickup_location => @pickup_location})
|
37
|
+
assert_nil(patron.error, "Failure in #{patron.class} while placing hold: #{patron.error}")
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
class AlephRecordBenchMarks < ActiveSupport::TestCase
|
3
|
+
def setup
|
4
|
+
@primo_config = YAML.load_file("#{Rails.root}/config/umlaut_config/primo.yml")
|
5
|
+
@nyu_aleph_config = @primo_config["sources"]["nyu_aleph"]
|
6
|
+
@rest_url = @nyu_aleph_config["rest_url"]
|
7
|
+
@aleph_doc_library = "NYU01"
|
8
|
+
@aleph_doc_number = "000062856"
|
9
|
+
@bogus_url = "http://library.nyu.edu/bogus"
|
10
|
+
@TESTS = 10
|
11
|
+
end
|
12
|
+
|
13
|
+
# Get benchmarks for calls to the Aleph API.
|
14
|
+
def test_benchmarks
|
15
|
+
# Display performance benchmarks.
|
16
|
+
time = Benchmark.bmbm do |results|
|
17
|
+
results.report("Aleph items:") { @TESTS.times {
|
18
|
+
aleph_record = Exlibris::Aleph::Record.new(@aleph_doc_library, @aleph_doc_number, @rest_url)
|
19
|
+
items = aleph_record.items
|
20
|
+
} }
|
21
|
+
results.report("Aleph bib and holdings:") { @TESTS.times {
|
22
|
+
aleph_record = Exlibris::Aleph::Record.new(@aleph_doc_library, @aleph_doc_number, @rest_url)
|
23
|
+
items = aleph_record.bib
|
24
|
+
items = aleph_record.holdings
|
25
|
+
} }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
class AlephRecordTest < ActiveSupport::TestCase
|
3
|
+
def setup
|
4
|
+
@primo_config = YAML.load_file("#{Rails.root}/config/umlaut_config/primo.yml")
|
5
|
+
@nyu_aleph_config = @primo_config["sources"]["nyu_aleph"]
|
6
|
+
@rest_url = @nyu_aleph_config["rest_url"]
|
7
|
+
@aleph_doc_library = "NYU01"
|
8
|
+
@aleph_doc_number = "000062856"
|
9
|
+
@bogus_url = "http://library.nyu.edu/bogus"
|
10
|
+
end
|
11
|
+
|
12
|
+
# Test exception handling for bogus response.
|
13
|
+
def test_bogus_response
|
14
|
+
aleph_record = Exlibris::Aleph::Record.new(@aleph_doc_library, @aleph_doc_number, @bogus_url)
|
15
|
+
assert_raise(RuntimeError) { aleph_record.bib }
|
16
|
+
assert_raise(RuntimeError) { aleph_record.holdings }
|
17
|
+
assert_raise(REXML::ParseException) { aleph_record.items }
|
18
|
+
end
|
19
|
+
|
20
|
+
# Test search for a single Primo document.
|
21
|
+
def test_record
|
22
|
+
aleph_record = Exlibris::Aleph::Record.new(@aleph_doc_library, @aleph_doc_number, @rest_url)
|
23
|
+
bib = aleph_record.bib
|
24
|
+
assert_nil(aleph_record.error, "Failure in #{aleph_record.class} while calling bib: #{aleph_record.error}")
|
25
|
+
holdings = aleph_record.holdings
|
26
|
+
assert_nil(aleph_record.error, "Failure in #{aleph_record.class} while calling holdings: #{aleph_record.error}")
|
27
|
+
items = aleph_record.items
|
28
|
+
assert_nil(aleph_record.error, "Failure in #{aleph_record.class} while calling items: #{aleph_record.error}")
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
# Example used for testing is from
|
4
|
+
# http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/rest-signature.html
|
5
|
+
# Although that example itself has some bugs as of 12 may 09 doh.
|
6
|
+
# it's output isn't actually valid.
|
7
|
+
#
|
8
|
+
class AwsProductSignTest < Test::Unit::TestCase
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@example_params = {
|
12
|
+
"Service" => "AWSECommerceService",
|
13
|
+
"Operation"=>"ItemLookup",
|
14
|
+
"ItemId"=>"0679722769",
|
15
|
+
"ResponseGroup"=>"ItemAttributes,Offers,Images,Reviews",
|
16
|
+
"Version" => "2009-01-06",
|
17
|
+
"Timestamp" => "2009-05-13T10:43:28-04:00" # fixed timestamp so we can test output
|
18
|
+
}
|
19
|
+
@access_key = "00000000000000000000"
|
20
|
+
@secret_key = "1234567890"
|
21
|
+
|
22
|
+
@test_obj = AwsProductSign.new(:secret_key => @secret_key, :access_key => @access_key)
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
def test_url_encoding
|
27
|
+
# Make sure it doesn't encode what it shouldn't.
|
28
|
+
reserved_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~"
|
29
|
+
assert_equal(reserved_chars,
|
30
|
+
@test_obj.url_encode(reserved_chars),
|
31
|
+
"Reserved chars are not encoded")
|
32
|
+
|
33
|
+
# Space better be %20 not plus.
|
34
|
+
assert_equal("%20", @test_obj.url_encode(" "), "Space is encoded as %20")
|
35
|
+
|
36
|
+
# Try a sample UTF-8 char, e acute.
|
37
|
+
assert_equal("%C3%A9",
|
38
|
+
@test_obj.url_encode("\xC3\xA9"),
|
39
|
+
"Encodes a UTF-8 char properly")
|
40
|
+
|
41
|
+
# Make sure it does escape a few other sample chars, although we won't
|
42
|
+
# try every possible char!
|
43
|
+
chars_to_escape = "%:,/+=" # that last one is a utf-8 e acute.
|
44
|
+
|
45
|
+
assert_equal( "%25%3A%2C%2F%2B%3D",
|
46
|
+
@test_obj.url_encode(chars_to_escape),
|
47
|
+
"Some other chars are encoded properly")
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_canonical_query_order
|
51
|
+
ordered_keys =
|
52
|
+
@test_obj.canonical_querystring(@example_params).split("&").collect { |kv| kv.split("=")[0] }
|
53
|
+
|
54
|
+
# should be sorted byte-ordered
|
55
|
+
assert_equal(ordered_keys,
|
56
|
+
["ItemId", "Operation", "ResponseGroup", "Service", "Timestamp", "Version"])
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_add_signature
|
60
|
+
new_params = @test_obj.add_signature( @example_params )
|
61
|
+
|
62
|
+
assert_not_nil( new_params["Timestamp"], "Adds timestamp" )
|
63
|
+
assert_equal( @access_key, new_params["AWSAccessKeyId"], "Adds access key")
|
64
|
+
assert_equal("F3xmBlY91rML36hkQTZn/N2Bk3ABIVB8NI+e/JCYpDQ=" ,
|
65
|
+
new_params["Signature"],
|
66
|
+
"Adds correct signature")
|
67
|
+
|
68
|
+
assert( @example_params != new_params, "Does not mutate input")
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_add_signature_mutate
|
72
|
+
params = Hash[@example_params]
|
73
|
+
|
74
|
+
@test_obj.add_signature!(params)
|
75
|
+
|
76
|
+
assert_not_nil( params["Signature"], "Mutates input")
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_query_string
|
81
|
+
require 'cgi'
|
82
|
+
params = @test_obj.add_signature(@example_params)
|
83
|
+
query_string = @test_obj.query_with_signature(params)
|
84
|
+
|
85
|
+
re_parsed = CGI.parse(query_string)
|
86
|
+
# cgi puts everything in an array, flatten it please.
|
87
|
+
re_parsed.each {|k,v| re_parsed[k] = v.first}
|
88
|
+
|
89
|
+
assert_equal( params, re_parsed, "query string generated" )
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class CollectionTest < ActiveSupport::TestCase
|
4
|
+
fixtures :requests, :referents, :referent_values, :sfx_urls
|
5
|
+
|
6
|
+
def setup
|
7
|
+
# Make something that looks like a session hash type thing, so we
|
8
|
+
# can init a collection with it.
|
9
|
+
@fake_session = Hash.new
|
10
|
+
class << @fake_session
|
11
|
+
def session_id ; "000001" ; end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def test_collection_instantiate
|
17
|
+
collection = Collection.new(requests(:simple_request) , @fake_session)
|
18
|
+
|
19
|
+
new_services = collection.instantiate_services!
|
20
|
+
assert_not_nil new_services
|
21
|
+
assert new_services.length > 0
|
22
|
+
new_services.each do |s|
|
23
|
+
assert_kind_of Service, s
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_instantiate_creates_new
|
28
|
+
collection = Collection.new(requests(:simple_request) , @fake_session)
|
29
|
+
|
30
|
+
s1 = collection.instantiate_services!
|
31
|
+
s2 = collection.instantiate_services!
|
32
|
+
|
33
|
+
assert_equal 0, (s1 & s2).length, "instantiate_services! must create new services each time, not re-use objects."
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_service_level
|
38
|
+
collection = Collection.new(requests(:simple_request) , @fake_session)
|
39
|
+
|
40
|
+
services = collection.instantiate_services!(:level => 'c')
|
41
|
+
|
42
|
+
assert services.find {|s| s.service_id == "UlrichsCover"}, "UlrichsCover not included in instantiate_services!(:level =>'c')"
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_requests_set
|
46
|
+
collection = Collection.new(requests(:simple_request) , @fake_session)
|
47
|
+
|
48
|
+
services = collection.instantiate_services!(:level => 'c')
|
49
|
+
|
50
|
+
services.each do |s|
|
51
|
+
assert_not_nil s.request, "umlaut request not set in service."
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_get_single_service
|
56
|
+
collection = Collection.new(requests(:simple_request) , @fake_session)
|
57
|
+
|
58
|
+
service = collection.instantiate_service!("UlrichsCover")
|
59
|
+
|
60
|
+
assert_not_nil service, "Service for UlrichsCover not returned"
|
61
|
+
assert_not_nil service.request, "Service for UlrichsCover does not have request set."
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_get_nonexisting_task
|
65
|
+
collection = Collection.new(requests(:simple_request) , @fake_session)
|
66
|
+
|
67
|
+
null_services = collection.instantiate_services!(:task => :no_such_task)
|
68
|
+
|
69
|
+
assert_equal [], null_services
|
70
|
+
|
71
|
+
null_services = collection.instantiate_services!(:task => :no_such_task, :level => 1)
|
72
|
+
|
73
|
+
assert_equal [], null_services
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
# tests for google book search service
|
2
|
+
# Only the the simplest of tests are done so far. To do more advanced tests,
|
3
|
+
# request fixtures for more cases should be created.
|
4
|
+
|
5
|
+
$:.unshift File.join(File.dirname(__FILE__),'..','lib')
|
6
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
7
|
+
|
8
|
+
require 'test/unit'
|
9
|
+
require 'rubygems'
|
10
|
+
|
11
|
+
#require 'lib/service'
|
12
|
+
#require 'lib/metadata_helper'
|
13
|
+
#require 'lib/service_adaptors/google_book_search'
|
14
|
+
|
15
|
+
require 'yaml'
|
16
|
+
|
17
|
+
class GoogleBookSearchTest < Test::Unit::TestCase
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
def setup
|
22
|
+
|
23
|
+
|
24
|
+
@gbs_default = ServiceList.instance.instantiate!("GoogleBookSearch", nil)
|
25
|
+
@gbs_minimum = GoogleBookSearch.new({"priority"=>1})
|
26
|
+
|
27
|
+
# Bunch of responses in the proper format somtimes followed by the hash that
|
28
|
+
# will result. The values here are not necessarily true/real.
|
29
|
+
# For instance the preview value is likely faked to test methods
|
30
|
+
# Only those currently used are uncommented.
|
31
|
+
@response_one = 'gbscallback({"ISBN:030905382X":{"bib_key":"ISBN:030905382X","info_url":"http://books.google.com/books?id=XiiYq5U1qEUC\x26source=gbs_ViewAPI","preview_url":"http://books.google.com/books?id=XiiYq5U1qEUC\x26printsec=frontcover\x26sig=9-7ypznOwL_rECoKJLizCBpodds\x26source=gbs_ViewAPI","thumbnail_url":"http://bks7.books.google.com/books?id=XiiYq5U1qEUC\x26pg=PP1\x26img=1\x26zoom=5\x26sig=2XmDi4HEhbqply9YjIsuopFQLAk","preview":"noview"}});'
|
32
|
+
#@one_full_view = 'gbscallback({"ISBN:1582183392":{"bib_key":"ISBN:1582183392","info_url":"http://books.google.com/books?id=bFGPoGrAXbwC\x26source=gbs_ViewAPI","preview_url":"http://books.google.com/books?id=bFGPoGrAXbwC\x26printsec=frontcover\x26sig=kYnPnuSmFdbm5rJfxNUN0_Qa3Zk\x26source=gbs_ViewAPI","thumbnail_url":"http://bks8.books.google.com/books?id=bFGPoGrAXbwC\x26pg=PP1\x26img=1\x26zoom=5\x26sig=bBu6nZ_q8k5uKZ43RrdBOElOCiA","preview":"full"}});'
|
33
|
+
#@one_partial_view = 'gbscallback({"ISBN:9780618680009":{"bib_key":"ISBN:9780618680009","info_url":"http://books.google.com/books?id=yq1xDpicghkC\x26source=gbs_ViewAPI","preview_url":"http://books.google.com/books?id=yq1xDpicghkC\x26printsec=frontcover\x26sig=wuZrXklCy_Duenlw3Ea0MTgIhYQ\x26source=gbs_ViewAPI","thumbnail_url":"http://bks8.books.google.com/books?id=yq1xDpicghkC\x26pg=PP1\x26img=1\x26zoom=5\x26sig=3sezA1j1-qzTTtI5E8PTdHJDkHw","preview":"partial"}});'
|
34
|
+
@response_three_duplicate_no_view = 'gbscallback({"ISBN:0393044548":{"bib_key":"ISBN:0393044548","info_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","preview_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","thumbnail_url":"http://bks3.books.google.com/books?id=E4R9AQAACAAJ\x26printsec=frontcover\x26img=1\x26zoom=5\x26sig=32ieZbDQYbQAeCNfW-vek8SfOxc","preview":"noview"},"OCLC:2985768":{"bib_key":"OCLC:2985768","info_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","preview_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","thumbnail_url":"http://bks4.books.google.com/books?id=E4R9AQAACAAJ\x26printsec=frontcover\x26img=1\x26zoom=5\x26sig=Z98qalA95yde4XY6VO-1ZF0tKlE","preview":"noview"},"LCCN:76030648":{"bib_key":"LCCN:76030648","info_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","preview_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","thumbnail_url":"http://bks5.books.google.com/books?id=E4R9AQAACAAJ\x26printsec=frontcover\x26img=1\x26zoom=5\x26sig=_qfxqS7dLZ7Oi48sFIBssQUbd4E","preview":"noview"}});'
|
35
|
+
@a_three_duplicate_no_view = [{
|
36
|
+
"info_url"=>
|
37
|
+
"http://books.google.com/books?id=E4R9AQAACAAJ&source=gbs_ViewAPI",
|
38
|
+
"preview_url"=>
|
39
|
+
"http://books.google.com/books?id=E4R9AQAACAAJ&source=gbs_ViewAPI",
|
40
|
+
"preview"=>"noview",
|
41
|
+
"bib_key"=>"ISBN:0393044548, OCLC:2985768, LCCN:76030648",
|
42
|
+
"thumbnail_url"=>
|
43
|
+
"http://bks3.books.google.com/books?id=E4R9AQAACAAJ&printsec=frontcover&img=1&zoom=5&sig=32ieZbDQYbQAeCNfW-vek8SfOxc"
|
44
|
+
}]
|
45
|
+
|
46
|
+
|
47
|
+
@data_frankenstein = Hpricot.XML("<?xml version=\"1.0\" encoding=\"UTF-8\"?><feed xmlns:gd=\"http://schemas.google.com/g/2005\" xmlns:dc=\"http://purl.org/dc/terms\" xmlns:gbs=\"http://schemas.google.com/books/2008\" xmlns:openSearch=\"http://a9.com/-/spec/opensearchrss/1.0/\" xmlns=\"http://www.w3.org/2005/Atom\"><id>http://www.google.com/books/feeds/volumes</id><updated>2009-04-29T22:02:42.000Z</updated><category term=\"http://schemas.google.com/books/2008#volume\" scheme=\"http://schemas.google.com/g/2005#kind\"></category><title type=\"text\">Search results for ISBN9780393964585 OR OCLC33045872</title><link href=\"http://www.google.com\" rel=\"alternate\" type=\"text/html\" /><link href=\"http://www.google.com/books/feeds/volumes\" rel=\"http://schemas.google.com/g/2005#feed\" type=\"application/atom+xml\" /><link href=\"http://www.google.com/books/feeds/volumes?q=ISBN9780393964585+OR+OCLC33045872\" rel=\"self\" type=\"application/atom+xml\" /><author><name>Google Books Search</name><uri>http://www.google.com</uri></author><generator version=\"beta\">Google Book Search data API</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>20</openSearch:itemsPerPage><entry><id>http://www.google.com/books/feeds/volumes/92EbHgAACAAJ</id><updated>2009-04-29T22:02:42.000Z</updated><category term=\"http://schemas.google.com/books/2008#volume\" scheme=\"http://schemas.google.com/g/2005#kind\"></category><title type=\"text\">Frankenstein</title><link href=\"http://bks5.books.google.com/books?id=92EbHgAACAAJ&printsec=frontcover&img=1&zoom=5&sig=ACfU3U10W3ycsrdiB-udzUYGnYtkVIp5tQ&source=gbs_gdata\" rel=\"http://schemas.google.com/books/2008/thumbnail\" type=\"image/x-unknown\" /><link href=\"http://books.google.com/books?id=92EbHgAACAAJ&dq=ISBN9780393964585+OR+OCLC33045872&ie=ISO-8859-1&source=gbs_gdata\" rel=\"http://schemas.google.com/books/2008/info\" type=\"text/html\" /><link href=\"http://books.google.com/books?id=92EbHgAACAAJ&dq=ISBN9780393964585+OR+OCLC33045872&ie=ISO-8859-1&source=gbs_gdata\" rel=\"http://schemas.google.com/books/2008/preview\" type=\"text/html\" /><link href=\"http://www.google.com/books/feeds/users/me/volumes\" rel=\"http://schemas.google.com/books/2008/annotation\" type=\"application/atom+xml\" /><link href=\"http://books.google.com/books?id=92EbHgAACAAJ&dq=ISBN9780393964585+OR+OCLC33045872&ie=ISO-8859-1\" rel=\"alternate\" type=\"text/html\" /><link href=\"http://www.google.com/books/feeds/volumes/92EbHgAACAAJ\" rel=\"self\" type=\"application/atom+xml\" /><gbs:embeddability value=\"http://schemas.google.com/books/2008#not_embeddable\"></gbs:embeddability><gbs:openAccess value=\"http://schemas.google.com/books/2008#disabled\"></gbs:openAccess><gbs:viewability value=\"http://schemas.google.com/books/2008#view_no_pages\"></gbs:viewability><dc:creator>Mary Wollstonecraft Shelley</dc:creator><dc:creator>J. Paul Hunter</dc:creator><dc:date>1996-02-23</dc:date><dc:description>... ISBN9780393964585 9780393964585 LCCN95037928 OXFORD503855446 \r\nBIBoxford_UkOxUb11900853 BIBloc_95037928 OCLC78250571 OCLC33045872 ...</dc:description><dc:format>339 pages</dc:format><dc:identifier>92EbHgAACAAJ</dc:identifier><dc:identifier>ISBN:0393964582</dc:identifier><dc:identifier>ISBN:9780393964585</dc:identifier><dc:publisher>W. W. Norton & Company</dc:publisher><dc:subject>Juvenile Fiction</dc:subject><dc:title>Frankenstein</dc:title><dc:title>The 1818 Text, Contexts, Nineteenth-century Responses, Modern Criticism</dc:title></entry></feed>")
|
48
|
+
|
49
|
+
#@one_fake_full_fake_partial = 'gbscallback({"ISBN:0393044548":{"bib_key":"ISBN:0393044548","info_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","preview_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","thumbnail_url":"http://bks3.books.google.com/books?id=E4R9AQAACAAJ\x26printsec=frontcover\x26img=1\x26zoom=5\x26sig=32ieZbDQYbQAeCNfW-vek8SfOxc","preview":"full"},"OCLC:2985768":{"bib_key":"OCLC:2985768","info_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","preview_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","thumbnail_url":"http://bks4.books.google.com/books?id=E4R9AQAACAAJ\x26printsec=frontcover\x26img=1\x26zoom=5\x26sig=Z98qalA95yde4XY6VO-1ZF0tKlE","preview":"noview"},"LCCN:76030648":{"bib_key":"LCCN:76030648","info_url":"http://books.google.com/books?id=E4R9AQAACAAJx\x26source=gbs_ViewAPI","preview_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","thumbnail_url":"http://bks5.books.google.com/books?id=E4R9AQAACAAJ\x26printsec=frontcover\x26img=1\x26zoom=5\x26sig=_qfxqS7dLZ7Oi48sFIBssQUbd4E","preview":"partial"}});'
|
50
|
+
#@two_fake_full = 'gbscallback({"ISBN:0393044548":{"bib_key":"ISBN:0393044548","info_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","preview_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","thumbnail_url":"http://bks3.books.google.com/books?id=E4R9AQAACAAJ\x26printsec=frontcover\x26img=1\x26zoom=5\x26sig=32ieZbDQYbQAeCNfW-vek8SfOxc","preview":"full"},"OCLC:2985768":{"bib_key":"OCLC:2985768","info_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","preview_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","thumbnail_url":"http://bks4.books.google.com/books?id=E4R9AQAACAAJ\x26printsec=frontcover\x26img=1\x26zoom=5\x26sig=Z98qalA95yde4XY6VO-1ZF0tKlE","preview":"noview"},"LCCN:76030648":{"bib_key":"LCCN:76030648","info_url":"http://books.google.com/books?id=E4R9AQAACAAJx\x26source=gbs_ViewAPI","preview_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","thumbnail_url":"http://bks5.books.google.com/books?id=E4R9AQAACAAJ\x26printsec=frontcover\x26img=1\x26zoom=5\x26sig=_qfxqS7dLZ7Oi48sFIBssQUbd4E","preview":"full"}});'
|
51
|
+
#@one_fake_full_one_fake_noview = 'gbscallback({"ISBN:0393044548":{"bib_key":"ISBN:0393044548","info_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","preview_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","thumbnail_url":"http://bks3.books.google.com/books?id=E4R9AQAACAAJ\x26printsec=frontcover\x26img=1\x26zoom=5\x26sig=32ieZbDQYbQAeCNfW-vek8SfOxc","preview":"full"},"OCLC:2985768":{"bib_key":"OCLC:2985768","info_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","preview_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","thumbnail_url":"http://bks4.books.google.com/books?id=E4R9AQAACAAJ\x26printsec=frontcover\x26img=1\x26zoom=5\x26sig=Z98qalA95yde4XY6VO-1ZF0tKlE","preview":"noview"},"LCCN:76030648":{"bib_key":"LCCN:76030648","info_url":"http://books.google.com/books?id=E4R9AQAACAAJx\x26source=gbs_ViewAPI","preview_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","thumbnail_url":"http://bks5.books.google.com/books?id=E4R9AQAACAAJ\x26printsec=frontcover\x26img=1\x26zoom=5\x26sig=_qfxqS7dLZ7Oi48sFIBssQUbd4E","preview":"noview"}});'
|
52
|
+
#@one_fake_partial_one_fake_noview = 'gbscallback({"ISBN:0393044548":{"bib_key":"ISBN:0393044548","info_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","preview_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","thumbnail_url":"http://bks3.books.google.com/books?id=E4R9AQAACAAJ\x26printsec=frontcover\x26img=1\x26zoom=5\x26sig=32ieZbDQYbQAeCNfW-vek8SfOxc","preview":"partial"},"OCLC:2985768":{"bib_key":"OCLC:2985768","info_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","preview_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","thumbnail_url":"http://bks4.books.google.com/books?id=E4R9AQAACAAJ\x26printsec=frontcover\x26img=1\x26zoom=5\x26sig=Z98qalA95yde4XY6VO-1ZF0tKlE","preview":"noview"},"LCCN:76030648":{"bib_key":"LCCN:76030648","info_url":"http://books.google.com/books?id=E4R9AQAACAAJx\x26source=gbs_ViewAPI","preview_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","thumbnail_url":"http://bks5.books.google.com/books?id=E4R9AQAACAAJ\x26printsec=frontcover\x26img=1\x26zoom=5\x26sig=_qfxqS7dLZ7Oi48sFIBssQUbd4E","preview":"noview"}});'
|
53
|
+
#@two_no_view_one_fake_partial = 'gbscallback({"ISBN:0393044548":{"bib_key":"ISBN:0393044548","info_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","preview_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","thumbnail_url":"http://bks3.books.google.com/books?id=E4R9AQAACAAJ\x26printsec=frontcover\x26img=1\x26zoom=5\x26sig=32ieZbDQYbQAeCNfW-vek8SfOxc","preview":"noview"},"OCLC:2985768":{"bib_key":"OCLC:2985768","info_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","preview_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","thumbnail_url":"http://bks4.books.google.com/books?id=E4R9AQAACAAJ\x26printsec=frontcover\x26img=1\x26zoom=5\x26sig=Z98qalA95yde4XY6VO-1ZF0tKlE","preview":"noview"},"LCCN:76030648":{"bib_key":"LCCN:76030648","info_url":"http://books.google.com/books?id=E4R9AQAACAAJx\x26source=gbs_ViewAPI","preview_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","thumbnail_url":"http://bks5.books.google.com/books?id=E4R9AQAACAAJ\x26printsec=frontcover\x26img=1\x26zoom=5\x26sig=_qfxqS7dLZ7Oi48sFIBssQUbd4E","preview":"partial"}});'
|
54
|
+
#@two_full_one_fake_partial = 'gbscallback({"ISBN:0393044548":{"bib_key":"ISBN:0393044548","info_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","preview_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","thumbnail_url":"http://bks3.books.google.com/books?id=E4R9AQAACAAJ\x26printsec=frontcover\x26img=1\x26zoom=5\x26sig=32ieZbDQYbQAeCNfW-vek8SfOxc","preview":"full"},"OCLC:2985768":{"bib_key":"OCLC:2985768","info_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","preview_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","thumbnail_url":"http://bks4.books.google.com/books?id=E4R9AQAACAAJ\x26printsec=frontcover\x26img=1\x26zoom=5\x26sig=Z98qalA95yde4XY6VO-1ZF0tKlE","preview":"full"},"LCCN:76030648":{"bib_key":"LCCN:76030648","info_url":"http://books.google.com/books?id=E4R9AQAACAAJx\x26source=gbs_ViewAPI","preview_url":"http://books.google.com/books?id=E4R9AQAACAAJ\x26source=gbs_ViewAPI","thumbnail_url":"http://bks5.books.google.com/books?id=E4R9AQAACAAJ\x26printsec=frontcover\x26img=1\x26zoom=5\x26sig=_qfxqS7dLZ7Oi48sFIBssQUbd4E","preview":"partial"}});'
|
55
|
+
#@one_partial_view = 'gbscallback({"ISBN:030905382X":{"bib_key":"ISBN:030905382X","info_url":"http://books.google.com/books?id=XiiYq5U1qEUC\x26source=gbs_ViewAPI","preview_url":"http://books.google.com/books?id=XiiYq5U1qEUC\x26printsec=frontcover\x26sig=9-7ypznOwL_rECoKJLizCBpodds\x26source=gbs_ViewAPI","thumbnail_url":"http://bks7.books.google.com/books?id=XiiYq5U1qEUC\x26pg=PP1\x26img=1\x26zoom=5\x26sig=2XmDi4HEhbqply9YjIsuopFQLAk","preview":"partial"}});'
|
56
|
+
#@one_fake_noview = 'gbscallback({"ISBN:030905382X":{"bib_key":"ISBN:030905382X","info_url":"http://books.google.com/books?id=XiiYq5U1qEUC\x26source=gbs_ViewAPI","preview_url":"http://books.google.com/books?id=XiiYq5U1qEUC\x26printsec=frontcover\x26sig=9-7ypznOwL_rECoKJLizCBpodds\x26source=gbs_ViewAPI","thumbnail_url":"http://bks7.books.google.com/books?id=XiiYq5U1qEUC\x26pg=PP1\x26img=1\x26zoom=5\x26sig=2XmDi4HEhbqply9YjIsuopFQLAk","preview":"noview"}});'
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
def test_initialize_minimum
|
62
|
+
gbs = GoogleBookSearch.new({"priority"=>1})
|
63
|
+
assert_equal(1, gbs.priority)
|
64
|
+
assert_equal('Google Book Search', gbs.display_name)
|
65
|
+
assert_equal(1, gbs.num_full_views)
|
66
|
+
assert_equal(1, gbs.priority)
|
67
|
+
assert_equal('standard', gbs.task)
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_get_bibkeys
|
71
|
+
f = referents(:frankenstein)
|
72
|
+
keys = @gbs_default.get_bibkeys(f)
|
73
|
+
expected = CGI.escape('ISBN9780393964585 OR OCLC33045872')
|
74
|
+
assert_equal(expected, keys)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Actually a live test of GBS server, not great, but oh well.
|
78
|
+
# This doesn't check much of the response, but just enough to know we got
|
79
|
+
# something back. The server for the thumbnail changes, so we can't do a
|
80
|
+
# simple match and a huge regexp was making my head hurt.
|
81
|
+
def test_do_query
|
82
|
+
hpricot_response = @gbs_default.do_query('OCLC02364071', requests(:frankenstein))
|
83
|
+
|
84
|
+
assert hpricot_response.at("dc:identifier")
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
def test_create_fulltext_service_response_nil
|
89
|
+
request = requests(:frankenstein)
|
90
|
+
fulltext_shown = @gbs_default.create_fulltext_service_response(request,
|
91
|
+
@data_frankenstein)
|
92
|
+
assert_nil(fulltext_shown)
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_find_thumbnail_url
|
96
|
+
|
97
|
+
url = @gbs_default.find_thumbnail_url(@data_frankenstein)
|
98
|
+
assert_not_nil url
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
@@ -0,0 +1,403 @@
|
|
1
|
+
require "benchmark"
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
4
|
+
class PrimoSearcherTest < ActiveSupport::TestCase
|
5
|
+
def setup
|
6
|
+
@primo_definition = YAML.load( %{
|
7
|
+
type: PrimoService
|
8
|
+
priority: 2 # After SFX, to get SFX metadata enhancement
|
9
|
+
status: active
|
10
|
+
base_url: http://bobcatdev.library.nyu.edu
|
11
|
+
vid: NYU
|
12
|
+
institution: NYU
|
13
|
+
holding_search_institution: NYU
|
14
|
+
holding_search_text: Search for this title in BobCat.
|
15
|
+
suppress_holdings: [ !ruby/regexp '/\$\$LBWEB/', !ruby/regexp '/\$\$LNWEB/', !ruby/regexp '/\$\$LTWEB/', !ruby/regexp '/\$\$LWEB/', !ruby/regexp '/\$\$1Restricted Internet Resources/' ]
|
16
|
+
ez_proxy: !ruby/regexp '/https\:\/\/ezproxy\.library\.nyu\.edu\/login\?url=/'
|
17
|
+
service_types:
|
18
|
+
- primo_source
|
19
|
+
- holding_search
|
20
|
+
- fulltext
|
21
|
+
- table_of_contents
|
22
|
+
- referent_enhance
|
23
|
+
- cover_image
|
24
|
+
})
|
25
|
+
|
26
|
+
@base_url = @primo_definition["base_url"]
|
27
|
+
@vid = @primo_definition["vid"]
|
28
|
+
@primo_holdings_doc_id = "nyu_aleph000062856"
|
29
|
+
@primo_rsrcs_doc_id = "nyu_aleph002895625"
|
30
|
+
@primo_tocs_doc_id = "nyu_aleph003149772"
|
31
|
+
@primo_dedupmrg_doc_id = "dedupmrg17343091"
|
32
|
+
@primo_test_checked_out_doc_id = "nyu_aleph000089771"
|
33
|
+
@primo_test_offsite_doc_id = "nyu_aleph002169696"
|
34
|
+
@primo_test_ill_doc_id = "nyu_aleph001502625"
|
35
|
+
@primo_test_diacritics1_doc_id = "nyu_aleph002975583"
|
36
|
+
@primo_test_diacritics2_doc_id = "nyu_aleph003205339"
|
37
|
+
@primo_test_diacritics3_doc_id = "nyu_aleph003365921"
|
38
|
+
@primo_test_journals1_doc_id = "nyu_aleph002895625"
|
39
|
+
@primo_invalid_doc_id = "thisIsNotAValidDocId"
|
40
|
+
@primo_test_problem_doc_id = "nyu_aleph000509288"
|
41
|
+
@primo_test_bug1361_id = "ebrroutebr10416506"
|
42
|
+
@primo_test_isbn = "0143039008"
|
43
|
+
@primo_test_title = "Travels with My Aunt"
|
44
|
+
@primo_test_author = "Graham Greene"
|
45
|
+
@primo_test_genre = "Book"
|
46
|
+
@primo_config = YAML.load_file("#{Rails.root}/config/umlaut_config/primo.yml")
|
47
|
+
@searcher_setup = {
|
48
|
+
:base_url => @base_url,
|
49
|
+
:vid => @vid,
|
50
|
+
:config => @primo_config
|
51
|
+
}
|
52
|
+
aleph_helper = Exlibris::Aleph::Config::Helper.instance()
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_primo_searcher_benchmarks
|
56
|
+
Benchmark.bmbm do |results|
|
57
|
+
results.report("Primo Searcher:") {
|
58
|
+
(1..10).each {
|
59
|
+
searcher = Exlibris::Primo::Searcher.new(@searcher_setup, {:primo_id => @primo_holdings_doc_id})
|
60
|
+
}
|
61
|
+
}
|
62
|
+
searcher = Exlibris::Primo::Searcher.new(@searcher_setup, {:primo_id => @primo_holdings_doc_id})
|
63
|
+
results.report("Searcher#process_record") {
|
64
|
+
(1..10).each {
|
65
|
+
searcher.send(:process_record)
|
66
|
+
}
|
67
|
+
}
|
68
|
+
results.report("Searcher#process_search_results") {
|
69
|
+
(1..10).each {
|
70
|
+
searcher.send(:process_search_results)
|
71
|
+
}
|
72
|
+
}
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# Test search for a single Primo document.
|
77
|
+
def test_search_by_doc_id
|
78
|
+
searcher = Exlibris::Primo::Searcher.new(@searcher_setup, {:primo_id => @primo_holdings_doc_id})
|
79
|
+
assert_not_nil(searcher, "#{searcher.class} returned nil when instantiated.")
|
80
|
+
search_results = searcher.response
|
81
|
+
assert_instance_of(Hpricot::Doc, search_results, "#{searcher.class} search result is an unexpected object: #{search_results.class}")
|
82
|
+
assert_equal(@primo_holdings_doc_id, search_results.at("//control/recordid").inner_text, "#{searcher.class} returned an unexpected record: #{search_results.to_original_html}")
|
83
|
+
assert(searcher.count.to_i > 0, "#{searcher.class} returned 0 results for doc id: #{@primo_holdings_doc_id}.")
|
84
|
+
end
|
85
|
+
|
86
|
+
# Test search for a Primo problem record
|
87
|
+
def test_search_by_genre_discrepancy
|
88
|
+
searcher = Exlibris::Primo::Searcher.new(@searcher_setup, {:primo_id => @primo_test_problem_doc_id})
|
89
|
+
assert_not_nil(searcher, "#{searcher.class} returned nil when instantiated.")
|
90
|
+
search_results = searcher.response
|
91
|
+
assert_instance_of(Hpricot::Doc, search_results, "#{searcher.class} search result is an unexpected object: #{search_results.class}")
|
92
|
+
assert_equal(@primo_test_problem_doc_id, search_results.at("//control/recordid").inner_text, "#{searcher.class} returned an unexpected record: #{search_results.to_original_html}")
|
93
|
+
assert(searcher.count.to_i > 0, "#{searcher.class} returned 0 results for doc id: #{@primo_test_problem_doc_id}.")
|
94
|
+
assert_equal(1, searcher.holdings.length, "#{searcher.class} returned unexpected holdings")
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_search_by_bug1361
|
98
|
+
searcher = Exlibris::Primo::Searcher.new(@searcher_setup, {:primo_id => @primo_test_bug1361_id})
|
99
|
+
assert_not_nil(searcher, "#{searcher.class} returned nil when instantiated.")
|
100
|
+
search_results = searcher.response
|
101
|
+
assert_instance_of(Hpricot::Doc, search_results, "#{searcher.class} search result is an unexpected object: #{search_results.class}")
|
102
|
+
assert_equal(@primo_test_bug1361_id, search_results.at("//control/recordid").inner_text, "#{searcher.class} returned an unexpected record: #{search_results.to_original_html}")
|
103
|
+
assert(searcher.count.to_i > 0, "#{searcher.class} returned 0 results for doc id: #{@primo_test_bug1361_id}.")
|
104
|
+
assert_equal(0, searcher.holdings.length, "#{searcher.class} returned unexpected holdings")
|
105
|
+
assert_equal(4, searcher.rsrcs.length, "#{searcher.class} returned unexpected rsrcs")
|
106
|
+
end
|
107
|
+
|
108
|
+
# Test search for an invalid Primo document.
|
109
|
+
def test_search_by_invalid_doc_id
|
110
|
+
assert_raise(RuntimeError) {
|
111
|
+
searcher = Exlibris::Primo::Searcher.new(@searcher_setup, {:primo_id => @primo_invalid_doc_id})
|
112
|
+
}
|
113
|
+
end
|
114
|
+
|
115
|
+
# Test invalid setup.
|
116
|
+
def test_search_by_invalid_setup1
|
117
|
+
assert_raise(RuntimeError) {
|
118
|
+
searcher = Exlibris::Primo::Searcher.new({}, {:primo_id => @primo_invalid_doc_id})
|
119
|
+
}
|
120
|
+
end
|
121
|
+
|
122
|
+
# Test invalid setup.
|
123
|
+
def test_search_by_invalid_setup2
|
124
|
+
assert_raise(RuntimeError) {
|
125
|
+
searcher = Exlibris::Primo::Searcher.new({:base_url => @base_url, :config => nil}, {:primo_id => @primo_invalid_doc_id})
|
126
|
+
}
|
127
|
+
end
|
128
|
+
|
129
|
+
# Test base setup search for a single Primo document.
|
130
|
+
def test_search_base_setup_record_id
|
131
|
+
searcher = Exlibris::Primo::Searcher.new({:base_url => @base_url}, {:primo_id => @primo_holdings_doc_id})
|
132
|
+
holdings = searcher.holdings
|
133
|
+
assert_instance_of(Array, holdings, "#{searcher.class} holdings is an unexpected object: #{holdings.class}")
|
134
|
+
assert(holdings.count > 0, "#{searcher.class} returned 0 holdings for doc id: #{@primo_holdings_doc_id}.")
|
135
|
+
first_holding = holdings.first
|
136
|
+
assert_instance_of(Exlibris::Primo::Holding, first_holding, "#{searcher.class} first holding is an unexpected object: #{first_holding.class}")
|
137
|
+
assert_equal("check_holdings", first_holding.status, "#{searcher.class} first holding has an unexpected status: #{first_holding.status}")
|
138
|
+
assert_equal("NYU", first_holding.institution, "#{searcher.class} first holding has an unexpected institution: #{first_holding.institution}")
|
139
|
+
assert_equal("BOBST", first_holding.library, "#{searcher.class} first holding has an unexpected library: #{first_holding.library}")
|
140
|
+
assert_equal("Main Collection", first_holding.collection, "#{searcher.class} first holding has an unexpected collection: #{first_holding.collection}")
|
141
|
+
assert_equal("(PR6013.R44 T7 2004 )", first_holding.call_number, "#{searcher.class} first holding has an unexpected call number: #{first_holding.call_number}")
|
142
|
+
end
|
143
|
+
|
144
|
+
# Test search by isbn.
|
145
|
+
def test_search_by_isbn
|
146
|
+
searcher = Exlibris::Primo::Searcher.new(@searcher_setup, {:isbn => @primo_test_isbn})
|
147
|
+
assert_not_nil(searcher, "#{searcher.class} returned nil when instantiated.")
|
148
|
+
search_results = searcher.response
|
149
|
+
assert_instance_of(Hpricot::Doc, search_results, "#{searcher.class} search result is an unexpected object: #{search_results.class}")
|
150
|
+
search_results.search("//search/isbn") do |isbn|
|
151
|
+
assert_not_nil(isbn.inner_text.match(@primo_test_isbn), "#{searcher.class} returned an unexpected record: #{search_results.to_original_html}")
|
152
|
+
end
|
153
|
+
assert(searcher.count.to_i > 0, "#{searcher.class} returned 0 results for ISBN: #{@primo_test_isbn}.")
|
154
|
+
end
|
155
|
+
|
156
|
+
# Test search by isbn.
|
157
|
+
def test_search_by_issn
|
158
|
+
searcher = Exlibris::Primo::Searcher.new({:base_url => "http://bobcatdev.library.nyu.edu", :vid => "NYU"}, {:issn => "0002-8614"})
|
159
|
+
assert_not_nil(searcher, "#{searcher.class} returned nil when instantiated.")
|
160
|
+
search_results = searcher.response
|
161
|
+
assert_instance_of(Hpricot::Doc, search_results, "#{searcher.class} search result is an unexpected object: #{search_results.class}")
|
162
|
+
search_results.search("//search/issn") do |isbn|
|
163
|
+
assert_not_nil(isbn.inner_text.match("0002-8614"), "#{searcher.class} returned an unexpected record: #{search_results.to_original_html}")
|
164
|
+
end
|
165
|
+
assert(searcher.count.to_i > 0, "#{searcher.class} returned 0 results for ISSN: 0002-8614.")
|
166
|
+
end
|
167
|
+
|
168
|
+
# Test search by title/author/genre.
|
169
|
+
def test_search_by_title_author_genre
|
170
|
+
searcher = Exlibris::Primo::Searcher.new(@searcher_setup, {:title => @primo_test_title, :author => @primo_test_author, :genre => @primo_test_genre})
|
171
|
+
assert_not_nil(searcher, "#{searcher.class} returned nil when instantiated.")
|
172
|
+
search_results = searcher.response
|
173
|
+
assert_instance_of(Hpricot::Doc, search_results, "#{searcher.class} search result is an unexpected object: #{search_results.class}")
|
174
|
+
search_results.search("//search/title") do |title|
|
175
|
+
assert_not_nil(title.inner_text.downcase.match(@primo_test_title.downcase), "#{searcher.class} returned an unexpected record: #{search_results.to_original_html}")
|
176
|
+
end
|
177
|
+
assert(searcher.count.to_i > 0, "#{searcher.class} returned 0 results for Title: #{@primo_test_title}.")
|
178
|
+
end
|
179
|
+
|
180
|
+
# Test search for a single Primo document w/ holdings.
|
181
|
+
def test_holdings
|
182
|
+
searcher = Exlibris::Primo::Searcher.new(@searcher_setup, {:primo_id => @primo_holdings_doc_id})
|
183
|
+
holdings = searcher.holdings
|
184
|
+
assert_instance_of(Array, holdings,
|
185
|
+
"#{searcher.class} holdings is an unexpected object: #{holdings.class}")
|
186
|
+
assert_equal(1, holdings.count,
|
187
|
+
"#{searcher.class} returned 0 holdings for doc id: #{@primo_holdings_doc_id}.")
|
188
|
+
first_holding = holdings.first
|
189
|
+
assert_instance_of(
|
190
|
+
Exlibris::Primo::Holding,
|
191
|
+
first_holding,
|
192
|
+
"#{searcher.class} first holding is an unexpected object: #{first_holding.class}")
|
193
|
+
test_data = {
|
194
|
+
:record_id => "nyu_aleph000062856",
|
195
|
+
:source_id => "nyu_aleph",
|
196
|
+
:original_source_id => "NYU01",
|
197
|
+
:source_record_id => "000062856",
|
198
|
+
:institution_code => "NYU",
|
199
|
+
:institution => "NYU",
|
200
|
+
:library_code => "BOBST",
|
201
|
+
:library => "NYU Bobst",
|
202
|
+
:status_code => "check_holdings",
|
203
|
+
:status => "Check Availability",
|
204
|
+
:id_one => "Main Collection",
|
205
|
+
:id_two => "(PR6013.R44 T7 2004 )",
|
206
|
+
:collection => "Main Collection",
|
207
|
+
:call_number => "(PR6013.R44 T7 2004 )",
|
208
|
+
:origin => nil,
|
209
|
+
:display_type => "book",
|
210
|
+
:coverage => [],
|
211
|
+
:notes => "",
|
212
|
+
:url => "#{@base_url}/primo_library/libweb/action/dlDisplay.do?docId=nyu_aleph000062856&institution=NYU&vid=#{@vid}",
|
213
|
+
:request_url => nil,
|
214
|
+
:match_reliability => ServiceResponse::MatchExact,
|
215
|
+
:request_link_supports_ajax_call => false }
|
216
|
+
test_data.each { |key, value|
|
217
|
+
assert_equal(
|
218
|
+
value,
|
219
|
+
first_holding.send(key),
|
220
|
+
"#{searcher.class} first holding has an unexpected #{key}: #{first_holding.send(key)}")
|
221
|
+
}
|
222
|
+
end
|
223
|
+
|
224
|
+
|
225
|
+
# Test search for a single Primo document w/ rsrcs.
|
226
|
+
def test_rsrcs
|
227
|
+
searcher = Exlibris::Primo::Searcher.new(
|
228
|
+
@searcher_setup,
|
229
|
+
{ :primo_id => @primo_rsrcs_doc_id })
|
230
|
+
rsrcs = searcher.rsrcs
|
231
|
+
assert_instance_of(Array, rsrcs,
|
232
|
+
"#{searcher.class} rsrcs is an unexpected object: #{rsrcs.class}")
|
233
|
+
assert_equal(2, rsrcs.count,
|
234
|
+
"#{searcher.class} returned an unexpected amount of rsrcs (#{rsrcs.count}) for doc id: #{@primo_rsrcs_doc_id}.")
|
235
|
+
first_rsrc = rsrcs.first
|
236
|
+
assert_instance_of(
|
237
|
+
Exlibris::Primo::Rsrc,
|
238
|
+
first_rsrc,
|
239
|
+
"#{searcher.class} first rsrc is an unexpected object: #{first_rsrc.class}")
|
240
|
+
test_data = {
|
241
|
+
:record_id => "nyu_aleph002895625",
|
242
|
+
:v => nil,
|
243
|
+
:url => "http://ezproxy.library.nyu.edu:2048/login?url=http://mq.oxfordjournals.org/",
|
244
|
+
:display => "Online Version",
|
245
|
+
:institution_code => "NYU",
|
246
|
+
:origin => nil,
|
247
|
+
:notes => "" }
|
248
|
+
test_data.each { |key, value|
|
249
|
+
assert_equal(
|
250
|
+
value,
|
251
|
+
first_rsrc.send(key),
|
252
|
+
"#{searcher.class} first rsrc has an unexpected #{key}: #{first_rsrc.send(key)}")
|
253
|
+
}
|
254
|
+
end
|
255
|
+
|
256
|
+
# Test search for a single Primo document w/ tocs.
|
257
|
+
def test_tocs
|
258
|
+
searcher = Exlibris::Primo::Searcher.new(
|
259
|
+
@searcher_setup,
|
260
|
+
{ :primo_id => @primo_tocs_doc_id })
|
261
|
+
tocs = searcher.tocs
|
262
|
+
assert_instance_of(Array, tocs,
|
263
|
+
"#{searcher.class} tocs is an unexpected object: #{tocs.class}")
|
264
|
+
assert_equal(1, tocs.count,
|
265
|
+
"#{searcher.class} returned an unexpected amount of tocs (#{tocs.count}) for doc id: #{@primo_tocs_doc_id}.")
|
266
|
+
first_toc = tocs.last
|
267
|
+
assert_instance_of(
|
268
|
+
Exlibris::Primo::Toc,
|
269
|
+
first_toc,
|
270
|
+
"#{searcher.class} first toc is an unexpected object: #{first_toc.class}")
|
271
|
+
test_data = {
|
272
|
+
:record_id => "nyu_aleph003149772",
|
273
|
+
:url => "http://www.loc.gov/catdir/toc/onix07/2001024342.html",
|
274
|
+
:display => "Table of Contents",
|
275
|
+
:notes => "" }
|
276
|
+
test_data.each { |key, value|
|
277
|
+
assert_equal(
|
278
|
+
value,
|
279
|
+
first_toc.send(key),
|
280
|
+
"#{searcher.class} first toc has an unexpected #{key}: #{first_toc.send(key)}")
|
281
|
+
}
|
282
|
+
end
|
283
|
+
|
284
|
+
def test_dedupmrg
|
285
|
+
searcher = Exlibris::Primo::Searcher.new(
|
286
|
+
@searcher_setup,
|
287
|
+
{ :primo_id => @primo_dedupmrg_doc_id })
|
288
|
+
holdings = searcher.holdings
|
289
|
+
assert_instance_of(Array, holdings,
|
290
|
+
"#{searcher.class} holdings is an unexpected object: #{holdings.class}")
|
291
|
+
assert_equal(7, holdings.count,
|
292
|
+
"#{searcher.class} returned 0 holdings for doc id: #{@primo_dedupmrg_doc_id}.")
|
293
|
+
first_holding = holdings.first
|
294
|
+
assert_instance_of(
|
295
|
+
Exlibris::Primo::Holding,
|
296
|
+
first_holding,
|
297
|
+
"#{searcher.class} first holding is an unexpected object: #{first_holding.class}")
|
298
|
+
test_data = {
|
299
|
+
:record_id => "dedupmrg17343091",
|
300
|
+
:source_id => "nyu_aleph",
|
301
|
+
:original_source_id => "NYU01",
|
302
|
+
:source_record_id => "000932393",
|
303
|
+
:institution_code => "NYU",
|
304
|
+
:institution => "NYU",
|
305
|
+
:library_code => "BWEB",
|
306
|
+
:library => "NYU Restricted Internet",
|
307
|
+
:status_code => "check_holdings",
|
308
|
+
:status => "Check Availability",
|
309
|
+
:id_one => "Internet Resources",
|
310
|
+
:id_two => "(Newspaper Electronic access )",
|
311
|
+
:collection => "Internet Resources",
|
312
|
+
:call_number => "(Newspaper Electronic access )",
|
313
|
+
:origin => "nyu_aleph000932393",
|
314
|
+
:display_type => "journal",
|
315
|
+
:coverage => [],
|
316
|
+
:notes => "",
|
317
|
+
:url => "#{@base_url}/primo_library/libweb/action/dlDisplay.do?docId=dedupmrg17343091&institution=NYU&vid=#{@vid}",
|
318
|
+
:request_url => nil,
|
319
|
+
:match_reliability => ServiceResponse::MatchExact,
|
320
|
+
:request_link_supports_ajax_call => false }
|
321
|
+
test_data.each { |key, value|
|
322
|
+
assert_equal(
|
323
|
+
value,
|
324
|
+
first_holding.send(key),
|
325
|
+
"#{searcher.class} first holding has an unexpected #{key}: #{first_holding.send(key)}")
|
326
|
+
}
|
327
|
+
rsrcs = searcher.rsrcs
|
328
|
+
assert_instance_of(Array, rsrcs,
|
329
|
+
"#{searcher.class} rsrcs is an unexpected object: #{rsrcs.class}")
|
330
|
+
assert_equal(8, rsrcs.count,
|
331
|
+
"#{searcher.class} returned an unexpected amount of rsrcs (#{rsrcs.count}) for doc id: #{@primo_rsrcs_doc_id}.")
|
332
|
+
first_rsrc = rsrcs.first
|
333
|
+
assert_instance_of(
|
334
|
+
Exlibris::Primo::Rsrc,
|
335
|
+
first_rsrc,
|
336
|
+
"#{searcher.class} first rsrc is an unexpected object: #{first_rsrc.class}")
|
337
|
+
test_data = {
|
338
|
+
:record_id => "dedupmrg17343091",
|
339
|
+
:v => "",
|
340
|
+
:url => "https://ezproxy.library.nyu.edu/login?url=http://proquest.umi.com/pqdweb?RQT=318&VName=PQD&clientid=9269&pmid=7818",
|
341
|
+
:display => "1995 - Current Access via Proquest",
|
342
|
+
:institution_code => "NYU",
|
343
|
+
:origin => "nyu_aleph000932393",
|
344
|
+
:notes => "" }
|
345
|
+
test_data.each { |key, value|
|
346
|
+
assert_equal(
|
347
|
+
value,
|
348
|
+
first_rsrc.send(key),
|
349
|
+
"#{searcher.class} first rsrc has an unexpected #{key}: #{first_rsrc.send(key)}")
|
350
|
+
}
|
351
|
+
end
|
352
|
+
|
353
|
+
def test_holdings_diacritics1
|
354
|
+
searcher = Exlibris::Primo::Searcher.new(
|
355
|
+
@searcher_setup,
|
356
|
+
{ :primo_id => @primo_test_diacritics1_doc_id })
|
357
|
+
assert_equal(
|
358
|
+
"Rubāʻīyāt-i Bābā Ṭāhir",
|
359
|
+
searcher.btitle,
|
360
|
+
"#{searcher.class} has an unexpected btitle: #{searcher.btitle}")
|
361
|
+
assert_equal(
|
362
|
+
"Bābā-Ṭāhir, 11th cent",
|
363
|
+
searcher.au,
|
364
|
+
"#{searcher.class} has an unexpected author: #{searcher.au}")
|
365
|
+
end
|
366
|
+
|
367
|
+
# This test fails but I don't know why!
|
368
|
+
def test_holdings_diacritics2
|
369
|
+
searcher = Exlibris::Primo::Searcher.new(
|
370
|
+
@searcher_setup,
|
371
|
+
{ :primo_id => @primo_test_diacritics2_doc_id })
|
372
|
+
assert_equal(
|
373
|
+
"أقليم توات خلال القرنين الثامن عشر والتاسع عشر الميلاديين : دراسة لأوضاع الأقليم السياسية والأجتماعية والأقتصادية والثقافية، مع تحقيق كتاب القول البسيط في أخبار تمنطيط (لمحمد بن بابا حيده)",
|
374
|
+
searcher.btitle,
|
375
|
+
"#{searcher.class} has an unexpected btitle: #{searcher.btitle}")
|
376
|
+
puts ("\n")
|
377
|
+
puts searcher.au.bytes.collect.inspect
|
378
|
+
faraj = "Faraj, Faraj Maḥmūd"
|
379
|
+
puts ("\n»")
|
380
|
+
puts "»".bytes.collect.inspect
|
381
|
+
puts faraj.bytes.collect.inspect
|
382
|
+
assert_equal(
|
383
|
+
"Faraj, Faraj Maḥmūd",
|
384
|
+
searcher.au,
|
385
|
+
"#{searcher.class} has an unexpected author: #{searcher.au}")
|
386
|
+
assert_equal("(DT299.T88 F373 2007)", first_holding.call_number, "#{searcher.class} first holding has an unexpected call number: #{first_holding.call_number}")
|
387
|
+
end
|
388
|
+
|
389
|
+
# Record doesn't exist in BobCat dev
|
390
|
+
# def test_holdings_diacritics3
|
391
|
+
# searcher = Exlibris::Primo::Searcher.new(
|
392
|
+
# @searcher_setup,
|
393
|
+
# { :primo_id => @primo_test_diacritics3_doc_id })
|
394
|
+
# assert_equal(
|
395
|
+
# "Mul har ha-gaʻash : ḥoḳre toldot Yiśraʼel le-nokhaḥ ha-Shoʼah",
|
396
|
+
# searcher.btitle,
|
397
|
+
# "#{searcher.class} has an unexpected btitle: #{searcher.btitle}")
|
398
|
+
# assert_equal(
|
399
|
+
# "Engel, David",
|
400
|
+
# searcher.au,
|
401
|
+
# "#{searcher.class} has an unexpected author: #{searcher.au}")
|
402
|
+
# end
|
403
|
+
end
|