exlibris-aleph 0.1.6 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +89 -0
- data/Rakefile +2 -4
- data/lib/exlibris-aleph.rb +8 -21
- data/lib/exlibris/aleph.rb +13 -0
- data/lib/exlibris/aleph/abstract.rb +28 -0
- data/lib/exlibris/aleph/config.rb +78 -0
- data/lib/exlibris/aleph/patron.rb +71 -56
- data/lib/exlibris/aleph/record.rb +34 -40
- data/lib/exlibris/aleph/rest/base.rb +56 -0
- data/lib/exlibris/aleph/tab_helper.rb +84 -99
- data/lib/exlibris/aleph/{config/config_base.rb → tabs_parser/base.rb} +2 -2
- data/lib/exlibris/aleph/{config → tabs_parser}/pc_tab_exp_field_extended.rb +2 -2
- data/lib/exlibris/aleph/{config/config_by_sub_library.rb → tabs_parser/sub_library.rb} +2 -2
- data/lib/exlibris/aleph/{config → tabs_parser}/tab15_by_item_process_status.rb +2 -2
- data/lib/exlibris/aleph/{config → tabs_parser}/tab15_by_item_status.rb +2 -2
- data/lib/exlibris/aleph/{config → tabs_parser}/tab31.rb +2 -2
- data/lib/exlibris/aleph/{config → tabs_parser}/tab37.rb +2 -2
- data/lib/exlibris/aleph/{config → tabs_parser}/tab40.rb +2 -2
- data/lib/exlibris/aleph/{config → tabs_parser}/tab_sub_library.rb +2 -2
- data/lib/exlibris/aleph/{config → tabs_parser}/tab_www_item_desc.rb +2 -2
- data/lib/exlibris/aleph/task_installer.rb +23 -0
- data/lib/exlibris/aleph/version.rb +1 -1
- data/lib/exlibris/aleph/write_attributes.rb +38 -0
- data/lib/exlibris/aleph/xml_util.rb +50 -0
- data/lib/exlibris/aleph/xservice/bor_auth.rb +47 -0
- data/lib/tasks/exlibris-aleph_tasks.rake +1 -8
- data/test/{dummy/config → config}/aleph/alephe/sub_libraries.yml +0 -1
- data/test/{dummy/config → config}/aleph/nyu50/collections.yml +0 -1
- data/test/{dummy/config → config}/aleph/nyu50/item_permissions_by_item_process_status.yml +0 -1
- data/test/{dummy/config → config}/aleph/nyu50/item_permissions_by_item_status.yml +104 -105
- data/test/{dummy/config → config}/aleph/nyu50/items.yml +0 -1
- data/test/{dummy/config → config}/aleph/nyu50/patron_permissions.yml +27 -28
- data/test/{dummy/config → config}/aleph/nyu50/patrons.yml +0 -1
- data/test/{dummy/config → config}/aleph/nyu50/pickup_locations.yml +0 -1
- data/test/{dummy/config → config}/aleph/nyu51/collections.yml +0 -1
- data/test/{dummy/config → config}/aleph/nyu51/item_permissions_by_item_process_status.yml +0 -1
- data/test/{dummy/config → config}/aleph/nyu51/item_permissions_by_item_status.yml +6 -7
- data/test/{dummy/config → config}/aleph/nyu51/items.yml +0 -1
- data/test/{dummy/config → config}/aleph/nyu51/patron_permissions.yml +27 -28
- data/test/{dummy/config → config}/aleph/nyu51/patrons.yml +0 -1
- data/test/{dummy/config → config}/aleph/nyu51/pickup_locations.yml +0 -1
- data/test/config_test.rb +24 -0
- data/test/patron_test.rb +98 -0
- data/test/{unit/record_benchmarks.rb → record_benchmarks.rb} +0 -0
- data/test/record_test.rb +64 -0
- data/test/support/config.yml +2 -0
- data/test/{unit/tab_helper_benchmarks.rb → tab_helper_benchmarks.rb} +5 -20
- data/test/tab_helper_test.rb +178 -0
- data/test/test_helper.rb +26 -22
- data/test/vcr_cassettes/bor_auth.yml +8 -10
- data/test/vcr_cassettes/patron.yml +77 -18
- data/test/vcr_cassettes/patron_address.yml +45 -0
- data/test/vcr_cassettes/patron_bogus_url.yml +731 -0
- data/test/vcr_cassettes/patron_error.yml +93 -0
- data/test/vcr_cassettes/record.yml +18 -17
- data/test/vcr_cassettes/record_bogus_url.yml +690 -0
- data/test/{unit → xservice}/bor_auth_test.rb +4 -4
- metadata +160 -150
- data/README.rdoc +0 -67
- data/lib/exlibris/aleph/bor_auth.rb +0 -45
- data/lib/exlibris/aleph/railtie.rb +0 -9
- data/lib/exlibris/aleph/rest.rb +0 -43
- data/lib/exlibris/aleph/tasks.rb +0 -25
- 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/aleph.rb +0 -1
- 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/aleph/aleph_tab_helper.log +0 -1
- data/test/dummy/log/aleph/tab_helper.log +0 -109
- data/test/dummy/log/tab_helper.log +0 -16
- data/test/dummy/log/test.log +0 -5160
- 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/patron_test.rb +0 -41
- data/test/unit/record_test.rb +0 -32
- data/test/unit/tab_helper_test.rb +0 -222
data/test/config_test.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
class ConfigTest < Test::Unit::TestCase
|
3
|
+
def test_config
|
4
|
+
reset_aleph_configuration
|
5
|
+
Exlibris::Aleph.configure do |config|
|
6
|
+
config.base_url = "test_url"
|
7
|
+
config.adms = ["ADM1", "ADM2"]
|
8
|
+
end
|
9
|
+
assert_equal "test_url", Exlibris::Aleph::Config.base_url
|
10
|
+
assert_equal "test_url:1891/rest-dlf", Exlibris::Aleph::Config.rest_url
|
11
|
+
assert_equal ["ADM1", "ADM2"], Exlibris::Aleph::Config.adms
|
12
|
+
reset_aleph_configuration
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_config_from_yaml
|
16
|
+
reset_aleph_configuration
|
17
|
+
yaml_aleph_configuration
|
18
|
+
assert_equal "http://aleph.library.nyu.edu", Exlibris::Aleph::Config.base_url
|
19
|
+
assert_equal "http://aleph.library.nyu.edu:1891/rest-dlf", Exlibris::Aleph::Config.rest_url
|
20
|
+
assert_equal ["NYU50", "NYU51"], Exlibris::Aleph::Config.adms
|
21
|
+
assert_nil(Exlibris::Aleph::Config.tab_path)
|
22
|
+
reset_aleph_configuration
|
23
|
+
end
|
24
|
+
end
|
data/test/patron_test.rb
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
class PatronTest < ActiveSupport::TestCase
|
3
|
+
setup do
|
4
|
+
@rest_url = "http://aleph.library.nyu.edu:1891/rest-dlf"
|
5
|
+
@aleph_doc_library = "NYU01"
|
6
|
+
@aleph_doc_number = "000062856"
|
7
|
+
@nyuidn = "BOR_ID"
|
8
|
+
@aleph_adm_library = "NYU50"
|
9
|
+
@aleph_item_id = "NYU50000062856000010"
|
10
|
+
@aleph_renew_item_id = "NYU50003034208"
|
11
|
+
@pickup_location = "BOBST"
|
12
|
+
@bogus_url = "http://library.nyu.edu/bogus"
|
13
|
+
end
|
14
|
+
|
15
|
+
# Test exception handling for bogus response.
|
16
|
+
test "test_bogus_response" do
|
17
|
+
VCR.use_cassette('patron bogus url') do
|
18
|
+
patron = Exlibris::Aleph::Patron.new(patron_id: @nyuidn, rest_url: @bogus_url)
|
19
|
+
assert_raise(MultiXml::ParseError) { patron.loans }
|
20
|
+
assert_raise(MultiXml::ParseError) { patron.renew_loans() }
|
21
|
+
assert_raise(MultiXml::ParseError) { patron.renew_loans(@aleph_renew_item_id) }
|
22
|
+
assert_raise(MultiXml::ParseError) { patron.place_hold(@aleph_adm_library, @aleph_doc_library, @aleph_doc_number, @aleph_item_id, {:pickup_location => @pickup_location}) }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Test patron
|
27
|
+
test "test_patron" do
|
28
|
+
VCR.use_cassette('patron') do
|
29
|
+
patron = Exlibris::Aleph::Patron.new(patron_id: @nyuidn, rest_url: @rest_url)
|
30
|
+
loans = patron.loans
|
31
|
+
assert_kind_of Array, loans
|
32
|
+
assert((not loans.empty?), "Loans empty.")
|
33
|
+
loans.each { |loan| assert_kind_of Hash, loan }
|
34
|
+
assert_nil(patron.error, "Failure in #{patron.class} while getting loans: #{patron.error}")
|
35
|
+
renew_all_loans = patron.renew_loans()
|
36
|
+
assert_kind_of Array, renew_all_loans
|
37
|
+
assert((not renew_all_loans.empty?), "Renew all loans empty.")
|
38
|
+
renew_all_loans.each { |renew_all_loan| assert_kind_of Hash, renew_all_loan }
|
39
|
+
assert_nil(patron.error, "Failure in #{patron.class} while renewing all loans: #{patron.error}")
|
40
|
+
renew_loans = patron.renew_loans(@aleph_renew_item_id)
|
41
|
+
assert_kind_of Array, renew_loans
|
42
|
+
assert((not renew_loans.empty?), "Renew loans empty.")
|
43
|
+
renew_loans.each { |renew_loan| assert_kind_of Hash, renew_loan }
|
44
|
+
assert_nil(patron.error, "Failure in #{patron.class} while renewing loan #{@aleph_renew_item_id}: #{patron.error}")
|
45
|
+
place_hold = patron.place_hold(@aleph_adm_library, @aleph_doc_library, @aleph_doc_number, @aleph_item_id, {:pickup_location => @pickup_location})
|
46
|
+
assert_kind_of Hash, place_hold
|
47
|
+
assert_nil(patron.error, "Failure in #{patron.class} while placing hold: #{patron.error}")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Test patron
|
52
|
+
test "test patron address" do
|
53
|
+
VCR.use_cassette('patron address') do
|
54
|
+
patron = Exlibris::Aleph::Patron.new(patron_id: @nyuidn, rest_url: @rest_url)
|
55
|
+
address = patron.address
|
56
|
+
assert_kind_of Hash, address
|
57
|
+
assert_nil(patron.error, "Failure in #{patron.class} while getting address: #{patron.error}")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Test patron
|
62
|
+
test "test patron error" do
|
63
|
+
VCR.use_cassette('patron error') do
|
64
|
+
patron = Exlibris::Aleph::Patron.new(patron_id: @nyuidn, rest_url: @rest_url)
|
65
|
+
assert_raise(RuntimeError) { patron.place_hold(@aleph_adm_library, @aleph_doc_library, @aleph_doc_number, @aleph_item_id, {}) }
|
66
|
+
assert_raise(RuntimeError) { patron.renew_loans() }
|
67
|
+
assert_raise(RuntimeError) { patron.renew_loans(@aleph_renew_item_id) }
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# Test patron with URL set via config
|
72
|
+
test "test patron with global config" do
|
73
|
+
Exlibris::Aleph.configure do |c|
|
74
|
+
c.base_url = "http://aleph.library.nyu.edu"
|
75
|
+
end
|
76
|
+
VCR.use_cassette('patron') do
|
77
|
+
patron = Exlibris::Aleph::Patron.new(patron_id: @nyuidn)
|
78
|
+
loans = patron.loans
|
79
|
+
assert_kind_of Array, loans
|
80
|
+
assert((not loans.empty?), "Loans empty.")
|
81
|
+
loans.each { |loan| assert_kind_of Hash, loan }
|
82
|
+
assert_nil(patron.error, "Failure in #{patron.class} while getting loans: #{patron.error}")
|
83
|
+
renew_all_loans = patron.renew_loans()
|
84
|
+
assert_kind_of Array, renew_all_loans
|
85
|
+
assert((not renew_all_loans.empty?), "Renew all loans empty.")
|
86
|
+
renew_all_loans.each { |renew_all_loan| assert_kind_of Hash, renew_all_loan }
|
87
|
+
assert_nil(patron.error, "Failure in #{patron.class} while renewing all loans: #{patron.error}")
|
88
|
+
renew_loans = patron.renew_loans(@aleph_renew_item_id)
|
89
|
+
assert_kind_of Array, renew_loans
|
90
|
+
assert((not renew_loans.empty?), "Renew loans empty.")
|
91
|
+
renew_loans.each { |renew_loan| assert_kind_of Hash, renew_loan }
|
92
|
+
assert_nil(patron.error, "Failure in #{patron.class} while renewing loan #{@aleph_renew_item_id}: #{patron.error}")
|
93
|
+
place_hold = patron.place_hold(@aleph_adm_library, @aleph_doc_library, @aleph_doc_number, @aleph_item_id, {:pickup_location => @pickup_location})
|
94
|
+
assert_kind_of Hash, place_hold
|
95
|
+
assert_nil(patron.error, "Failure in #{patron.class} while placing hold: #{patron.error}")
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
File without changes
|
data/test/record_test.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
class RecordTest < ActiveSupport::TestCase
|
3
|
+
def setup
|
4
|
+
@rest_url = "http://aleph.library.nyu.edu:1891/rest-dlf"
|
5
|
+
@aleph_doc_library = "NYU01"
|
6
|
+
@aleph_doc_number = "000062856"
|
7
|
+
@bogus_url = "http://library.nyu.edu/bogus"
|
8
|
+
end
|
9
|
+
|
10
|
+
# Test exception handling for bogus url
|
11
|
+
test "bogus_response" do
|
12
|
+
VCR.use_cassette('record bogus url') do
|
13
|
+
aleph_record = Exlibris::Aleph::Record.new(bib_library: @aleph_doc_library, record_id: @aleph_doc_number, rest_url: @bogus_url)
|
14
|
+
assert_raise(MultiXml::ParseError) { aleph_record.bib }
|
15
|
+
assert_raise(MultiXml::ParseError) { aleph_record.holdings }
|
16
|
+
assert_raise(MultiXml::ParseError) { aleph_record.items }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# Test record.
|
21
|
+
test "record" do
|
22
|
+
VCR.use_cassette('record') do
|
23
|
+
aleph_record = Exlibris::Aleph::Record.new(bib_library: @aleph_doc_library, record_id: @aleph_doc_number, rest_url: @rest_url)
|
24
|
+
bib = aleph_record.bib
|
25
|
+
assert_kind_of MARC::Record, bib
|
26
|
+
assert_equal "Travels with my aunt /", bib['245']['a']
|
27
|
+
assert_nil(aleph_record.error, "Failure in #{aleph_record.class} while calling bib: #{aleph_record.error}")
|
28
|
+
holdings = aleph_record.holdings
|
29
|
+
assert_kind_of Array, holdings
|
30
|
+
assert((not holdings.empty?), "Holdings empty.")
|
31
|
+
holdings.each { |holding| assert_kind_of MARC::Record, holding }
|
32
|
+
assert_nil(aleph_record.error, "Failure in #{aleph_record.class} while calling holdings: #{aleph_record.error}")
|
33
|
+
items = aleph_record.items
|
34
|
+
assert_kind_of Array, items
|
35
|
+
assert((not items.empty?), "Items empty.")
|
36
|
+
items.each { |item| assert_kind_of Hash, item }
|
37
|
+
assert_nil(aleph_record.error, "Failure in #{aleph_record.class} while calling items: #{aleph_record.error}")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Test record.
|
42
|
+
test "record with global config" do
|
43
|
+
Exlibris::Aleph.configure do |c|
|
44
|
+
c.base_url = "http://aleph.library.nyu.edu"
|
45
|
+
end
|
46
|
+
VCR.use_cassette('record') do
|
47
|
+
aleph_record = Exlibris::Aleph::Record.new(bib_library: @aleph_doc_library, record_id: @aleph_doc_number)
|
48
|
+
bib = aleph_record.bib
|
49
|
+
assert_kind_of MARC::Record, bib
|
50
|
+
assert_equal "Travels with my aunt /", bib['245']['a']
|
51
|
+
assert_nil(aleph_record.error, "Failure in #{aleph_record.class} while calling bib: #{aleph_record.error}")
|
52
|
+
holdings = aleph_record.holdings
|
53
|
+
assert_kind_of Array, holdings
|
54
|
+
assert((not holdings.empty?), "Holdings empty.")
|
55
|
+
holdings.each { |holding| assert_kind_of MARC::Record, holding }
|
56
|
+
assert_nil(aleph_record.error, "Failure in #{aleph_record.class} while calling holdings: #{aleph_record.error}")
|
57
|
+
items = aleph_record.items
|
58
|
+
assert_kind_of Array, items
|
59
|
+
assert((not items.empty?), "Items empty.")
|
60
|
+
items.each { |item| assert_kind_of Hash, item }
|
61
|
+
assert_nil(aleph_record.error, "Failure in #{aleph_record.class} while calling items: #{aleph_record.error}")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -1,28 +1,16 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
class TabHelperBenchmarks < ActiveSupport::TestCase
|
3
3
|
def setup
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
Exlibris::Aleph::TabHelper.class_variable_set(:@@adms, [])
|
4
|
+
Exlibris::Aleph.configure { |c|
|
5
|
+
c.adms = ["NYU50", "NYU51"]
|
6
|
+
c.tab_path = "#{File.dirname(__FILE__)}/mnt/aleph_tab"
|
7
|
+
c.yml_path = File.join(File.dirname(__FILE__), "config/aleph")
|
8
|
+
}
|
10
9
|
@TESTS = 10
|
11
10
|
end
|
12
11
|
|
13
|
-
# Get benchmarks for the Aleph TabHelper
|
14
|
-
test "benchmarks_init" do
|
15
|
-
# Display performance benchmarks.
|
16
|
-
time = Benchmark.bmbm do |results|
|
17
|
-
results.report("TabHelper init:") { @TESTS.times {
|
18
|
-
Exlibris::Aleph::TabHelper.init(@tab_path, @adms)
|
19
|
-
} }
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
12
|
# Get benchmarks for the Aleph TabHelper
|
24
13
|
test "benchmarks_refresh_yml" do
|
25
|
-
Exlibris::Aleph::TabHelper.init(@tab_path, @adms)
|
26
14
|
# Display performance benchmarks.
|
27
15
|
time = Benchmark.bmbm do |results|
|
28
16
|
results.report("TabHelper refresh_yml:") { @TESTS.times {
|
@@ -33,7 +21,6 @@ class TabHelperBenchmarks < ActiveSupport::TestCase
|
|
33
21
|
|
34
22
|
# Get benchmarks for the Aleph TabHelper
|
35
23
|
test "benchmarks_new" do
|
36
|
-
Exlibris::Aleph::TabHelper.init(@tab_path, @adms)
|
37
24
|
# Display performance benchmarks.
|
38
25
|
time = Benchmark.bmbm do |results|
|
39
26
|
results.report("TabHelper new:") { @TESTS.times {
|
@@ -44,7 +31,6 @@ class TabHelperBenchmarks < ActiveSupport::TestCase
|
|
44
31
|
|
45
32
|
# Get benchmarks for the Aleph TabHelper
|
46
33
|
test "benchmarks_instance" do
|
47
|
-
Exlibris::Aleph::TabHelper.init(@tab_path, @adms)
|
48
34
|
Exlibris::Aleph::TabHelper.send(:new)
|
49
35
|
# Display performance benchmarks.
|
50
36
|
time = Benchmark.bmbm do |results|
|
@@ -56,7 +42,6 @@ class TabHelperBenchmarks < ActiveSupport::TestCase
|
|
56
42
|
|
57
43
|
# Get benchmarks for the Aleph TabHelper
|
58
44
|
test "benchmarks_refresh" do
|
59
|
-
Exlibris::Aleph::TabHelper.init(@tab_path, @adms)
|
60
45
|
helper = Exlibris::Aleph::TabHelper.instance
|
61
46
|
# Display performance benchmarks.
|
62
47
|
time = Benchmark.bmbm do |results|
|
@@ -0,0 +1,178 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
class TabHelperTest < ActiveSupport::TestCase
|
3
|
+
def setup
|
4
|
+
@adms = ["NYU50", "NYU51"]
|
5
|
+
@tab_path = "#{File.dirname(__FILE__)}/mnt/aleph_tab"
|
6
|
+
@yml_path = File.join(File.dirname(__FILE__), "config/aleph")
|
7
|
+
Exlibris::Aleph.configure { |c|
|
8
|
+
c.adms = @adms
|
9
|
+
c.tab_path = @tab_path
|
10
|
+
c.yml_path = @yml_path
|
11
|
+
}
|
12
|
+
@helper = Exlibris::Aleph::TabHelper.instance
|
13
|
+
end
|
14
|
+
|
15
|
+
test "configure" do
|
16
|
+
assert_equal(["nyu50", "nyu51"], @helper.adms)
|
17
|
+
assert_equal(File.join(File.dirname(__FILE__), "mnt/aleph_tab"), @helper.class.tab_path)
|
18
|
+
assert_equal(File.join(File.dirname(__FILE__), "config/aleph"), @helper.class.yml_path)
|
19
|
+
end
|
20
|
+
|
21
|
+
test "instance" do
|
22
|
+
assert_nothing_raised() { Exlibris::Aleph::TabHelper.send(:new) }
|
23
|
+
assert_same(@helper, Exlibris::Aleph::TabHelper.instance)
|
24
|
+
end
|
25
|
+
|
26
|
+
test "refresh" do
|
27
|
+
@helper.instance_variable_set(:@refresh_time, lambda{1.second.ago})
|
28
|
+
@helper.sub_libraries
|
29
|
+
updated_at_1 = @helper.updated_at
|
30
|
+
@helper.sub_libraries
|
31
|
+
updated_at_2 = @helper.updated_at
|
32
|
+
assert_equal(updated_at_1, updated_at_2)
|
33
|
+
sleep 1
|
34
|
+
@helper.sub_libraries
|
35
|
+
assert_not_equal(updated_at_1, @helper.updated_at)
|
36
|
+
@helper.instance_variable_set(:@refresh_time, @helper.class.refresh_time)
|
37
|
+
end
|
38
|
+
|
39
|
+
test "sub_library_text" do
|
40
|
+
assert_equal("NYU Bobst", @helper.sub_library_text("BOBST"))
|
41
|
+
end
|
42
|
+
|
43
|
+
test "sub_library_adm" do
|
44
|
+
assert_equal("NYU50", @helper.sub_library_adm("BOBST"))
|
45
|
+
end
|
46
|
+
|
47
|
+
test "item_pickup_locations" do
|
48
|
+
assert_equal(
|
49
|
+
["BOBST", "NCOUR", "NIFA", "NISAW", "NREI", "NPOLY", "NYUAB", "NYUSE", "NYUSS"],
|
50
|
+
@helper.item_pickup_locations({:adm_library_code => "nyu50", :sub_library_code => "BOBST", :bor_status => "51"}))
|
51
|
+
end
|
52
|
+
|
53
|
+
test "collection_text" do
|
54
|
+
assert_equal(
|
55
|
+
"Main Collection",
|
56
|
+
@helper.collection_text({:adm_library_code => "nyu50", :sub_library_code => "BOBST", :collection_code => "MAIN"}))
|
57
|
+
end
|
58
|
+
|
59
|
+
test "item_web_text" do
|
60
|
+
assert_equal(
|
61
|
+
"Offsite Available",
|
62
|
+
@helper.item_web_text({:adm_library_code => "nyu50", :item_process_status => "Depository"}))
|
63
|
+
assert_equal(
|
64
|
+
"Offsite Available",
|
65
|
+
@helper.item_web_text({:adm_library_code => "nyu50", :sub_library_code => "BOBST", :item_process_status_code => "DP"}))
|
66
|
+
end
|
67
|
+
|
68
|
+
test "sub_libraries" do
|
69
|
+
assert_equal("BOBST", @helper.sub_libraries["BOBST"][:code])
|
70
|
+
assert_equal("NYU Bobst", @helper.sub_libraries["BOBST"][:text])
|
71
|
+
assert_equal("NYU50", @helper.sub_libraries["BOBST"][:library])
|
72
|
+
end
|
73
|
+
|
74
|
+
test "patrons" do
|
75
|
+
assert_equal("51", @helper.patrons["nyu50"]["51"][:code])
|
76
|
+
assert_equal("NYU Administrator", @helper.patrons["nyu50"]["51"][:text])
|
77
|
+
end
|
78
|
+
|
79
|
+
test "patron_permissions" do
|
80
|
+
assert_equal("BOBST", @helper.patron_permissions["nyu50"]["BOBST"]["51"][:sub_library])
|
81
|
+
assert_equal("51", @helper.patron_permissions["nyu50"]["BOBST"]["51"][:patron_status])
|
82
|
+
assert_equal("Y", @helper.patron_permissions["nyu50"]["BOBST"]["51"][:loan_permission])
|
83
|
+
assert_equal("Y", @helper.patron_permissions["nyu50"]["BOBST"]["51"][:photo_permission])
|
84
|
+
assert_equal("Y", @helper.patron_permissions["nyu50"]["BOBST"]["51"][:override_permission])
|
85
|
+
assert_equal("N", @helper.patron_permissions["nyu50"]["BOBST"]["51"][:multiple_hold_permission])
|
86
|
+
assert_equal("Y", @helper.patron_permissions["nyu50"]["BOBST"]["51"][:check_loan])
|
87
|
+
assert_equal("Y", @helper.patron_permissions["nyu50"]["BOBST"]["51"][:hold_permission])
|
88
|
+
assert_equal("Y", @helper.patron_permissions["nyu50"]["BOBST"]["51"][:renew_permission])
|
89
|
+
assert_equal("Y", @helper.patron_permissions["nyu50"]["BOBST"]["51"][:hold_request_permission_for_item_on_shelf])
|
90
|
+
assert_equal("N", @helper.patron_permissions["nyu50"]["BOBST"]["51"][:loan_display])
|
91
|
+
assert_equal("N", @helper.patron_permissions["nyu50"]["BOBST"]["51"][:reading_room_permission])
|
92
|
+
assert_equal("N", @helper.patron_permissions["nyu50"]["BOBST"]["51"][:item_booking_permission])
|
93
|
+
assert_equal("N", @helper.patron_permissions["nyu50"]["BOBST"]["51"][:booking_ignore_closing_hours])
|
94
|
+
assert_equal("N", @helper.patron_permissions["nyu50"]["BOBST"]["51"][:automatically_create_aleph_record])
|
95
|
+
end
|
96
|
+
|
97
|
+
test "items" do
|
98
|
+
assert_equal("ITEM-STATUS", @helper.items["nyu50"]["Billed as lost"][:code])
|
99
|
+
assert_equal("Billed as lost", @helper.items["nyu50"]["Billed as lost"][:original_text])
|
100
|
+
assert_equal("Request ILL", @helper.items["nyu50"]["Billed as lost"][:web_text])
|
101
|
+
end
|
102
|
+
|
103
|
+
test "item_permissions_by_item_status" do
|
104
|
+
assert_equal("BOBST", @helper.item_permissions_by_item_status["nyu50"]["BOBST"]["01"][:sub_library])
|
105
|
+
assert_equal("01", @helper.item_permissions_by_item_status["nyu50"]["BOBST"]["01"][:item_status])
|
106
|
+
assert_equal("Regular loan", @helper.item_permissions_by_item_status["nyu50"]["BOBST"]["01"][:text])
|
107
|
+
assert_equal("Y", @helper.item_permissions_by_item_status["nyu50"]["BOBST"]["01"][:loan])
|
108
|
+
assert_equal("Y", @helper.item_permissions_by_item_status["nyu50"]["BOBST"]["01"][:renew])
|
109
|
+
assert_equal("Y", @helper.item_permissions_by_item_status["nyu50"]["BOBST"]["01"][:hold_request])
|
110
|
+
assert_equal("N", @helper.item_permissions_by_item_status["nyu50"]["BOBST"]["01"][:photocopy_request])
|
111
|
+
assert_equal("Y", @helper.item_permissions_by_item_status["nyu50"]["BOBST"]["01"][:web_opac])
|
112
|
+
assert_equal("N", @helper.item_permissions_by_item_status["nyu50"]["BOBST"]["01"][:specific_item])
|
113
|
+
assert_equal("N", @helper.item_permissions_by_item_status["nyu50"]["BOBST"]["01"][:limit_hold])
|
114
|
+
assert_equal("Y", @helper.item_permissions_by_item_status["nyu50"]["BOBST"]["01"][:recall])
|
115
|
+
assert_equal("N", @helper.item_permissions_by_item_status["nyu50"]["BOBST"]["01"][:rush_recall])
|
116
|
+
assert_equal("N", @helper.item_permissions_by_item_status["nyu50"]["BOBST"]["01"][:booking_permission])
|
117
|
+
assert_equal("00", @helper.item_permissions_by_item_status["nyu50"]["BOBST"]["01"][:reloaning_limit])
|
118
|
+
assert_equal("A", @helper.item_permissions_by_item_status["nyu50"]["BOBST"]["01"][:booking_hours])
|
119
|
+
end
|
120
|
+
|
121
|
+
test "item_permissions_by_item_process_status" do
|
122
|
+
assert_equal("BOBST", @helper.item_permissions_by_item_process_status["nyu50"]["BOBST"]["AC"][:sub_library])
|
123
|
+
assert_equal("AC", @helper.item_permissions_by_item_process_status["nyu50"]["BOBST"]["AC"][:item_process_status])
|
124
|
+
assert_equal("AFC-Post cataloging", @helper.item_permissions_by_item_process_status["nyu50"]["BOBST"]["AC"][:text])
|
125
|
+
assert_equal("Y", @helper.item_permissions_by_item_process_status["nyu50"]["BOBST"]["AC"][:loan])
|
126
|
+
assert_equal("Y", @helper.item_permissions_by_item_process_status["nyu50"]["BOBST"]["AC"][:renew])
|
127
|
+
assert_equal("Y", @helper.item_permissions_by_item_process_status["nyu50"]["BOBST"]["AC"][:hold_request])
|
128
|
+
assert_equal("N", @helper.item_permissions_by_item_process_status["nyu50"]["BOBST"]["AC"][:photocopy_request])
|
129
|
+
assert_equal("Y", @helper.item_permissions_by_item_process_status["nyu50"]["BOBST"]["AC"][:web_opac])
|
130
|
+
assert_equal("Y", @helper.item_permissions_by_item_process_status["nyu50"]["BOBST"]["AC"][:specific_item])
|
131
|
+
assert_equal("N", @helper.item_permissions_by_item_process_status["nyu50"]["BOBST"]["AC"][:limit_hold])
|
132
|
+
assert_equal("Y", @helper.item_permissions_by_item_process_status["nyu50"]["BOBST"]["AC"][:recall])
|
133
|
+
assert_equal("N", @helper.item_permissions_by_item_process_status["nyu50"]["BOBST"]["AC"][:rush_recall])
|
134
|
+
assert_equal("N", @helper.item_permissions_by_item_process_status["nyu50"]["BOBST"]["AC"][:booking_permission])
|
135
|
+
assert_equal("00", @helper.item_permissions_by_item_process_status["nyu50"]["BOBST"]["AC"][:reloaning_limit])
|
136
|
+
assert_equal("A", @helper.item_permissions_by_item_process_status["nyu50"]["BOBST"]["AC"][:booking_hours])
|
137
|
+
end
|
138
|
+
|
139
|
+
test "collections" do
|
140
|
+
assert_equal("BOBST", @helper.collections["nyu50"]["BOBST"]["MAIN"][:sub_library])
|
141
|
+
assert_equal("MAIN", @helper.collections["nyu50"]["BOBST"]["MAIN"][:collection_code])
|
142
|
+
assert_equal("Main Collection", @helper.collections["nyu50"]["BOBST"]["MAIN"][:text])
|
143
|
+
end
|
144
|
+
|
145
|
+
test "pickup_locations" do
|
146
|
+
assert_equal("BOBST", @helper.pickup_locations["nyu50"]["BOBST"]["##"]["DP"]["51"]["Y"][:sub_library])
|
147
|
+
assert_equal("##", @helper.pickup_locations["nyu50"]["BOBST"]["##"]["DP"]["51"]["Y"][:item_status])
|
148
|
+
assert_equal("DP", @helper.pickup_locations["nyu50"]["BOBST"]["##"]["DP"]["51"]["Y"][:item_process_status])
|
149
|
+
assert_equal("51", @helper.pickup_locations["nyu50"]["BOBST"]["##"]["DP"]["51"]["Y"][:patron_status])
|
150
|
+
assert_equal("Y", @helper.pickup_locations["nyu50"]["BOBST"]["##"]["DP"]["51"]["Y"][:availability_status])
|
151
|
+
assert_equal(["BOBST", "NCOUR", "NIFA", "NISAW", "NREI", "NPOLY", "NYUAB", "NYUSE", "NYUSS"], @helper.pickup_locations["nyu50"]["BOBST"]["##"]["DP"]["51"]["Y"][:pickup_locations])
|
152
|
+
end
|
153
|
+
|
154
|
+
test "pickup_locations on multiple lines" do
|
155
|
+
assert_equal(["BOBST", "NCOUR", "NIFA","NISAW","NREI","NPOLY","NYUAB","NBERL",
|
156
|
+
"NFLOR","NLOND","NPRAG","NWADC"], @helper.pickup_locations["nyu50"]["BOBST"]["##"]["##"]["89"]["#"][:pickup_locations])
|
157
|
+
end
|
158
|
+
|
159
|
+
test "refresh_yml" do
|
160
|
+
assert_nil(@helper.sub_libraries["NEW__"])
|
161
|
+
sub_library_file = "#{File.dirname(__FILE__)}/mnt/aleph_tab/alephe/tab/tab_sub_library.eng"
|
162
|
+
file = File.open(sub_library_file, 'r')
|
163
|
+
old_size = File.size(sub_library_file)
|
164
|
+
file.close
|
165
|
+
# Update the file.
|
166
|
+
File.open(sub_library_file, 'a') {|f| f.puts "NEW__ 1 NYU50 L NYU TEST BOBST BOBST BOBST BOBST NYU50 ALEPH" }
|
167
|
+
Exlibris::Aleph::TabHelper.refresh_yml
|
168
|
+
@helper.send(:refresh)
|
169
|
+
assert_not_nil(@helper.sub_libraries["NEW__"])
|
170
|
+
assert_equal("NEW__", @helper.sub_libraries["NEW__"][:code])
|
171
|
+
assert_equal("NYU TEST", @helper.sub_libraries["NEW__"][:text])
|
172
|
+
assert_equal("NYU50", @helper.sub_libraries["NEW__"][:library])
|
173
|
+
# Revert the file to what it was
|
174
|
+
file = File.open(sub_library_file, 'r+')
|
175
|
+
file.truncate(old_size)
|
176
|
+
file.close
|
177
|
+
end
|
178
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
require File.expand_path("
|
5
|
-
require "rails/test_help"
|
6
|
-
|
7
|
-
Rails.backtrace_cleaner.remove_silencers!
|
1
|
+
require 'coveralls'
|
2
|
+
Coveralls.wear!
|
3
|
+
require 'test/unit'
|
4
|
+
require File.expand_path("../../lib/exlibris-aleph.rb", __FILE__)
|
8
5
|
|
9
6
|
# VCR is used to 'record' HTTP interactions with
|
10
7
|
# third party services used in tests, and play em
|
@@ -15,28 +12,35 @@ Rails.backtrace_cleaner.remove_silencers!
|
|
15
12
|
require 'vcr'
|
16
13
|
require 'webmock'
|
17
14
|
|
18
|
-
# To allow us to do real HTTP requests in a VCR.turned_off, we
|
19
|
-
# have to tell webmock to let us.
|
20
|
-
WebMock.allow_net_connect!(:net_http_connect_on_start => true)
|
21
|
-
|
22
|
-
without_ctx_tim = VCR.request_matchers.uri_without_param(:ctx_tim)
|
23
15
|
VCR.configure do |c|
|
24
16
|
c.cassette_library_dir = 'test/vcr_cassettes'
|
25
17
|
# webmock needed for HTTPClient testing
|
26
18
|
c.hook_into :webmock
|
27
|
-
c.register_request_matcher(:uri_without_ctx_tim, &without_ctx_tim)
|
28
19
|
# c.debug_logger = $stderr
|
29
|
-
c.filter_sensitive_data(
|
20
|
+
c.filter_sensitive_data("library.edu") { "library.nyu.edu" }
|
30
21
|
end
|
31
22
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
def self.use_cassette(*args)
|
38
|
-
yield
|
23
|
+
class Test::Unit::TestCase
|
24
|
+
|
25
|
+
def yaml_aleph_configuration
|
26
|
+
Exlibris::Aleph.configure do |config|
|
27
|
+
config.load_yaml File.expand_path("../support/config.yml", __FILE__)
|
39
28
|
end
|
40
29
|
end
|
41
|
-
|
30
|
+
protected :yaml_aleph_configuration
|
42
31
|
|
32
|
+
def reset_aleph_configuration
|
33
|
+
Exlibris::Aleph.configure do |config|
|
34
|
+
config.base_url = nil
|
35
|
+
config.rest_url = nil
|
36
|
+
config.adms = nil
|
37
|
+
config.refresh_time = nil
|
38
|
+
config.tab_path = nil
|
39
|
+
config.yml_path = nil
|
40
|
+
config.logger = nil
|
41
|
+
config.irrelevant_sub_libraries = nil
|
42
|
+
config.load_time = nil
|
43
|
+
end
|
44
|
+
end
|
45
|
+
protected :reset_aleph_configuration
|
46
|
+
end
|