exlibris-primo 0.1.1 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +5 -2
- data/Rakefile +1 -5
- data/lib/exlibris/primo/eshelf.rb +4 -3
- data/lib/exlibris/primo/holding.rb +2 -10
- data/lib/exlibris/primo/record.rb +11 -6
- data/lib/exlibris/primo/searcher.rb +2 -4
- data/lib/exlibris/primo/version.rb +2 -2
- data/test/exlibris-primo_test.rb +3 -3
- data/test/test_helper.rb +33 -7
- data/test/unit/eshelf_test.rb +106 -87
- data/test/unit/record_test.rb +64 -45
- data/test/unit/searcher_benchmarks.rb +20 -28
- data/test/unit/searcher_test.rb +298 -273
- data/test/unit/web_service_benchmarks.rb +19 -21
- data/test/unit/web_service_test.rb +130 -102
- data/test/vcr_cassettes/eshelf_add_invalid_records.yml +107 -0
- data/test/vcr_cassettes/eshelf_add_same_record_twice.yml +159 -0
- data/test/vcr_cassettes/eshelf_add_to_empty_basket.yml +107 -0
- data/test/vcr_cassettes/eshelf_add_to_invalid_basket.yml +55 -0
- data/test/vcr_cassettes/eshelf_invalid_eshelf.yml +55 -0
- data/test/vcr_cassettes/eshelf_invalid_institution.yml +55 -0
- data/test/vcr_cassettes/eshelf_valid_eshelf.yml +2553 -0
- data/test/vcr_cassettes/eshelf_valid_eshelf_structure.yml +47 -0
- data/test/vcr_cassettes/record.yml +212 -0
- data/test/vcr_cassettes/record_invalid_record.yml +55 -0
- data/test/vcr_cassettes/record_sub_record.yml +212 -0
- data/test/vcr_cassettes/record_valid_record.yml +212 -0
- data/test/vcr_cassettes/searcher_base_holdings_by_id.yml +212 -0
- data/test/vcr_cassettes/searcher_dedupmrg_by_id.yml +347 -0
- data/test/vcr_cassettes/searcher_diacritics1_by_id.yml +207 -0
- data/test/vcr_cassettes/searcher_diacritics2_by_id.yml +232 -0
- data/test/vcr_cassettes/searcher_holdings_by_id.yml +212 -0
- data/test/vcr_cassettes/searcher_invalid_id.yml +55 -0
- data/test/vcr_cassettes/searcher_rsrcs_by_id.yml +270 -0
- data/test/vcr_cassettes/searcher_search_by_isbn.yml +278 -0
- data/test/vcr_cassettes/searcher_search_by_issn.yml +297 -0
- data/test/vcr_cassettes/searcher_search_by_title_author_genre.yml +671 -0
- data/test/vcr_cassettes/searcher_test_bug_1361.yml +224 -0
- data/test/vcr_cassettes/searcher_test_problem_by_id.yml +194 -0
- data/test/vcr_cassettes/searcher_tocs_by_id.yml +217 -0
- data/test/vcr_cassettes/web_service_author_search.yml +1269 -0
- data/test/vcr_cassettes/web_service_bogus_200.yml +392 -0
- data/test/vcr_cassettes/web_service_brief_search.yml +299 -0
- data/test/vcr_cassettes/web_service_get_eshelf.yml +11823 -0
- data/test/vcr_cassettes/web_service_get_eshelf_structure_search.yml +47 -0
- data/test/vcr_cassettes/web_service_invalid_document.yml +54 -0
- data/test/vcr_cassettes/web_service_isbn_search.yml +299 -0
- data/test/vcr_cassettes/web_service_issn_search.yml +293 -0
- data/test/vcr_cassettes/web_service_problem_document.yml +193 -0
- data/test/vcr_cassettes/web_service_single_document.yml +233 -0
- data/test/vcr_cassettes/web_service_title_author_genre_search.yml +719 -0
- data/test/vcr_cassettes/web_service_title_search.yml +1035 -0
- metadata +147 -77
- data/lib/tasks/exlibris-primo_tasks.rake +0 -4
- data/test/dummy/README.rdoc +0 -261
- data/test/dummy/Rakefile +0 -7
- data/test/dummy/app/assets/javascripts/application.js +0 -15
- data/test/dummy/app/assets/stylesheets/application.css +0 -13
- data/test/dummy/app/controllers/application_controller.rb +0 -3
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -56
- data/test/dummy/config/boot.rb +0 -10
- data/test/dummy/config/database.yml +0 -25
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -37
- data/test/dummy/config/environments/production.rb +0 -67
- data/test/dummy/config/environments/test.rb +0 -37
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/inflections.rb +0 -15
- data/test/dummy/config/initializers/mime_types.rb +0 -5
- data/test/dummy/config/initializers/secret_token.rb +0 -7
- data/test/dummy/config/initializers/session_store.rb +0 -8
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -5
- data/test/dummy/config/routes.rb +0 -58
- data/test/dummy/db/README +0 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +0 -1704
- data/test/dummy/public/404.html +0 -26
- data/test/dummy/public/422.html +0 -26
- data/test/dummy/public/500.html +0 -25
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +0 -6
data/test/unit/record_test.rb
CHANGED
@@ -1,18 +1,22 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
|
-
class RecordTest <
|
3
|
+
class RecordTest < Test::Unit::TestCase
|
4
4
|
|
5
5
|
SEAR_NS = {'sear' => 'http://www.exlibrisgroup.com/xsd/jaguar/search'}
|
6
6
|
|
7
|
+
class SubRecord < Exlibris::Primo::Record
|
8
|
+
def initialize(parameters={})
|
9
|
+
super(parameters)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
7
13
|
def setup
|
8
14
|
@record_definition = YAML.load( %{
|
9
15
|
base_url: http://bobcat.library.nyu.edu
|
10
16
|
resolver_base_url: https://getit.library.nyu.edu/resolve
|
11
17
|
vid: NYU
|
12
18
|
institution: NYU
|
13
|
-
record_id: nyu_aleph000062856
|
14
|
-
})
|
15
|
-
|
19
|
+
record_id: nyu_aleph000062856 })
|
16
20
|
@base_url = @record_definition["base_url"]
|
17
21
|
@resolver_base_url = @record_definition["resolver_base_url"]
|
18
22
|
@vid = @record_definition["vid"]
|
@@ -20,58 +24,73 @@ class RecordTest < ActiveSupport::TestCase
|
|
20
24
|
@valid_record_id = @record_definition["record_id"]
|
21
25
|
@invalid_record_id = "INVALID_RECORD"
|
22
26
|
@setup_args = {
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
}
|
27
|
+
:base_url => @base_url,
|
28
|
+
:resolver_base_url => @resolver_base_url,
|
29
|
+
:vid => @vid,
|
30
|
+
:institution => @institution,
|
31
|
+
:record_id => @valid_record_id }
|
29
32
|
end
|
30
33
|
|
31
|
-
|
34
|
+
def testnew
|
32
35
|
record = nil
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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
|
42
47
|
assert_raise(ArgumentError){ Exlibris::Primo::Record.new(@setup_args.merge({:base_url => nil})) }
|
43
48
|
assert_raise(ArgumentError){ Exlibris::Primo::Record.new(@setup_args.merge({:institution => nil})) }
|
44
49
|
assert_raise(ArgumentError){ Exlibris::Primo::Record.new(@setup_args.merge({:vid => nil})) }
|
45
50
|
assert_raise(ArgumentError){ Exlibris::Primo::Record.new(@setup_args.merge({:record_id => nil})) }
|
46
|
-
|
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
|
47
54
|
end
|
48
|
-
|
49
|
-
|
50
|
-
record
|
51
|
-
|
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
|
52
65
|
end
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
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 Hash, was #{record.to_json.class}")
|
71
|
+
assert(record.to_json.starts_with? '{"record":{"control":{"sourcerecordid":"000062856","sourceid":"nyu_aleph","recordid":"nyu_aleph000062856","originalsourceid":"NYU01","ilsapiid":"NYU01000062856","sourceformat":"MARC21","sourcesystem":"Aleph"}')
|
59
72
|
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def testsub_class
|
60
76
|
record = nil
|
61
|
-
|
62
|
-
|
63
|
-
|
77
|
+
VCR.use_cassette('record sub record') do
|
78
|
+
assert_nothing_raised(){ record = SubRecord.new(@setup_args) }
|
79
|
+
assert_not_nil(record)
|
80
|
+
assert_raise(ArgumentError){ record = SubRecord.new() }
|
81
|
+
end
|
64
82
|
end
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
83
|
+
|
84
|
+
def testraw_xml
|
85
|
+
VCR.use_cassette('record') do
|
86
|
+
record = Exlibris::Primo::Record.new(@setup_args)
|
87
|
+
raw_xml = record.instance_variable_get(:@raw_xml)
|
88
|
+
assert_not_nil(raw_xml)
|
89
|
+
assert_instance_of(String, raw_xml)
|
90
|
+
doc = nil
|
91
|
+
assert_nothing_raised(){ doc = Nokogiri::XML.parse(raw_xml) }
|
92
|
+
assert_not_nil(doc)
|
93
|
+
assert(doc.xpath("//record", doc.namespaces).size > 0)
|
94
|
+
end
|
75
95
|
end
|
76
|
-
|
77
96
|
end
|
@@ -1,29 +1,27 @@
|
|
1
1
|
require 'test_helper'
|
2
|
-
class SearcherTest <
|
2
|
+
class SearcherTest < Test::Unit::TestCase
|
3
3
|
PNX_NS = {'pnx' => 'http://www.exlibrisgroup.com/xsd/primo/primo_nm_bib'}
|
4
4
|
SEARCH_NS = {'search' => 'http://www.exlibrisgroup.com/xsd/jaguar/search'}
|
5
5
|
|
6
6
|
def setup
|
7
7
|
@primo_definition = YAML.load( %{
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
})
|
26
|
-
|
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 })
|
27
25
|
@base_url = @primo_definition["base_url"]
|
28
26
|
@vid = @primo_definition["vid"]
|
29
27
|
@institution = @primo_definition["institution"]
|
@@ -49,17 +47,11 @@ class SearcherTest < ActiveSupport::TestCase
|
|
49
47
|
:base_url => @base_url,
|
50
48
|
:institution => @institution,
|
51
49
|
:vid => @vid,
|
52
|
-
:config => @
|
53
|
-
}
|
54
|
-
|
55
|
-
@searcher_setup_without_config = {
|
56
|
-
:base_url => @base_url,
|
57
|
-
:institution => @institution,
|
58
|
-
:vid => @vid
|
50
|
+
:config => @primo_definition
|
59
51
|
}
|
60
52
|
end
|
61
53
|
|
62
|
-
|
54
|
+
def testbenchmarks
|
63
55
|
Benchmark.bmbm do |results|
|
64
56
|
results.report("Primo Searcher:") {
|
65
57
|
(1..10).each {
|
data/test/unit/searcher_test.rb
CHANGED
@@ -1,30 +1,28 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'test_helper'
|
3
|
-
class SearcherTest <
|
3
|
+
class SearcherTest < Test::Unit::TestCase
|
4
4
|
PNX_NS = {'pnx' => 'http://www.exlibrisgroup.com/xsd/primo/primo_nm_bib'}
|
5
5
|
SEARCH_NS = {'search' => 'http://www.exlibrisgroup.com/xsd/jaguar/search'}
|
6
6
|
|
7
7
|
def setup
|
8
8
|
@primo_definition = YAML.load( %{
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
})
|
27
|
-
|
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 })
|
28
26
|
@base_url = @primo_definition["base_url"]
|
29
27
|
@vid = @primo_definition["vid"]
|
30
28
|
@institution = @primo_definition["institution"]
|
@@ -52,7 +50,6 @@ class SearcherTest < ActiveSupport::TestCase
|
|
52
50
|
:vid => @vid,
|
53
51
|
:config => @primo_definition
|
54
52
|
}
|
55
|
-
|
56
53
|
@searcher_setup_without_config = {
|
57
54
|
:base_url => @base_url,
|
58
55
|
:institution => @institution,
|
@@ -61,297 +58,323 @@ class SearcherTest < ActiveSupport::TestCase
|
|
61
58
|
end
|
62
59
|
|
63
60
|
# Test search for a single Primo document.
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
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
|
71
70
|
end
|
72
71
|
|
73
72
|
# Test search for a Primo problem record
|
74
|
-
|
75
|
-
searcher
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
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
|
82
83
|
end
|
83
84
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
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
|
93
96
|
end
|
94
97
|
|
95
98
|
# Test search for an invalid Primo document.
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
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
|
100
105
|
end
|
101
106
|
|
102
107
|
# Test invalid setup.
|
103
|
-
|
108
|
+
def testsearch_by_invalid_setup1
|
104
109
|
assert_raise(RuntimeError) {
|
105
110
|
searcher = Exlibris::Primo::Searcher.new({}, {:primo_id => @primo_invalid_doc_id})
|
106
111
|
}
|
107
112
|
end
|
108
113
|
|
109
114
|
# Test invalid setup.
|
110
|
-
|
115
|
+
def testsearch_by_invalid_setup2
|
111
116
|
assert_raise(RuntimeError) {
|
112
117
|
searcher = Exlibris::Primo::Searcher.new({:base_url => @base_url, :config => nil}, {:primo_id => @primo_invalid_doc_id})
|
113
118
|
}
|
114
119
|
end
|
115
120
|
|
116
121
|
# Test base setup search for a single Primo document.
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
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
|
129
136
|
end
|
130
137
|
|
131
138
|
# Test search by isbn.
|
132
|
-
|
133
|
-
searcher
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
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}.")
|
139
149
|
end
|
140
|
-
assert(searcher.count.to_i > 0, "#{searcher.class} returned 0 results for ISBN: #{@primo_test_isbn}.")
|
141
150
|
end
|
142
151
|
|
143
152
|
# Test search by isbn.
|
144
|
-
|
145
|
-
searcher
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
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.")
|
151
163
|
end
|
152
|
-
assert(searcher.count.to_i > 0, "#{searcher.class} returned 0 results for ISSN: 0002-8614.")
|
153
164
|
end
|
154
165
|
|
155
166
|
# Test search by title/author/genre.
|
156
|
-
|
157
|
-
searcher
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
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}.")
|
163
177
|
end
|
164
|
-
assert(searcher.count.to_i > 0, "#{searcher.class} returned 0 results for Title: #{@primo_test_title}.")
|
165
178
|
end
|
166
179
|
|
167
180
|
# Test search for a single Primo document w/ holdings.
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
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
|
209
224
|
end
|
210
225
|
|
211
226
|
# Test search for a single Primo document w/ rsrcs.
|
212
|
-
|
213
|
-
searcher
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
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
|
240
257
|
end
|
241
258
|
|
242
259
|
# Test search for a single Primo document w/ tocs.
|
243
|
-
|
244
|
-
searcher
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
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
|
268
287
|
end
|
269
288
|
|
270
|
-
|
271
|
-
searcher
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
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 })
|
308
365
|
assert_equal(
|
309
|
-
|
310
|
-
|
311
|
-
"#{searcher.class}
|
312
|
-
}
|
313
|
-
rsrcs = searcher.rsrcs
|
314
|
-
assert_instance_of(Array, rsrcs,
|
315
|
-
"#{searcher.class} rsrcs is an unexpected object: #{rsrcs.class}")
|
316
|
-
assert_equal(8, rsrcs.count,
|
317
|
-
"#{searcher.class} returned an unexpected amount of rsrcs (#{rsrcs.count}) for doc id: #{@primo_rsrcs_doc_id}.")
|
318
|
-
first_rsrc = rsrcs.first
|
319
|
-
assert_instance_of(
|
320
|
-
Exlibris::Primo::Rsrc,
|
321
|
-
first_rsrc,
|
322
|
-
"#{searcher.class} first rsrc is an unexpected object: #{first_rsrc.class}")
|
323
|
-
test_data = {
|
324
|
-
:record_id => "dedupmrg17343091",
|
325
|
-
:v => "",
|
326
|
-
:url => "https://ezproxy.library.nyu.edu/login?url=http://proquest.umi.com/pqdweb?RQT=318&VName=PQD&clientid=9269&pmid=7818",
|
327
|
-
:display => "1995 - Current Access via Proquest",
|
328
|
-
:institution_code => "NYU",
|
329
|
-
:origin => "nyu_aleph000932393",
|
330
|
-
:notes => "" }
|
331
|
-
test_data.each { |key, value|
|
366
|
+
"Rubāʻīyāt-i Bābā Ṭāhir",
|
367
|
+
searcher.btitle,
|
368
|
+
"#{searcher.class} has an unexpected btitle: #{searcher.btitle}")
|
332
369
|
assert_equal(
|
333
|
-
|
334
|
-
|
335
|
-
"#{searcher.class}
|
336
|
-
|
370
|
+
"Bābā-Ṭāhir, 11th cent",
|
371
|
+
searcher.au,
|
372
|
+
"#{searcher.class} has an unexpected author: #{searcher.au}")
|
373
|
+
end
|
337
374
|
end
|
338
|
-
|
339
|
-
test "holdings_diacritics1" do
|
340
|
-
searcher = Exlibris::Primo::Searcher.new(
|
341
|
-
@searcher_setup,
|
342
|
-
{ :primo_id => @primo_test_diacritics1_doc_id })
|
343
|
-
assert_equal(
|
344
|
-
"Rubāʻīyāt-i Bābā Ṭāhir",
|
345
|
-
searcher.btitle,
|
346
|
-
"#{searcher.class} has an unexpected btitle: #{searcher.btitle}")
|
347
|
-
assert_equal(
|
348
|
-
"Bābā-Ṭāhir, 11th cent",
|
349
|
-
searcher.au,
|
350
|
-
"#{searcher.class} has an unexpected author: #{searcher.au}")
|
351
|
-
end
|
352
375
|
|
353
376
|
# This test fails but I don't know why!
|
354
|
-
#
|
377
|
+
# def testholdings_diacritics2
|
355
378
|
# searcher = Exlibris::Primo::Searcher.new(
|
356
379
|
# @searcher_setup,
|
357
380
|
# { :primo_id => @primo_test_diacritics2_doc_id })
|
@@ -365,17 +388,19 @@ class SearcherTest < ActiveSupport::TestCase
|
|
365
388
|
# "#{searcher.class} has an unexpected btitle: #{searcher.btitle}")
|
366
389
|
# end
|
367
390
|
|
368
|
-
|
369
|
-
searcher
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
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
|
380
405
|
end
|
381
406
|
end
|