exlibris-primo 1.1.9 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 01f76416ae24ba5c3d237cc1cebfe8c4192e17f7
4
- data.tar.gz: 497c57e36349a2bb3d7f88a27eaa10a3ff3b55b8
3
+ metadata.gz: a82bc9dc99c48271e4b298fb3e17f85fba6a82d4
4
+ data.tar.gz: c0df376d0087a548c857f715531e3c78298b7b7f
5
5
  SHA512:
6
- metadata.gz: 865d284666936374dc228aeba4696fe7d398757d895499f761400075001ed6d8bc0b783280213eb8f081740a435d020d9a1b5fb94947e7b1c8d95476651a86a1
7
- data.tar.gz: 9a31bba9503106e7de56d3d85dfe9348e6e6ba04d576c3dda08b33ed2b29db19c555eac4db8b42bdb4391e98a6fbd35136a6a6250df22b2be9a770eb3decd8b1
6
+ metadata.gz: a23d848ebdfefc254a0d12364584183130d0a2375afdcfe8b2007345ad9430a481a4f5cca78eaeccaac68524bdb897046b3a19b9c60db728c76d21e4572f35e2
7
+ data.tar.gz: 2c253dfc14fc47f65e9e628ad7161229a2f9011fa643a0ce7284a20af9239ea10c8567ed6284c1a871dab05072b8e73f1f1bb09070f0bc3e863d913641f40a95
@@ -1,5 +1,5 @@
1
1
  module Exlibris
2
2
  module Primo
3
- VERSION = '1.1.9'
3
+ VERSION = '2.0.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exlibris-primo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.9
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scot Dalton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-05 00:00:00.000000000 Z
11
+ date: 2017-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: require_all
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.6.0
47
+ version: 1.7.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.6.0
54
+ version: 1.7.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: json
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -164,10 +164,39 @@ dependencies:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: 4.7.5
167
+ - !ruby/object:Gem::Dependency
168
+ name: rack
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: 1.6.5
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: 1.6.5
181
+ - !ruby/object:Gem::Dependency
182
+ name: test-unit
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: 3.2.3
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: 3.2.3
167
195
  description: Library to work with Exlibris' Primo discovery system. Does not require
168
196
  Rails.
169
197
  email:
170
198
  - scotdalton@gmail.com
199
+ - barnaby.alter@gmail.com
171
200
  executables: []
172
201
  extensions: []
173
202
  extra_rdoc_files: []
@@ -245,10 +274,6 @@ files:
245
274
  - lib/exlibris/primo/web_service/response/tags.rb
246
275
  - lib/exlibris/primo/write_attributes.rb
247
276
  - lib/exlibris/primo/xml_util.rb
248
- - test/bak/eshelf_test.rb.bak
249
- - test/bak/record_test.rb.bak
250
- - test/bak/searcher_test.rb.bak
251
- - test/bak/web_service_test.rb.bak
252
277
  - test/config_test.rb
253
278
  - test/eshelf_test.rb
254
279
  - test/exlibris-primo_test.rb
@@ -344,7 +369,6 @@ files:
344
369
  - test/vcr_cassettes/reviews_reviews.yml
345
370
  - test/vcr_cassettes/reviews_user.yml
346
371
  - test/vcr_cassettes/search_chaining_author_title.yml
347
- - test/vcr_cassettes/search_chaining_author_title.yml.bak
348
372
  - test/vcr_cassettes/search_chaining_contains_any.yml
349
373
  - test/vcr_cassettes/search_chaining_contains_author_starts_with_title.yml
350
374
  - test/vcr_cassettes/search_chaining_isbn.yml
@@ -405,7 +429,7 @@ files:
405
429
  - test/web_service/response/tags_test.rb
406
430
  - test/xml/record_other_sourcesystem.xml
407
431
  - test/xml_util_test.rb
408
- homepage: https://github.com/scotdalton/exlibris-primo
432
+ homepage: https://github.com/NYULibraries/exlibris-primo
409
433
  licenses:
410
434
  - MIT
411
435
  metadata: {}
@@ -425,15 +449,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
425
449
  version: '0'
426
450
  requirements: []
427
451
  rubyforge_project:
428
- rubygems_version: 2.2.2
452
+ rubygems_version: 2.5.2
429
453
  signing_key:
430
454
  specification_version: 4
431
455
  summary: Library to work with Exlibris' Primo discovery system.
432
456
  test_files:
433
- - test/bak/eshelf_test.rb.bak
434
- - test/bak/record_test.rb.bak
435
- - test/bak/searcher_test.rb.bak
436
- - test/bak/web_service_test.rb.bak
437
457
  - test/config_test.rb
438
458
  - test/eshelf_test.rb
439
459
  - test/exlibris-primo_test.rb
@@ -529,7 +549,6 @@ test_files:
529
549
  - test/vcr_cassettes/reviews_reviews.yml
530
550
  - test/vcr_cassettes/reviews_user.yml
531
551
  - test/vcr_cassettes/search_chaining_author_title.yml
532
- - test/vcr_cassettes/search_chaining_author_title.yml.bak
533
552
  - test/vcr_cassettes/search_chaining_contains_any.yml
534
553
  - test/vcr_cassettes/search_chaining_contains_author_starts_with_title.yml
