@@ -5,8 +5,8 @@ def popcorn
5
5
VCR . use_cassette ( 'popcorn primo' ,
6
6
allow_playback_repeats : true ) do
7
7
raw_query = SearchPrimo . new . search ( 'popcorn' ,
8
- ENV [ 'PRIMO_BOOK_SCOPE' ] , 5 )
9
- NormalizePrimo . new . to_result ( raw_query , ENV [ 'PRIMO_BOOK_SCOPE' ] ,
8
+ ENV . fetch ( 'PRIMO_BOOK_SCOPE' , nil ) , 5 )
9
+ NormalizePrimo . new . to_result ( raw_query , ENV . fetch ( 'PRIMO_BOOK_SCOPE' , nil ) ,
10
10
'popcorn' )
11
11
end
12
12
end
@@ -15,8 +15,8 @@ def monkeys
15
15
VCR . use_cassette ( 'monkeys primo articles' ,
16
16
allow_playback_repeats : true ) do
17
17
raw_query = SearchPrimo . new . search ( 'monkeys' ,
18
- ENV [ 'PRIMO_ARTICLE_SCOPE' ] , 5 )
19
- NormalizePrimo . new . to_result ( raw_query , ENV [ 'PRIMO_ARTICLE_SCOPE' ] ,
18
+ ENV . fetch ( 'PRIMO_ARTICLE_SCOPE' , nil ) , 5 )
19
+ NormalizePrimo . new . to_result ( raw_query , ENV . fetch ( 'PRIMO_ARTICLE_SCOPE' , nil ) ,
20
20
'monkeys' )
21
21
end
22
22
end
@@ -28,8 +28,8 @@ def missing_fields
28
28
VCR . use_cassette ( 'missing fields primo' ,
29
29
allow_playback_repeats : true ) do
30
30
raw_query = SearchPrimo . new . search ( 'Chʻomsŭkʻi, kkŭt ŏmnŭn tojŏn' ,
31
- ENV [ 'PRIMO_BOOK_SCOPE' ] , 5 )
32
- NormalizePrimo . new . to_result ( raw_query , ENV [ 'PRIMO_BOOK_SCOPE' ] ,
31
+ ENV . fetch ( 'PRIMO_BOOK_SCOPE' , nil ) , 5 )
32
+ NormalizePrimo . new . to_result ( raw_query , ENV . fetch ( 'PRIMO_BOOK_SCOPE' , nil ) ,
33
33
'Chʻomsŭkʻi, kkŭt ŏmnŭn tojŏn' )
34
34
end
35
35
end
@@ -38,8 +38,8 @@ def missing_fields
38
38
VCR . use_cassette ( 'no results primo' ,
39
39
allow_playback_repeats : true ) do
40
40
raw_query = SearchPrimo . new . search ( 'popcornandorangejuice' ,
41
- ENV [ 'PRIMO_BOOK_SCOPE' ] , 5 )
42
- query = NormalizePrimo . new . to_result ( raw_query , ENV [ 'PRIMO_BOOK_SCOPE' ] ,
41
+ ENV . fetch ( 'PRIMO_BOOK_SCOPE' , nil ) , 5 )
42
+ query = NormalizePrimo . new . to_result ( raw_query , ENV . fetch ( 'PRIMO_BOOK_SCOPE' , nil ) ,
43
43
'popcornandorangejuice' )
44
44
assert_equal ( 0 , query [ 'total' ] )
45
45
end
@@ -79,47 +79,47 @@ def missing_fields
79
79
result = popcorn [ 'results' ] . first
80
80
assert_not_equal 'Rudolph, J.$$QRudolph, J.' , result . authors . first . first
81
81
assert_equal [ 'Rudolph, J.' ,
82
- 'https://mit.primo.exlibrisgroup.com/discovery/search?query=creator,exact,Rudolph, J .&tab=all&search_scope=all&vid=FAKE_PRIMO_VID' ] ,
82
+ 'https://mit.primo.exlibrisgroup.com/discovery/search?query=creator,exact,Rudolph%2C%20J .&tab=all&search_scope=all&vid=FAKE_PRIMO_VID' ] ,
83
83
result . authors . first
84
84
end
85
85
86
86
test 'multiple authors in a single element are appropriately parsed' do
87
87
result = monkeys [ 'results' ] . second
88
88
assert_not_equal [ 'Beran, Michael J ; Smith, J. David' ] , result . authors . first . first
89
89
assert_equal [ 'Beran, Michael J' ,
90
- 'https://mit.primo.exlibrisgroup.com/discovery/search?query=creator,exact,Beran, Michael J &tab=all&search_scope=all&vid=FAKE_PRIMO_VID' ] ,
90
+ 'https://mit.primo.exlibrisgroup.com/discovery/search?query=creator,exact,Beran%2C%20Michael%20J &tab=all&search_scope=all&vid=FAKE_PRIMO_VID' ] ,
91
91
result . authors . first
92
92
assert_equal [ 'Smith, J. David' ,
93
- 'https://mit.primo.exlibrisgroup.com/discovery/search?query=creator,exact,Smith, J. David &tab=all&search_scope=all&vid=FAKE_PRIMO_VID' ] ,
93
+ 'https://mit.primo.exlibrisgroup.com/discovery/search?query=creator,exact,Smith%2C%20J.%20David &tab=all&search_scope=all&vid=FAKE_PRIMO_VID' ] ,
94
94
result . authors . second
95
95
end
96
96
97
97
test 'cleans up single author data in the expected Alma format' do
98
- normalizer = NormalizePrimoCommon . new ( 'record' , ENV [ 'PRIMO_BOOK_SCOPE' ] )
98
+ normalizer = NormalizePrimoCommon . new ( 'record' , ENV . fetch ( 'PRIMO_BOOK_SCOPE' , nil ) )
99
99
authors = [ 'Evans, Bill$$QEvans, Bill' ]
100
100
assert_equal [ 'Evans, Bill' ] , normalizer . sanitize_authors ( authors )
101
101
end
102
102
103
103
test 'cleans up multiple author data in the expected Alma format' do
104
- normalizer = NormalizePrimoCommon . new ( 'record' , ENV [ 'PRIMO_BOOK_SCOPE' ] )
104
+ normalizer = NormalizePrimoCommon . new ( 'record' , ENV . fetch ( 'PRIMO_BOOK_SCOPE' , nil ) )
105
105
authors = [ 'Blakey, Art$$QBlakey, Art' , 'Shorter, Wayne$$QShorter, Wayne' ]
106
106
assert_equal [ 'Blakey, Art' , 'Shorter, Wayne' ] , normalizer . sanitize_authors ( authors )
107
107
end
108
108
109
109
test 'cleans up multiple author data in the expected CDI format' do
110
- normalizer = NormalizePrimoCommon . new ( 'record' , ENV [ 'PRIMO_ARTICLE_SCOPE' ] )
110
+ normalizer = NormalizePrimoCommon . new ( 'record' , ENV . fetch ( 'PRIMO_ARTICLE_SCOPE' , nil ) )
111
111
authors = [ 'Blakey, Art ; Shorter, Wayne' ]
112
112
assert_equal [ 'Blakey, Art' , 'Shorter, Wayne' ] , normalizer . sanitize_authors ( authors )
113
113
end
114
114
115
115
test 'does not attempt to clean up acceptable single author data' do
116
- normalizer = NormalizePrimoCommon . new ( 'record' , ENV [ 'PRIMO_BOOK_SCOPE' ] )
116
+ normalizer = NormalizePrimoCommon . new ( 'record' , ENV . fetch ( 'PRIMO_BOOK_SCOPE' , nil ) )
117
117
authors = [ 'Redman, Joshua' ]
118
118
assert_equal [ 'Redman, Joshua' ] , normalizer . sanitize_authors ( authors )
119
119
end
120
120
121
121
test 'does not attempt to clean up acceptable multiple author data' do
122
- normalizer = NormalizePrimoCommon . new ( 'record' , ENV [ 'PRIMO_BOOK_SCOPE' ] )
122
+ normalizer = NormalizePrimoCommon . new ( 'record' , ENV . fetch ( 'PRIMO_BOOK_SCOPE' , nil ) )
123
123
authors = [ 'Redman, Joshua' , 'Mehldau, Brad' ]
124
124
assert_equal [ 'Redman, Joshua' , 'Mehldau, Brad' ] , normalizer . sanitize_authors ( authors )
125
125
end
@@ -132,7 +132,7 @@ def missing_fields
132
132
133
133
test 'can handle bad results' do
134
134
assert_raises NormalizePrimo ::InvalidResults do
135
- NormalizePrimo . new . to_result ( '' , ENV [ 'PRIMO_BOOK_SCOPE' ] , 'popcorn' )
135
+ NormalizePrimo . new . to_result ( '' , ENV . fetch ( 'PRIMO_BOOK_SCOPE' , nil ) , 'popcorn' )
136
136
end
137
137
end
138
138
end
0 commit comments