exlibris-primo 0.0.1

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.
Files changed (50) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +38 -0
  4. data/lib/exlibris-primo.rb +11 -0
  5. data/lib/exlibris/primo/holding.rb +185 -0
  6. data/lib/exlibris/primo/related_link.rb +19 -0
  7. data/lib/exlibris/primo/rsrc.rb +19 -0
  8. data/lib/exlibris/primo/searcher.rb +292 -0
  9. data/lib/exlibris/primo/source/aleph.rb +50 -0
  10. data/lib/exlibris/primo/toc.rb +19 -0
  11. data/lib/exlibris/primo/version.rb +5 -0
  12. data/lib/exlibris/primo/web_service.rb +145 -0
  13. data/lib/tasks/exlibris-primo_tasks.rake +4 -0
  14. data/test/dummy/README.rdoc +261 -0
  15. data/test/dummy/Rakefile +7 -0
  16. data/test/dummy/app/assets/javascripts/application.js +15 -0
  17. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  18. data/test/dummy/app/controllers/application_controller.rb +3 -0
  19. data/test/dummy/app/helpers/application_helper.rb +2 -0
  20. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  21. data/test/dummy/config.ru +4 -0
  22. data/test/dummy/config/application.rb +56 -0
  23. data/test/dummy/config/boot.rb +10 -0
  24. data/test/dummy/config/database.yml +25 -0
  25. data/test/dummy/config/environment.rb +5 -0
  26. data/test/dummy/config/environments/development.rb +37 -0
  27. data/test/dummy/config/environments/production.rb +67 -0
  28. data/test/dummy/config/environments/test.rb +37 -0
  29. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  30. data/test/dummy/config/initializers/inflections.rb +15 -0
  31. data/test/dummy/config/initializers/mime_types.rb +5 -0
  32. data/test/dummy/config/initializers/secret_token.rb +7 -0
  33. data/test/dummy/config/initializers/session_store.rb +8 -0
  34. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  35. data/test/dummy/config/locales/en.yml +5 -0
  36. data/test/dummy/config/routes.rb +58 -0
  37. data/test/dummy/db/test.sqlite3 +0 -0
  38. data/test/dummy/log/test.log +410 -0
  39. data/test/dummy/public/404.html +26 -0
  40. data/test/dummy/public/422.html +26 -0
  41. data/test/dummy/public/500.html +25 -0
  42. data/test/dummy/public/favicon.ico +0 -0
  43. data/test/dummy/script/rails +6 -0
  44. data/test/exlibris-primo_test.rb +7 -0
  45. data/test/test_helper.rb +10 -0
  46. data/test/unit/searcher_benchmarks.rb +82 -0
  47. data/test/unit/searcher_test.rb +383 -0
  48. data/test/unit/web_service_benchmarks.rb +60 -0
  49. data/test/unit/web_service_test.rb +124 -0
  50. metadata +174 -0
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class ExlibrisPrimoTest < ActiveSupport::TestCase
4
+ test "truth" do
5
+ assert_kind_of Module, Exlibris::Primo
6
+ end
7
+ end
@@ -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 }
@@ -0,0 +1,82 @@
1
+ require 'test_helper'
2
+ class SearcherTest < Test::Unit::TestCase
3
+ PNX_NS = {'pnx' => 'http://www.exlibrisgroup.com/xsd/primo/primo_nm_bib'}
4
+ SEARCH_NS = {'search' => 'http://www.exlibrisgroup.com/xsd/jaguar/search'}
5
+
6
+ def setup
7
+ @primo_definition = YAML.load( %{
8
+ type: PrimoService
9
+ priority: 2 # After SFX, to get SFX metadata enhancement
10
+ status: active
11
+ base_url: http://bobcat.library.nyu.edu
12
+ vid: NYU
13
+ institution: NYU
14
+ holding_search_institution: NYU
15
+ holding_search_text: Search for this title in BobCat.
16
+ suppress_holdings: [ !ruby/regexp '/\$\$LBWEB/', !ruby/regexp '/\$\$LNWEB/', !ruby/regexp '/\$\$LTWEB/', !ruby/regexp '/\$\$LWEB/', !ruby/regexp '/\$\$1Restricted Internet Resources/' ]
17
+ ez_proxy: !ruby/regexp '/https\:\/\/ezproxy\.library\.nyu\.edu\/login\?url=/'
18
+ service_types:
19
+ - primo_source
20
+ - holding_search
21
+ - fulltext
22
+ - table_of_contents
23
+ - referent_enhance
24
+ - cover_image
25
+ })
26
+
27
+ @base_url = @primo_definition["base_url"]
28
+ @vid = @primo_definition["vid"]
29
+ @institution = @primo_definition["institution"]
30
+ @primo_holdings_doc_id = "nyu_aleph000062856"
31
+ @primo_rsrcs_doc_id = "nyu_aleph002895625"
32
+ @primo_tocs_doc_id = "nyu_aleph003149772"
33
+ @primo_dedupmrg_doc_id = "dedupmrg17343091"
34
+ @primo_test_checked_out_doc_id = "nyu_aleph000089771"
35
+ @primo_test_offsite_doc_id = "nyu_aleph002169696"
36
+ @primo_test_ill_doc_id = "nyu_aleph001502625"
37
+ @primo_test_diacritics1_doc_id = "nyu_aleph002975583"
38
+ @primo_test_diacritics2_doc_id = "nyu_aleph003205339"
39
+ @primo_test_diacritics3_doc_id = "nyu_aleph003365921"
40
+ @primo_test_journals1_doc_id = "nyu_aleph002895625"
41
+ @primo_invalid_doc_id = "thisIsNotAValidDocId"
42
+ @primo_test_problem_doc_id = "nyu_aleph000509288"
43
+ @primo_test_bug1361_id = "ebrroutebr10416506"
44
+ @primo_test_isbn = "0143039008"
45
+ @primo_test_title = "Travels with My Aunt"
46
+ @primo_test_author = "Graham Greene"
47
+ @primo_test_genre = "Book"
48
+ @searcher_setup = {
49
+ :base_url => @base_url,
50
+ :institution => @institution,
51
+ :vid => @vid,
52
+ :config => @primo_config
53
+ }
54
+
55
+ @searcher_setup_without_config = {
56
+ :base_url => @base_url,
57
+ :institution => @institution,
58
+ :vid => @vid
59
+ }
60
+ end
61
+
62
+ test "benchmarks" do
63
+ Benchmark.bmbm do |results|
64
+ results.report("Primo Searcher:") {
65
+ (1..10).each {
66
+ searcher = Exlibris::Primo::Searcher.new(@searcher_setup, {:primo_id => @primo_holdings_doc_id})
67
+ }
68
+ }
69
+ searcher = Exlibris::Primo::Searcher.new(@searcher_setup, {:primo_id => @primo_holdings_doc_id})
70
+ results.report("Searcher#process_record") {
71
+ (1..10).each {
72
+ searcher.send(:process_record)
73
+ }
74
+ }
75
+ results.report("Searcher#process_search_results") {
76
+ (1..10).each {
77
+ searcher.send(:process_search_results)
78
+ }
79
+ }
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,383 @@
1
+ require 'test_helper'
2
+ class SearcherTest < Test::Unit::TestCase
3
+ PNX_NS = {'pnx' => 'http://www.exlibrisgroup.com/xsd/primo/primo_nm_bib'}
4
+ SEARCH_NS = {'search' => 'http://www.exlibrisgroup.com/xsd/jaguar/search'}
5
+
6
+ def setup
7
+ @primo_definition = YAML.load( %{
8
+ type: PrimoService
9
+ priority: 2 # After SFX, to get SFX metadata enhancement
10
+ status: active
11
+ base_url: http://bobcat.library.nyu.edu
12
+ vid: NYU
13
+ institution: NYU
14
+ holding_search_institution: NYU
15
+ holding_search_text: Search for this title in BobCat.
16
+ suppress_holdings: [ !ruby/regexp '/\$\$LBWEB/', !ruby/regexp '/\$\$LNWEB/', !ruby/regexp '/\$\$LTWEB/', !ruby/regexp '/\$\$LWEB/', !ruby/regexp '/\$\$1Restricted Internet Resources/' ]
17
+ ez_proxy: !ruby/regexp '/https\:\/\/ezproxy\.library\.nyu\.edu\/login\?url=/'
18
+ service_types:
19
+ - primo_source
20
+ - holding_search
21
+ - fulltext
22
+ - table_of_contents
23
+ - referent_enhance
24
+ - cover_image
25
+ })
26
+
27
+ @base_url = @primo_definition["base_url"]
28
+ @vid = @primo_definition["vid"]
29
+ @institution = @primo_definition["institution"]
30
+ @primo_holdings_doc_id = "nyu_aleph000062856"
31
+ @primo_rsrcs_doc_id = "nyu_aleph002895625"
32
+ @primo_tocs_doc_id = "nyu_aleph003149772"
33
+ @primo_dedupmrg_doc_id = "dedupmrg17343091"
34
+ @primo_test_checked_out_doc_id = "nyu_aleph000089771"
35
+ @primo_test_offsite_doc_id = "nyu_aleph002169696"
36
+ @primo_test_ill_doc_id = "nyu_aleph001502625"
37
+ @primo_test_diacritics1_doc_id = "nyu_aleph002975583"
38
+ @primo_test_diacritics2_doc_id = "nyu_aleph003205339"
39
+ @primo_test_diacritics3_doc_id = "nyu_aleph003365921"
40
+ @primo_test_journals1_doc_id = "nyu_aleph002895625"
41
+ @primo_invalid_doc_id = "thisIsNotAValidDocId"
42
+ @primo_test_problem_doc_id = "nyu_aleph000509288"
43
+ @primo_test_bug1361_id = "ebrroutebr10416506"
44
+ @primo_test_isbn = "0143039008"
45
+ @primo_test_title = "Travels with My Aunt"
46
+ @primo_test_author = "Graham Greene"
47
+ @primo_test_genre = "Book"
48
+ @searcher_setup = {
49
+ :base_url => @base_url,
50
+ :institution => @institution,
51
+ :vid => @vid,
52
+ :config => @primo_definition
53
+ }
54
+
55
+ @searcher_setup_without_config = {
56
+ :base_url => @base_url,
57
+ :institution => @institution,
58
+ :vid => @vid
59
+ }
60
+ end
61
+
62
+ # Test search for a single Primo document.
63
+ def test_search_by_doc_id
64
+ searcher = Exlibris::Primo::Searcher.new(@searcher_setup, {:primo_id => @primo_holdings_doc_id})
65
+ assert_not_nil(searcher, "#{searcher.class} returned nil when instantiated.")
66
+ search_results = searcher.response
67
+ assert_instance_of(Nokogiri::XML::Document, search_results, "#{searcher.class} search result is an unexpected object: #{search_results.class}")
68
+ assert_equal(@primo_holdings_doc_id, search_results.at("//pnx:control/pnx:recordid", PNX_NS).inner_text, "#{searcher.class} returned an unexpected record: #{search_results.to_xml(:indent => 5, :encoding => 'UTF-8')}")
69
+ assert(searcher.count.to_i > 0, "#{searcher.class} returned 0 results for doc id: #{@primo_holdings_doc_id}.")
70
+ end
71
+
72
+ # Test search for a Primo problem record
73
+ def test_search_by_genre_discrepancy
74
+ searcher = Exlibris::Primo::Searcher.new(@searcher_setup, {:primo_id => @primo_test_problem_doc_id})
75
+ assert_not_nil(searcher, "#{searcher.class} returned nil when instantiated.")
76
+ search_results = searcher.response
77
+ assert_instance_of(Nokogiri::XML::Document, search_results, "#{searcher.class} search result is an unexpected object: #{search_results.class}")
78
+ assert_equal(@primo_test_problem_doc_id, search_results.at("//pnx:control/pnx:recordid", PNX_NS).inner_text, "#{searcher.class} returned an unexpected record: #{search_results.to_xml(:indent => 5, :encoding => 'UTF-8')}")
79
+ assert(searcher.count.to_i > 0, "#{searcher.class} returned 0 results for doc id: #{@primo_test_problem_doc_id}.")
80
+ assert_equal(1, searcher.holdings.length, "#{searcher.class} returned unexpected holdings")
81
+ end
82
+
83
+ def test_search_by_bug1361
84
+ searcher = Exlibris::Primo::Searcher.new(@searcher_setup, {:primo_id => @primo_test_bug1361_id})
85
+ assert_not_nil(searcher, "#{searcher.class} returned nil when instantiated.")
86
+ search_results = searcher.response
87
+ assert_instance_of(Nokogiri::XML::Document, search_results, "#{searcher.class} search result is an unexpected object: #{search_results.class}")
88
+ assert_equal(@primo_test_bug1361_id, search_results.at("//pnx:control/pnx:recordid", PNX_NS).inner_text, "#{searcher.class} returned an unexpected record: #{search_results.to_xml(:indent => 5, :encoding => 'UTF-8')}")
89
+ assert(searcher.count.to_i > 0, "#{searcher.class} returned 0 results for doc id: #{@primo_test_bug1361_id}.")
90
+ assert_equal(0, searcher.holdings.length, "#{searcher.class} returned unexpected holdings")
91
+ assert_equal(4, searcher.rsrcs.length, "#{searcher.class} returned unexpected rsrcs")
92
+ end
93
+
94
+ # Test search for an invalid Primo document.
95
+ def test_search_by_invalid_doc_id
96
+ assert_raise(RuntimeError) {
97
+ searcher = Exlibris::Primo::Searcher.new(@searcher_setup, {:primo_id => @primo_invalid_doc_id})
98
+ }
99
+ end
100
+
101
+ # Test invalid setup.
102
+ def test_search_by_invalid_setup1
103
+ assert_raise(RuntimeError) {
104
+ searcher = Exlibris::Primo::Searcher.new({}, {:primo_id => @primo_invalid_doc_id})
105
+ }
106
+ end
107
+
108
+ # Test invalid setup.
109
+ def test_search_by_invalid_setup2
110
+ assert_raise(RuntimeError) {
111
+ searcher = Exlibris::Primo::Searcher.new({:base_url => @base_url, :config => nil}, {:primo_id => @primo_invalid_doc_id})
112
+ }
113
+ end
114
+
115
+ # Test base setup search for a single Primo document.
116
+ def test_search_base_setup_record_id
117
+ searcher = Exlibris::Primo::Searcher.new({:base_url => @base_url, :institution => @institution}, {:primo_id => @primo_holdings_doc_id})
118
+ holdings = searcher.holdings
119
+ assert_instance_of(Array, holdings, "#{searcher.class} holdings is an unexpected object: #{holdings.class}")
120
+ assert(holdings.count > 0, "#{searcher.class} returned 0 holdings for doc id: #{@primo_holdings_doc_id}.")
121
+ first_holding = holdings.first
122
+ assert_instance_of(Exlibris::Primo::Holding, first_holding, "#{searcher.class} first holding is an unexpected object: #{first_holding.class}")
123
+ assert_equal("check_holdings", first_holding.status, "#{searcher.class} first holding has an unexpected status: #{first_holding.status}")
124
+ assert_equal("NYU", first_holding.institution, "#{searcher.class} first holding has an unexpected institution: #{first_holding.institution}")
125
+ assert_equal("BOBST", first_holding.library, "#{searcher.class} first holding has an unexpected library: #{first_holding.library}")
126
+ assert_equal("Main Collection", first_holding.collection, "#{searcher.class} first holding has an unexpected collection: #{first_holding.collection}")
127
+ assert_equal("(PR6013.R44 T7 2004 )", first_holding.call_number, "#{searcher.class} first holding has an unexpected call number: #{first_holding.call_number}")
128
+ end
129
+
130
+ # Test search by isbn.
131
+ def test_search_by_isbn
132
+ searcher = Exlibris::Primo::Searcher.new(@searcher_setup, {:isbn => @primo_test_isbn})
133
+ assert_not_nil(searcher, "#{searcher.class} returned nil when instantiated.")
134
+ search_results = searcher.response
135
+ assert_instance_of(Nokogiri::XML::Document, search_results, "#{searcher.class} search result is an unexpected object: #{search_results.class}")
136
+ search_results.search("//search/isbn") do |isbn|
137
+ assert_not_nil(isbn.inner_text.match(@primo_test_isbn), "#{searcher.class} returned an unexpected record: #{search_results.to_xml(:indent => 5, :encoding => 'UTF-8')}")
138
+ end
139
+ assert(searcher.count.to_i > 0, "#{searcher.class} returned 0 results for ISBN: #{@primo_test_isbn}.")
140
+ end
141
+
142
+ # Test search by isbn.
143
+ def test_search_by_issn
144
+ searcher = Exlibris::Primo::Searcher.new(@searcher_setup_without_config, {:issn => "0002-8614"})
145
+ assert_not_nil(searcher, "#{searcher.class} returned nil when instantiated.")
146
+ search_results = searcher.response
147
+ assert_instance_of(Nokogiri::XML::Document, search_results, "#{searcher.class} search result is an unexpected object: #{search_results.class}")
148
+ search_results.search("//search/issn") do |isbn|
149
+ assert_not_nil(isbn.inner_text.match("0002-8614"), "#{searcher.class} returned an unexpected record: #{search_results.to_xml(:indent => 5, :encoding => 'UTF-8')}")
150
+ end
151
+ assert(searcher.count.to_i > 0, "#{searcher.class} returned 0 results for ISSN: 0002-8614.")
152
+ end
153
+
154
+ # Test search by title/author/genre.
155
+ def test_search_by_title_author_genre
156
+ searcher = Exlibris::Primo::Searcher.new(@searcher_setup, {:title => @primo_test_title, :author => @primo_test_author, :genre => @primo_test_genre})
157
+ assert_not_nil(searcher, "#{searcher.class} returned nil when instantiated.")
158
+ search_results = searcher.response
159
+ assert_instance_of(Nokogiri::XML::Document, search_results, "#{searcher.class} search result is an unexpected object: #{search_results.class}")
160
+ search_results.search("//search/title") do |title|
161
+ assert_not_nil(title.inner_text.downcase.match(@primo_test_title.downcase), "#{searcher.class} returned an unexpected record: #{search_results.to_xml(:indent => 5, :encoding => 'UTF-8')}")
162
+ end
163
+ assert(searcher.count.to_i > 0, "#{searcher.class} returned 0 results for Title: #{@primo_test_title}.")
164
+ end
165
+
166
+ # Test search for a single Primo document w/ holdings.
167
+ def test_holdings
168
+ searcher = Exlibris::Primo::Searcher.new(@searcher_setup, {:primo_id => @primo_holdings_doc_id})
169
+ holdings = searcher.holdings
170
+ assert_instance_of(Array, holdings,
171
+ "#{searcher.class} holdings is an unexpected object: #{holdings.class}")
172
+ assert_equal(1, holdings.count,
173
+ "#{searcher.class} returned 0 holdings for doc id: #{@primo_holdings_doc_id}.")
174
+ first_holding = holdings.first
175
+ assert_instance_of(
176
+ Exlibris::Primo::Holding,
177
+ first_holding,
178
+ "#{searcher.class} first holding is an unexpected object: #{first_holding.class}")
179
+ test_data = {
180
+ :record_id => "nyu_aleph000062856",
181
+ :source_id => "nyu_aleph",
182
+ :original_source_id => "NYU01",
183
+ :source_record_id => "000062856",
184
+ :institution_code => "NYU",
185
+ :institution => "NYU",
186
+ :library_code => "BOBST",
187
+ :library => "BOBST",
188
+ :status_code => "check_holdings",
189
+ :status => "check_holdings",
190
+ :id_one => "Main Collection",
191
+ :id_two => "(PR6013.R44 T7 2004 )",
192
+ :collection => "Main Collection",
193
+ :call_number => "(PR6013.R44 T7 2004 )",
194
+ :origin => nil,
195
+ :display_type => "book",
196
+ :coverage => [],
197
+ :notes => "",
198
+ :url => "#{@base_url}/primo_library/libweb/action/dlDisplay.do?docId=nyu_aleph000062856&institution=NYU&vid=#{@vid}",
199
+ :request_url => nil }
200
+ test_data.each { |key, value|
201
+ assert_equal(
202
+ value,
203
+ first_holding.send(key),
204
+ "#{searcher.class} first holding has an unexpected #{key}: #{first_holding.send(key)}")
205
+ }
206
+ end
207
+
208
+ # Test search for a single Primo document w/ rsrcs.
209
+ def test_rsrcs
210
+ searcher = Exlibris::Primo::Searcher.new(
211
+ @searcher_setup,
212
+ { :primo_id => @primo_rsrcs_doc_id })
213
+ rsrcs = searcher.rsrcs
214
+ assert_instance_of(Array, rsrcs,
215
+ "#{searcher.class} rsrcs is an unexpected object: #{rsrcs.class}")
216
+ assert_equal(2, rsrcs.count,
217
+ "#{searcher.class} returned an unexpected amount of rsrcs (#{rsrcs.count}) for doc id: #{@primo_rsrcs_doc_id}.")
218
+ first_rsrc = rsrcs.first
219
+ assert_instance_of(
220
+ Exlibris::Primo::Rsrc,
221
+ first_rsrc,
222
+ "#{searcher.class} first rsrc is an unexpected object: #{first_rsrc.class}")
223
+ test_data = {
224
+ :record_id => "nyu_aleph002895625",
225
+ :v => nil,
226
+ :url => "https://ezproxy.library.nyu.edu/login?url=http://mq.oxfordjournals.org/",
227
+ :display => "Online Version",
228
+ :institution_code => "NYU",
229
+ :origin => nil,
230
+ :notes => "" }
231
+ test_data.each { |key, value|
232
+ assert_equal(
233
+ value,
234
+ first_rsrc.send(key),
235
+ "#{searcher.class} first rsrc has an unexpected #{key}: #{first_rsrc.send(key)}")
236
+ }
237
+ end
238
+
239
+ # Test search for a single Primo document w/ tocs.
240
+ def test_tocs
241
+ searcher = Exlibris::Primo::Searcher.new(
242
+ @searcher_setup,
243
+ { :primo_id => @primo_tocs_doc_id })
244
+ tocs = searcher.tocs
245
+ assert_instance_of(Array, tocs,
246
+ "#{searcher.class} tocs is an unexpected object: #{tocs.class}")
247
+ assert_equal(1, tocs.count,
248
+ "#{searcher.class} returned an unexpected amount of tocs (#{tocs.count}) for doc id: #{@primo_tocs_doc_id}.")
249
+ first_toc = tocs.last
250
+ assert_instance_of(
251
+ Exlibris::Primo::Toc,
252
+ first_toc,
253
+ "#{searcher.class} first toc is an unexpected object: #{first_toc.class}")
254
+ test_data = {
255
+ :record_id => "nyu_aleph003149772",
256
+ :url => "http://www.loc.gov/catdir/toc/onix07/2001024342.html",
257
+ :display => "Table of Contents",
258
+ :notes => "" }
259
+ test_data.each { |key, value|
260
+ assert_equal(
261
+ value,
262
+ first_toc.send(key),
263
+ "#{searcher.class} first toc has an unexpected #{key}: #{first_toc.send(key)}")
264
+ }
265
+ end
266
+
267
+ def test_dedupmrg
268
+ searcher = Exlibris::Primo::Searcher.new(
269
+ @searcher_setup,
270
+ { :primo_id => @primo_dedupmrg_doc_id })
271
+ holdings = searcher.holdings
272
+ assert_instance_of(Array, holdings,
273
+ "#{searcher.class} holdings is an unexpected object: #{holdings.class}")
274
+ assert_equal(6, holdings.count,
275
+ "#{searcher.class} returned 0 holdings for doc id: #{@primo_dedupmrg_doc_id}.")
276
+ first_holding = holdings.first
277
+ assert_instance_of(
278
+ Exlibris::Primo::Holding,
279
+ first_holding,
280
+ "#{searcher.class} first holding is an unexpected object: #{first_holding.class}")
281
+ test_data = {
282
+ :record_id => "dedupmrg17343091",
283
+ :source_id => "nyu_aleph",
284
+ :original_source_id => "NYU01",
285
+ :source_record_id => "000932393",
286
+ :institution_code => "NYU",
287
+ :institution => "NYU",
288
+ :library_code => "BWEB",
289
+ :library => "BWEB",
290
+ :status_code => "check_holdings",
291
+ :status => "check_holdings",
292
+ :id_one => "Internet Resources",
293
+ :id_two => "(Newspaper Electronic access )",
294
+ :collection => "Internet Resources",
295
+ :call_number => "(Newspaper Electronic access )",
296
+ :origin => "nyu_aleph000932393",
297
+ :display_type => "journal",
298
+ :coverage => [],
299
+ :notes => "",
300
+ :url => "#{@base_url}/primo_library/libweb/action/dlDisplay.do?docId=dedupmrg17343091&institution=NYU&vid=#{@vid}",
301
+ :request_url => nil }
302
+ test_data.each { |key, value|
303
+ assert_equal(
304
+ value,
305
+ first_holding.send(key),
306
+ "#{searcher.class} first holding has an unexpected #{key}: #{first_holding.send(key)}")
307
+ }
308
+ rsrcs = searcher.rsrcs
309
+ assert_instance_of(Array, rsrcs,
310
+ "#{searcher.class} rsrcs is an unexpected object: #{rsrcs.class}")
311
+ assert_equal(8, rsrcs.count,
312
+ "#{searcher.class} returned an unexpected amount of rsrcs (#{rsrcs.count}) for doc id: #{@primo_rsrcs_doc_id}.")
313
+ first_rsrc = rsrcs.first
314
+ assert_instance_of(
315
+ Exlibris::Primo::Rsrc,
316
+ first_rsrc,
317
+ "#{searcher.class} first rsrc is an unexpected object: #{first_rsrc.class}")
318
+ test_data = {
319
+ :record_id => "dedupmrg17343091",
320
+ :v => "",
321
+ :url => "https://ezproxy.library.nyu.edu/login?url=http://proquest.umi.com/pqdweb?RQT=318&VName=PQD&clientid=9269&pmid=7818",
322
+ :display => "1995 - Current Access via Proquest",
323
+ :institution_code => "NYU",
324
+ :origin => "nyu_aleph000932393",
325
+ :notes => "" }
326
+ test_data.each { |key, value|
327
+ assert_equal(
328
+ value,
329
+ first_rsrc.send(key),
330
+ "#{searcher.class} first rsrc has an unexpected #{key}: #{first_rsrc.send(key)}")
331
+ }
332
+ end
333
+
334
+ # def test_holdings_diacritics1
335
+ # searcher = Exlibris::Primo::Searcher.new(
336
+ # @searcher_setup,
337
+ # { :primo_id => @primo_test_diacritics1_doc_id })
338
+ # assert_equal(
339
+ # "Rubāʻīyāt-i Bābā Ṭāhir",
340
+ # searcher.btitle,
341
+ # "#{searcher.class} has an unexpected btitle: #{searcher.btitle}")
342
+ # assert_equal(
343
+ # "Bābā-Ṭāhir, 11th cent",
344
+ # searcher.au,
345
+ # "#{searcher.class} has an unexpected author: #{searcher.au}")
346
+ # end
347
+
348
+ # # This test fails but I don't know why!
349
+ # def test_holdings_diacritics2
350
+ # searcher = Exlibris::Primo::Searcher.new(
351
+ # @searcher_setup,
352
+ # { :primo_id => @primo_test_diacritics2_doc_id })
353
+ # assert_equal(
354
+ # "أقليم توات خلال القرنين الثامن عشر والتاسع عشر الميلاديين : دراسة لأوضاع الأقليم السياسية والأجتماعية والأقتصادية والثقافية، مع تحقيق كتاب القول البسيط في أخبار تمنطيط (لمحمد بن بابا حيده)",
355
+ # searcher.btitle,
356
+ # "#{searcher.class} has an unexpected btitle: #{searcher.btitle}")
357
+ # puts ("\n")
358
+ # puts searcher.au.bytes.collect.inspect
359
+ # faraj = "Faraj, Faraj Maḥmūd"
360
+ # puts ("\n»")
361
+ # puts "»".bytes.collect.inspect
362
+ # puts faraj.bytes.collect.inspect
363
+ # assert_equal(
364
+ # "Faraj, Faraj Maḥmūd",
365
+ # searcher.au,
366
+ # "#{searcher.class} has an unexpected author: #{searcher.au}")
367
+ # assert_equal("(DT299.T88 F373 2007)", first_holding.call_number, "#{searcher.class} first holding has an unexpected call number: #{first_holding.call_number}")
368
+ # end
369
+ #
370
+ # def test_holdings_diacritics3
371
+ # searcher = Exlibris::Primo::Searcher.new(
372
+ # @searcher_setup,
373
+ # { :primo_id => @primo_test_diacritics3_doc_id })
374
+ # assert_equal(
375
+ # "Mul har ha-gaʻash : ḥoḳre toldot Yiśraʼel le-nokhaḥ ha-Shoʼah",
376
+ # searcher.btitle,
377
+ # "#{searcher.class} has an unexpected btitle: #{searcher.btitle}")
378
+ # assert_equal(
379
+ # "Engel, David",
380
+ # searcher.au,
381
+ # "#{searcher.class} has an unexpected author: #{searcher.au}")
382
+ # end
383
+ end