535
554
  - test/vcr_cassettes/search_chaining_isbn.yml
@@ -1,171 +0,0 @@
1
- require 'test_helper'
2
-
3
- class EShelfTest < Test::Unit::TestCase
4
- PNX_NS = {'pnx' => 'http://www.exlibrisgroup.com/xsd/primo/primo_nm_bib'}
5
- SEARCH_NS = {'search' => 'http://www.exlibrisgroup.com/xsd/jaguar/search'}
6
- SEAR_NS = {'sear' => 'http://www.exlibrisgroup.com/xsd/jaguar/search'}
7
- PRIM_NS = {'prim' => 'http://www.exlibris.com/primo/xsd/primoeshelffolder'}
8
-
9
- def setup
10
- @primo_definition = YAML.load( %{
11
- type: PrimoService
12
- priority: 2 # After SFX, to get SFX metadata enhancement
13
- status: active
14
- base_url: http://bobcat.library.nyu.edu
15
- resolver_base_url: https://getit.library.nyu.edu/resolve
16
- vid: NYU
17
- institution: NYU
18
- holding_search_institution: NYU
19
- holding_search_text: Search for this title in BobCat.
20
- suppress_holdings: [ !ruby/regexp '/\$\$LBWEB/', !ruby/regexp '/\$\$LNWEB/', !ruby/regexp '/\$\$LTWEB/', !ruby/regexp '/\$\$LWEB/', !ruby/regexp '/\$\$1Restricted Internet Resources/' ]
21
- ez_proxy: !ruby/regexp '/https\:\/\/ezproxy\.library\.nyu\.edu\/login\?url=/'
22
- service_types:
23
- - primo_source
24
- - holding_search
25
- - fulltext
26
- - table_of_contents
27
- - referent_enhance
28
- - cover_image })
29
- @base_url = @primo_definition["base_url"]
30
- @vid = @primo_definition["vid"]
31
- @valid_user_id = "N18158418"
32
- @invalid_user_id = "INVALID_USER"
33
- @eshelf_setup = {
34
- :base_url => @base_url,
35
- :vid => @vid,
36
- :resolver_base_url => @primo_definition["resolver_base_url"] }
37
- @valid_institute = "NYU"
38
- @invalid_institute = "INVALID_INST"
39
- @valid_doc_ids = ["nyu_aleph000062856"]
40
- @invalid_doc_ids = ["INVALID_DOC_ID"]
41
- @valid_basket = "298560007"
42
- #@valid_folder = "344619707"
43
- @invalid_basket = "INVALID_BASKET"
44
- end
45
-
46
- def test_new
47
- eshelf = Exlibris::Primo::EShelf.new(@eshelf_setup, @valid_user_id, @valid_institute)
48
- assert_not_nil(eshelf, "#{eshelf.class} returned nil when instantiated.")
49
- assert_equal(@base_url, eshelf.instance_variable_get(:@base_url))
50
- assert_equal(@vid, eshelf.instance_variable_get(:@vid))
51
- assert_equal(@valid_user_id, eshelf.instance_variable_get(:@user_id))
52
- assert_equal(@valid_institute, eshelf.instance_variable_get(:@institution))
53
- assert_nothing_raised{Exlibris::Primo::EShelf.new({:base_url => @base_url}, @valid_user_id, @valid_institute)}
54
- assert_nothing_raised{Exlibris::Primo::EShelf.new({:base_url => @base_url, :vid => @vid}, @valid_user_id, @valid_institute)}
55
- assert_raise(ArgumentError){Exlibris::Primo::EShelf.new({}, @valid_user_id, @valid_institute)}
56
- assert_raise(ArgumentError){Exlibris::Primo::EShelf.new(@eshelf_setup, nil, nil)}
57
- assert_raise(ArgumentError){Exlibris::Primo::EShelf.new(@eshelf_setup, nil, nil)}
58
- assert_raise(ArgumentError){Exlibris::Primo::EShelf.new(@eshelf_setup, @valid_user_id, nil)}
59
- end
60
-
61
- def test_valid_eshelf
62
- eshelf = nil
63
- assert_nil(eshelf)
64
- VCR.use_cassette('eshelf valid eshelf') do
65
- assert_nothing_raised{eshelf = Exlibris::Primo::EShelf.new(@eshelf_setup, @valid_user_id, @valid_institute).eshelf}
66
- assert_not_nil(eshelf)
67
- assert_instance_of(Nokogiri::XML::Document, eshelf)
68
- end
69
- end
70
-
71
- def test_valid_eshelf_structure
72
- VCR.use_cassette('eshelf valid eshelf structure') do
73
- eshelfStructure = nil
74
- assert_nil(eshelfStructure)
75
- assert_nothing_raised{eshelfStructure = Exlibris::Primo::EShelf.new(@eshelf_setup, @valid_user_id, @valid_institute).eshelfStructure}
76
- assert_not_nil(eshelfStructure)
77
- assert(eshelfStructure.is_a? Nokogiri::XML::Document)
78
- end
79
- end
80
-
81
- def test_basket_id
82
- VCR.use_cassette('eshelf valid eshelf structure') do
83
- assert_equal(@valid_basket, Exlibris::Primo::EShelf.new(@eshelf_setup, @valid_user_id, @valid_institute).basket_id)
84
- end
85
- end
86
-
87
- def test_invalid_user_eshelf
88
- ws = nil
89
- assert_nil(ws)
90
- assert_nothing_raised(){ws = Exlibris::Primo::EShelf.new(@eshelf_setup, @invalid_user_id, @valid_institute)}
91
- assert_not_nil(ws)
92
- eshelf = nil
93
- assert_nil(eshelf)
94
- VCR.use_cassette('eshelf invalid eshelf') do
95
- assert_nothing_raised(){eshelf = ws.eshelf}
96
- assert_not_nil(eshelf)
97
- assert_instance_of(Nokogiri::XML::Document, eshelf)
98
- assert_equal(0, ws.count)
99
- end
100
- end
101
-
102
- def test_invalid_institution_eshelf
103
- ws = nil
104
- assert_nil(ws)
105
- assert_nothing_raised(){ws = Exlibris::Primo::EShelf.new(@eshelf_setup, @invalid_user_id, @valid_institute)}
106
- assert_not_nil(ws)
107
- eshelf = nil
108
- assert_nil(eshelf)
109
- VCR.use_cassette('eshelf invalid institution') do
110
- assert_nothing_raised(){eshelf = ws.eshelf}
111
- assert_not_nil(eshelf)
112
- assert_instance_of(Nokogiri::XML::Document, eshelf)
113
- assert_equal(0, ws.count)
114
- end
115
- end
116
-
117
- def test_records
118
- records = nil
119
- assert_nil(records)
120
- VCR.use_cassette('eshelf valid eshelf') do
121
- assert_nothing_raised(){records = Exlibris::Primo::EShelf.new(@eshelf_setup, @valid_user_id, @valid_institute).records}
122
- assert_not_nil(records)
123
- assert_instance_of(Array, records)
124
- assert(!records.empty?, "Eshelf records returned empty")
125
- end
126
- end
127
-
128
- def test_cant_add_same_record_twice
129
- eshelf = Exlibris::Primo::EShelf.new(@eshelf_setup, @valid_user_id, @valid_institute)
130
- assert_not_nil(eshelf)
131
- VCR.use_cassette('eshelf add same record twice') do
132
- # Add record
133
- assert_nothing_raised(){ eshelf.add_records(@valid_doc_ids, @valid_basket) }
134
- # Add same record again
135
- assert_raise(RuntimeError){ eshelf.add_records(@valid_doc_ids, @valid_basket) }
136
- # Remove record
137
- assert_nothing_raised(){ eshelf.remove_records(@valid_doc_ids, @valid_basket) }
138
- end
139
- end
140
-
141
- def test_cant_add_invalid_records
142
- eshelf = Exlibris::Primo::EShelf.new(@eshelf_setup, @valid_user_id, @valid_institute)
143
- assert_not_nil(eshelf)
144
- VCR.use_cassette('eshelf add invalid records') do
145
- # Attempt to add record
146
- assert_raise(RuntimeError){ eshelf.add_records(@invalid_doc_ids, @valid_basket) }
147
- # Attempt to remove record which was never added
148
- assert_raise(RuntimeError){ eshelf.remove_records(@invalid_doc_ids, @valid_basket) }
149
- end
150
- end
151
-
152
- def test_cant_add_to_invalid_basket
153
- eshelf = Exlibris::Primo::EShelf.new(@eshelf_setup, @valid_user_id, @valid_institute)
154
- assert_not_nil(eshelf)
155
- VCR.use_cassette('eshelf add to invalid basket') do
156
- # Attempt to add record to basket with invalid folder name
157
- assert_raise(RuntimeError){ eshelf.add_records(@valid_doc_ids, @invalid_basket) }
158
- end
159
- end
160
-
161
- def test_can_add_to_empty_folder
162
- eshelf = Exlibris::Primo::EShelf.new(@eshelf_setup, @valid_user_id, @valid_institute)
163
- assert_not_nil(eshelf)
164
- VCR.use_cassette('eshelf add to empty basket') do
165
- # Add record to basket with no folder id
166
- assert_nothing_raised(){ eshelf.add_records(@valid_doc_ids, nil) }
167
- # Remove record from basket with no folder id
168
- assert_nothing_raised(){ eshelf.remove_records(@valid_doc_ids, @valid_basket) }
169
- end
170
- end
171
- end
@@ -1,103 +0,0 @@
1
- require 'test_helper'
2
-
3
- class RecordTest < Test::Unit::TestCase
4
-
5
- SEAR_NS = {'sear' => 'http://www.exlibrisgroup.com/xsd/jaguar/search'}
6
-
7
- class SubRecord < Exlibris::Primo::Record
8
- def initialize(parameters={})
9
- super(parameters)
10
- end
11
- end
12
-
13
- def setup
14
- @record_definition = YAML.load( %{
15
- base_url: http://bobcat.library.nyu.edu
16
- resolver_base_url: https://getit.library.nyu.edu/resolve
17
- vid: NYU
18
- institution: NYU
19
- record_id: nyu_aleph000062856 })
20
- @base_url = @record_definition["base_url"]
21
- @resolver_base_url = @record_definition["resolver_base_url"]
22
- @vid = @record_definition["vid"]
23
- @institution = @record_definition["institution"]
24
- @valid_record_id = @record_definition["record_id"]
25
- @invalid_record_id = "INVALID_RECORD"
26
- @setup_args = {
27
- :base_url => @base_url,
28
- :resolver_base_url => @resolver_base_url,
29
- :vid => @vid,
30
- :institution => @institution,
31
- :record_id => @valid_record_id }
32
- end
33
-
34
- def testnew
35
- record = nil
36
- VCR.use_cassette('record valid record') do
37
- assert_nothing_raised(){ record = Exlibris::Primo::Record.new(@setup_args) }
38
- assert_not_nil(record)
39
- assert_not_nil(record.instance_variable_get(:@record_id))
40
- assert_not_nil(record.instance_variable_get(:@type))
41
- assert_not_nil(record.instance_variable_get(:@title))
42
- assert_not_nil(record.instance_variable_get(:@url))
43
- assert_not_nil(record.instance_variable_get(:@openurl))
44
- assert_not_nil(record.instance_variable_get(:@creator))
45
- assert_not_nil(record.instance_variable_get(:@raw_xml))
46
- end
47
- assert_raise(ArgumentError){ Exlibris::Primo::Record.new(@setup_args.merge({:base_url => nil})) }
48
- assert_raise(ArgumentError){ Exlibris::Primo::Record.new(@setup_args.merge({:institution => nil})) }
49
- assert_raise(ArgumentError){ Exlibris::Primo::Record.new(@setup_args.merge({:vid => nil})) }
50
- assert_raise(ArgumentError){ Exlibris::Primo::Record.new(@setup_args.merge({:record_id => nil})) }
51
- VCR.use_cassette('record invalid record') do
52
- assert_raise(RuntimeError){ Exlibris::Primo::Record.new(@setup_args.merge({:record_id => @invalid_record_id})) }
53
- end
54
- end
55
-
56
- def testto_hash_function
57
- VCR.use_cassette('record valid record') do
58
- record = Exlibris::Primo::Record.new(@setup_args)
59
- assert((record.to_h.is_a? Hash), "#{record.class} was expected to be a Hash, was #{record.to_h.class}")
60
- assert(record.to_h["format"], "BOOK")
61
- assert(record.to_h["title"], "Travels with my aunt")
62
- assert(record.to_h["author"], "Graham Greene 1904-1991.")
63
- assert(record.to_h["url"], "#{@base_url}/primo_library/libweb/action/dlDisplay.do?dym=false&onCampus=false&docId=nyu_aleph000062856&institution=#{@institution}&vid=#{@vid}")
64
- end
65
- end
66
-
67
- def testto_json_function
68
- VCR.use_cassette('record valid record') do
69
- record = Exlibris::Primo::Record.new(@setup_args)
70
- assert((record.to_json.is_a? String), "#{record.class} was expected to be a String, was #{record.to_json.class}")
71
- control_hash = JSON.parse(record.to_json)["record"]["control"]
72
- assert_equal("000062856", control_hash["sourcerecordid"])
73
- assert_equal("nyu_aleph", control_hash["sourceid"])
74
- assert_equal("nyu_aleph000062856", control_hash["recordid"])
75
- assert_equal("NYU01", control_hash["originalsourceid"])
76
- assert_equal("NYU01000062856", control_hash["ilsapiid"])
77
- assert_equal("MARC21", control_hash["sourceformat"])
78
- assert_equal("Aleph", control_hash["sourcesystem"])
79
- end
80
- end
81
-
82
- def testsub_class
83
- record = nil
84
- VCR.use_cassette('record sub record') do
85
- assert_nothing_raised(){ record = SubRecord.new(@setup_args) }
86
- assert_not_nil(record)
87
- assert_raise(ArgumentError){ record = SubRecord.new() }
88
- end
89
- end
90
-
91
- def testraw_xml
92
- VCR.use_cassette('record') do
93
- record = Exlibris::Primo::Record.new(@setup_args)
94
- raw_xml = record.instance_variable_get(:@raw_xml)
95
- assert_not_nil(raw_xml)
96
- assert_instance_of(String, raw_xml)
97
- doc = nil
98
- assert_nothing_raised(){ doc = Nokogiri::XML.parse(raw_xml) }
99
- assert_not_nil(doc)
100
- assert(doc.xpath("//record", doc.namespaces).size > 0)
101
- end
102
- end
103
- end
@@ -1,406 +0,0 @@
1
- # encoding: utf-8
2
- require 'test_helper'
3
- class SearcherTest < Test::Unit::TestCase
4
- PNX_NS = {'pnx' => 'http://www.exlibrisgroup.com/xsd/primo/primo_nm_bib'}
5
- SEARCH_NS = {'search' => 'http://www.exlibrisgroup.com/xsd/jaguar/search'}
6
-
7
- def setup
8
- @primo_definition = YAML.load( %{
9
- type: PrimoService
10
- priority: 2 # After SFX, to get SFX metadata enhancement
11
- status: active
12
- base_url: http://bobcat.library.nyu.edu
13
- vid: NYU
14
- institution: NYU
15
- holding_search_institution: NYU
16
- holding_search_text: Search for this title in BobCat.
17
- suppress_holdings: [ !ruby/regexp '/\$\$LBWEB/', !ruby/regexp '/\$\$LNWEB/', !ruby/regexp '/\$\$LTWEB/', !ruby/regexp '/\$\$LWEB/', !ruby/regexp '/\$\$1Restricted Internet Resources/' ]
18
- ez_proxy: !ruby/regexp '/https\:\/\/ezproxy\.library\.nyu\.edu\/login\?url=/'
19
- service_types:
20
- - primo_source
21
- - holding_search
22
- - fulltext
23
- - table_of_contents
24
- - referent_enhance
25
- - cover_image })
26
- @base_url = @primo_definition["base_url"]
27
- @vid = @primo_definition["vid"]
28
- @institution = @primo_definition["institution"]
29
- @primo_holdings_doc_id = "nyu_aleph000062856"
30
- @primo_rsrcs_doc_id = "nyu_aleph002895625"
31
- @primo_tocs_doc_id = "nyu_aleph003149772"
32
- @primo_dedupmrg_doc_id = "dedupmrg17343091"
33
- @primo_test_checked_out_doc_id = "nyu_aleph000089771"
34
- @primo_test_offsite_doc_id = "nyu_aleph002169696"
35
- @primo_test_ill_doc_id = "nyu_aleph001502625"
36
- @primo_test_diacritics1_doc_id = "nyu_aleph002975583"
37
- @primo_test_diacritics2_doc_id = "nyu_aleph003205339"
38
- @primo_test_diacritics3_doc_id = "nyu_aleph003365921"
39
- @primo_test_journals1_doc_id = "nyu_aleph002895625"
40
- @primo_invalid_doc_id = "thisIsNotAValidDocId"
41
- @primo_test_problem_doc_id = "nyu_aleph000509288"
42
- @primo_test_bug1361_id = "ebrroutebr10416506"
43
- @primo_test_isbn = "0143039008"
44
- @primo_test_title = "Travels with My Aunt"
45
- @primo_test_author = "Graham Greene"
46
- @primo_test_genre = "Book"
47
- @searcher_setup = {
48
- :base_url => @base_url,
49
- :institution => @institution,
50
- :vid => @vid,
51
- :config => @primo_definition
52
- }
53
- @searcher_setup_without_config = {
54
- :base_url => @base_url,
55
- :institution => @institution,
56
- :vid => @vid
57
- }
58
- end
59
-
60
- # Test search for a single Primo document.
61
- def testsearch_by_doc_id
62
- VCR.use_cassette('searcher holdings by id') do
63
- searcher = Exlibris::Primo::Searcher.new(@searcher_setup, {:primo_id => @primo_holdings_doc_id})
64
- assert_not_nil(searcher, "#{searcher.class} returned nil when instantiated.")
65
- search_results = searcher.response
66
- assert_instance_of(Nokogiri::XML::Document, search_results, "#{searcher.class} search result is an unexpected object: #{search_results.class}")
67
- 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')}")
68
- assert(searcher.count.to_i > 0, "#{searcher.class} returned 0 results for doc id: #{@primo_holdings_doc_id}.")
69
- end
70
- end
71
-
72
- # Test search for a Primo problem record
73
- def testsearch_by_genre_discrepancy
74
- VCR.use_cassette('searcher test problem by id') do
75
- searcher = Exlibris::Primo::Searcher.new(@searcher_setup, {:primo_id => @primo_test_problem_doc_id})
76
- assert_not_nil(searcher, "#{searcher.class} returned nil when instantiated.")
77
- search_results = searcher.response
78
- assert_instance_of(Nokogiri::XML::Document, search_results, "#{searcher.class} search result is an unexpected object: #{search_results.class}")
79
- 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')}")
80
- assert(searcher.count.to_i > 0, "#{searcher.class} returned 0 results for doc id: #{@primo_test_problem_doc_id}.")
81
- assert_equal(1, searcher.holdings.length, "#{searcher.class} returned unexpected holdings")
82
- end
83
- end
84
-
85
- def testsearch_by_bug1361
86
- VCR.use_cassette('searcher test bug 1361') do
87
- searcher = Exlibris::Primo::Searcher.new(@searcher_setup, {:primo_id => @primo_test_bug1361_id})
88
- assert_not_nil(searcher, "#{searcher.class} returned nil when instantiated.")
89
- search_results = searcher.response
90
- assert_instance_of(Nokogiri::XML::Document, search_results, "#{searcher.class} search result is an unexpected object: #{search_results.class}")
91
- 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')}")
92
- assert(searcher.count.to_i > 0, "#{searcher.class} returned 0 results for doc id: #{@primo_test_bug1361_id}.")
93
- assert_equal(0, searcher.holdings.length, "#{searcher.class} returned unexpected holdings")
94
- assert_equal(4, searcher.rsrcs.length, "#{searcher.class} returned unexpected rsrcs")
95
- end
96
- end
97
-
98
- # Test search for an invalid Primo document.
99
- def testsearch_by_invalid_doc_id
100
- VCR.use_cassette('searcher invalid id') do
101
- assert_raise(RuntimeError) {
102
- searcher = Exlibris::Primo::Searcher.new(@searcher_setup, {:primo_id => @primo_invalid_doc_id})
103
- }
104
- end
105
- end
106
-
107
- # Test invalid setup.
108
- def testsearch_by_invalid_setup1
109
- assert_raise(RuntimeError) {
110
- searcher = Exlibris::Primo::Searcher.new({}, {:primo_id => @primo_invalid_doc_id})
111
- }
112
- end
113
-
114
- # Test invalid setup.
115
- def testsearch_by_invalid_setup2
116
- assert_raise(RuntimeError) {
117
- searcher = Exlibris::Primo::Searcher.new({:base_url => @base_url, :config => nil}, {:primo_id => @primo_invalid_doc_id})
118
- }
119
- end
120
-
121
- # Test base setup search for a single Primo document.
122
- def testsearch_base_setup_record_id
123
- VCR.use_cassette('searcher base holdings by id') do
124
- searcher = Exlibris::Primo::Searcher.new({:base_url => @base_url, :institution => @institution}, {:primo_id => @primo_holdings_doc_id})
125
- holdings = searcher.holdings
126
- assert_instance_of(Array, holdings, "#{searcher.class} holdings is an unexpected object: #{holdings.class}")
127
- assert(holdings.count > 0, "#{searcher.class} returned 0 holdings for doc id: #{@primo_holdings_doc_id}.")
128
- first_holding = holdings.first
129
- assert_instance_of(Exlibris::Primo::Holding, first_holding, "#{searcher.class} first holding is an unexpected object: #{first_holding.class}")
130
- assert_equal("check_holdings", first_holding.status, "#{searcher.class} first holding has an unexpected status: #{first_holding.status}")
131
- assert_equal("NYU", first_holding.institution, "#{searcher.class} first holding has an unexpected institution: #{first_holding.institution}")
132
- assert_equal("BOBST", first_holding.library, "#{searcher.class} first holding has an unexpected library: #{first_holding.library}")
133
- assert_equal("Main Collection", first_holding.collection, "#{searcher.class} first holding has an unexpected collection: #{first_holding.collection}")
134
- assert_equal("(PR6013.R44 T7 2004 )", first_holding.call_number, "#{searcher.class} first holding has an unexpected call number: #{first_holding.call_number}")
135
- end
136
- end
137
-
138
- # Test search by isbn.
139
- def testsearch_by_isbn
140
- VCR.use_cassette('searcher search by isbn') do
141
- searcher = Exlibris::Primo::Searcher.new(@searcher_setup, {:isbn => @primo_test_isbn})
142
- assert_not_nil(searcher, "#{searcher.class} returned nil when instantiated.")
143
- search_results = searcher.response
144
- assert_instance_of(Nokogiri::XML::Document, search_results, "#{searcher.class} search result is an unexpected object: #{search_results.class}")
145
- search_results.search("//search/isbn") do |isbn|
146
- 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')}")
147
- end
148
- assert(searcher.count.to_i > 0, "#{searcher.class} returned 0 results for ISBN: #{@primo_test_isbn}.")
149
- end
150
- end
151
-
152
- # Test search by isbn.
153
- def testsearch_by_issn
154
- VCR.use_cassette('searcher search by issn') do
155
- searcher = Exlibris::Primo::Searcher.new(@searcher_setup_without_config, {:issn => "0002-8614"})
156
- assert_not_nil(searcher, "#{searcher.class} returned nil when instantiated.")
157
- search_results = searcher.response
158
- assert_instance_of(Nokogiri::XML::Document, search_results, "#{searcher.class} search result is an unexpected object: #{search_results.class}")
159
- search_results.search("//search/issn") do |isbn|
160
- assert_not_nil(isbn.inner_text.match("0002-8614"), "#{searcher.class} returned an unexpected record: #{search_results.to_xml(:indent => 5, :encoding => 'UTF-8')}")
161
- end
162
- assert(searcher.count.to_i > 0, "#{searcher.class} returned 0 results for ISSN: 0002-8614.")
163
- end
164
- end
165
-
166
- # Test search by title/author/genre.
167
- def testsearch_by_title_author_genre
168
- VCR.use_cassette('searcher search by title author genre') do
169
- searcher = Exlibris::Primo::Searcher.new(@searcher_setup, {:title => @primo_test_title, :author => @primo_test_author, :genre => @primo_test_genre})
170
- assert_not_nil(searcher, "#{searcher.class} returned nil when instantiated.")
171
- search_results = searcher.response
172
- assert_instance_of(Nokogiri::XML::Document, search_results, "#{searcher.class} search result is an unexpected object: #{search_results.class}")
173
- search_results.search("//search/title") do |title|
174
- 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')}")
175
- end
176
- assert(searcher.count.to_i > 0, "#{searcher.class} returned 0 results for Title: #{@primo_test_title}.")
177
- end
178
- end
179
-
180
- # Test search for a single Primo document w/ holdings.
181
- def testholdings
182
- VCR.use_cassette('searcher holdings by id') do
183
- searcher = Exlibris::Primo::Searcher.new(@searcher_setup, {:primo_id => @primo_holdings_doc_id})
184
- holdings = searcher.holdings
185
- assert_instance_of(Array, holdings,
186
- "#{searcher.class} holdings is an unexpected object: #{holdings.class}")
187
- assert_equal(1, holdings.count,
188
- "#{searcher.class} returned 0 holdings for doc id: #{@primo_holdings_doc_id}.")
189
- first_holding = holdings.first
190
- assert_instance_of(
191
- Exlibris::Primo::Holding,
192
- first_holding,
193
- "#{searcher.class} first holding is an unexpected object: #{first_holding.class}")
194
- test_data = {
195
- :record_id => "nyu_aleph000062856",
196
- :title => "Travels with my aunt",
197
- :author => "Graham Greene 1904-1991.",
198
- :source_id => "nyu_aleph",
199
- :original_source_id => "NYU01",
200
- :source_record_id => "000062856",
201
- :institution_code => "NYU",
202
- :institution => "NYU",
203
- :library_code => "BOBST",
204
- :library => "BOBST",
205
- :status_code => "check_holdings",
206
- :status => "check_holdings",
207
- :id_one => "Main Collection",
208
- :id_two => "(PR6013.R44 T7 2004 )",
209
- :collection => "Main Collection",
210
- :call_number => "(PR6013.R44 T7 2004 )",
211
- :origin => nil,
212
- :display_type => "book",
213
- :coverage => [],
214
- :notes => "",
215
- :url => "#{@base_url}/primo_library/libweb/action/dlDisplay.do?docId=nyu_aleph000062856&institution=NYU&vid=#{@vid}",
216
- :request_url => nil }
217
- test_data.each { |key, value|
218
- assert_equal(
219
- value,
220
- first_holding.send(key),
221
- "#{searcher.class} first holding has an unexpected #{key}: #{first_holding.send(key)}")
222
- }
223
- end
224
- end
225
-
226
- # Test search for a single Primo document w/ rsrcs.
227
- def testrsrcs
228
- VCR.use_cassette('searcher rsrcs by id') do
229
- searcher = Exlibris::Primo::Searcher.new(
230
- @searcher_setup,
231
- { :primo_id => @primo_rsrcs_doc_id })
232
- rsrcs = searcher.rsrcs
233
- assert_instance_of(Array, rsrcs,
234
- "#{searcher.class} rsrcs is an unexpected object: #{rsrcs.class}")
235
- assert_equal(2, rsrcs.count,
236
- "#{searcher.class} returned an unexpected amount of rsrcs (#{rsrcs.count}) for doc id: #{@primo_rsrcs_doc_id}.")
237
- first_rsrc = rsrcs.first
238
- assert_instance_of(
239
- Exlibris::Primo::Rsrc,
240
- first_rsrc,
241
- "#{searcher.class} first rsrc is an unexpected object: #{first_rsrc.class}")
242
- test_data = {
243
- :record_id => "nyu_aleph002895625",
244
- :v => nil,
245
- :url => "https://ezproxy.library.nyu.edu/login?url=http://mq.oxfordjournals.org/",
246
- :display => "Online Version",
247
- :institution_code => "NYU",
248
- :origin => nil,
249
- :notes => "" }
250
- test_data.each { |key, value|
251
- assert_equal(
252
- value,
253
- first_rsrc.send(key),
254
- "#{searcher.class} first rsrc has an unexpected #{key}: #{first_rsrc.send(key)}")
255
- }
256
- end
257
- end
258
-
259
- # Test search for a single Primo document w/ tocs.
260
- def testtocs
261
- VCR.use_cassette('searcher tocs by id') do
262
- searcher = Exlibris::Primo::Searcher.new(
263
- @searcher_setup,
264
- { :primo_id => @primo_tocs_doc_id })
265
- tocs = searcher.tocs
266
- assert_instance_of(Array, tocs,
267
- "#{searcher.class} tocs is an unexpected object: #{tocs.class}")
268
- assert_equal(1, tocs.count,
269
- "#{searcher.class} returned an unexpected amount of tocs (#{tocs.count}) for doc id: #{@primo_tocs_doc_id}.")
270
- first_toc = tocs.last
271
- assert_instance_of(
272
- Exlibris::Primo::Toc,
273
- first_toc,
274
- "#{searcher.class} first toc is an unexpected object: #{first_toc.class}")
275
- test_data = {
276
- :record_id => "nyu_aleph003149772",
277
- :url => "http://www.loc.gov/catdir/toc/onix07/2001024342.html",
278
- :display => "Table of Contents",
279
- :notes => "" }
280
- test_data.each { |key, value|
281
- assert_equal(
282
- value,
283
- first_toc.send(key),
284
- "#{searcher.class} first toc has an unexpected #{key}: #{first_toc.send(key)}")
285
- }
286
- end
287
- end
288
-
289
- def testdedupmrg
290
- VCR.use_cassette('searcher dedupmrg by id') do
291
- searcher = Exlibris::Primo::Searcher.new(
292
- @searcher_setup,
293
- { :primo_id => @primo_dedupmrg_doc_id })
294
- holdings = searcher.holdings
295
- assert_instance_of(Array, holdings,
296
- "#{searcher.class} holdings is an unexpected object: #{holdings.class}")
297
- assert_equal(7, holdings.count,
298
- "#{searcher.class} returned 0 holdings for doc id: #{@primo_dedupmrg_doc_id}.")
299
- first_holding = holdings.first
300
- assert_instance_of(
301
- Exlibris::Primo::Holding,
302
- first_holding,
303
- "#{searcher.class} first holding is an unexpected object: #{first_holding.class}")
304
- test_data = {
305
- :record_id => "dedupmrg17343091",
306
- :title => "The New York times",
307
- :author => "",
308
- :source_id => "nyu_aleph",
309
- :original_source_id => "NYU01",
310
- :source_record_id => "000932393",
311
- :institution_code => "NYU",
312
- :institution => "NYU",
313
- :library_code => "BWEB",
314
- :library => "BWEB",
315
- :status_code => "check_holdings",
316
- :status => "check_holdings",
317
- :id_one => "Internet Resources",
318
- :id_two => "(Newspaper Electronic access )",
319
- :collection => "Internet Resources",
320
- :call_number => "(Newspaper Electronic access )",
321
- :origin => "nyu_aleph000932393",
322
- :display_type => "journal",
323
- :coverage => [],
324
- :notes => "",
325
- :url => "#{@base_url}/primo_library/libweb/action/dlDisplay.do?docId=dedupmrg17343091&institution=NYU&vid=#{@vid}",
326
- :request_url => nil }
327
- test_data.each { |key, value|
328
- assert_equal(
329
- value,
330
- first_holding.send(key),
331
- "#{searcher.class} first holding has an unexpected #{key}: #{first_holding.send(key)}")
332
- }
333
- rsrcs = searcher.rsrcs
334
- assert_instance_of(Array, rsrcs,
335
- "#{searcher.class} rsrcs is an unexpected object: #{rsrcs.class}")
336
- assert_equal(8, rsrcs.count,
337
- "#{searcher.class} returned an unexpected amount of rsrcs (#{rsrcs.count}) for doc id: #{@primo_rsrcs_doc_id}.")
338
- first_rsrc = rsrcs.first
339
- assert_instance_of(
340
- Exlibris::Primo::Rsrc,
341
- first_rsrc,
342
- "#{searcher.class} first rsrc is an unexpected object: #{first_rsrc.class}")
343
- test_data = {
344
- :record_id => "dedupmrg17343091",
345
- :v => "",
346
- :url => "https://ezproxy.library.nyu.edu/login?url=http://proquest.umi.com/pqdweb?RQT=318&VName=PQD&clientid=9269&pmid=7818",
347
- :display => "1995 - Current Access via Proquest",
348
- :institution_code => "NYU",
349
- :origin => "nyu_aleph000932393",
350
- :notes => "" }
351
- test_data.each { |key, value|
352
- assert_equal(
353
- value,
354
- first_rsrc.send(key),
355
- "#{searcher.class} first rsrc has an unexpected #{key}: #{first_rsrc.send(key)}")
356
- }
357
- end
358
- end
359
-
360
- def testholdings_diacritics1
361
- VCR.use_cassette('searcher diacritics1 by id') do
362
- searcher = Exlibris::Primo::Searcher.new(
363
- @searcher_setup,
364
- { :primo_id => @primo_test_diacritics1_doc_id })
365
- assert_equal(
366
- "Rubāʻīyāt-i Bābā Ṭāhir",
367
- searcher.btitle,
368
- "#{searcher.class} has an unexpected btitle: #{searcher.btitle}")
369
- assert_equal(
370
- "Bābā-Ṭāhir, 11th cent",
371
- searcher.au,
372
- "#{searcher.class} has an unexpected author: #{searcher.au}")
373
- end
374
- end
375
-
376
- # This test fails but I don't know why!
377
- # def testholdings_diacritics2
378
- # searcher = Exlibris::Primo::Searcher.new(
379
- # @searcher_setup,
380
- # { :primo_id => @primo_test_diacritics2_doc_id })
381
- # assert_equal(
382
- # "Faraj, Faraj Maḥmūd",
383
- # searcher.au,
384
- # "#{searcher.class} has an unexpected author: #{searcher.au}")
385
- # assert_equal(
386
- # "Iqlīm Tuwāt khilāl al-qarnayn al-thāmin ʻashar wa-al-tāsiʻ ʻashar al-mīlādīyīn : dirāsah li-awḍāʻ al-iqlīm al-siyāsīyah wa-al-ijtimāʻīyah wa-al-iqtiṣādīyah wa-al-thaqāfīyah, maʻa taḥqīq kitāb al-Qawl al-basīṭ fī akhbār Tamanṭīṭ (li-Muḥammad ibn Bābā Ḥaydah)",
387
- # searcher.btitle,
388
- # "#{searcher.class} has an unexpected btitle: #{searcher.btitle}")
389
- # end
390
-
391
- def testholdings_diacritics3
392
- VCR.use_cassette('searcher diacritics2 by id') do
393
- searcher = Exlibris::Primo::Searcher.new(
394
- @searcher_setup,
395
- { :primo_id => @primo_test_diacritics3_doc_id })
396
- assert_equal(
397
- "Mul har ha-gaʻash : ḥoḳre toldot Yiśraʼel le-nokhaḥ ha-Shoʼah",
398
- searcher.btitle,
399
- "#{searcher.class} has an unexpected btitle: #{searcher.btitle}")
400
- assert_equal(
401
- "Engel, David",
402
- searcher.au,
403
- "#{searcher.class} has an unexpected author: #{searcher.au}")
404
- end
405
- end
406
- end