qa 4.0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/controllers/qa/linked_data_terms_controller.rb +30 -9
- data/app/controllers/qa/terms_controller.rb +3 -2
- data/app/models/qa/linked_data/config/context_property_map.rb +6 -25
- data/app/services/qa/iri_template_service.rb +32 -24
- data/app/services/qa/linked_data/authority_service.rb +8 -0
- data/app/services/qa/linked_data/authority_url_service.rb +27 -8
- data/app/services/qa/linked_data/deep_sort_service.rb +3 -2
- data/app/services/qa/linked_data/graph_service.rb +13 -0
- data/app/services/qa/linked_data/language_service.rb +12 -0
- data/app/services/qa/linked_data/language_sort_service.rb +7 -2
- data/app/services/qa/linked_data/ldpath_service.rb +40 -0
- data/app/services/qa/linked_data/mapper/graph_ldpath_mapper_service.rb +49 -0
- data/app/services/qa/linked_data/mapper/graph_mapper_service.rb +3 -11
- data/app/services/qa/linked_data/mapper/graph_predicate_mapper_service.rb +40 -0
- data/app/services/qa/linked_data/mapper/search_results_mapper_service.rb +58 -11
- data/app/services/qa/linked_data/mapper/term_results_mapper_service.rb +80 -0
- data/config/authorities/linked_data/loc.json +13 -7
- data/config/authorities/linked_data/oclc_fast.json +13 -8
- data/lib/generators/qa/discogs/USAGE +10 -0
- data/lib/generators/qa/discogs/discogs_generator.rb +12 -0
- data/lib/generators/qa/discogs/templates/config/discogs-formats.yml +346 -0
- data/lib/generators/qa/discogs/templates/config/discogs-genres.yml +627 -0
- data/lib/generators/qa/install/templates/config/initializers/qa.rb +4 -0
- data/lib/qa.rb +6 -0
- data/lib/qa/authorities.rb +2 -0
- data/lib/qa/authorities/discogs.rb +28 -0
- data/lib/qa/authorities/discogs/discogs_instance_builder.rb +145 -0
- data/lib/qa/authorities/discogs/discogs_translation.rb +126 -0
- data/lib/qa/authorities/discogs/discogs_utils.rb +89 -0
- data/lib/qa/authorities/discogs/discogs_works_builder.rb +153 -0
- data/lib/qa/authorities/discogs/generic_authority.rb +151 -0
- data/lib/qa/authorities/discogs_subauthority.rb +9 -0
- data/lib/qa/authorities/linked_data/config.rb +7 -3
- data/lib/qa/authorities/linked_data/config/search_config.rb +99 -11
- data/lib/qa/authorities/linked_data/config/term_config.rb +112 -8
- data/lib/qa/authorities/linked_data/find_term.rb +154 -84
- data/lib/qa/authorities/linked_data/search_query.rb +76 -13
- data/lib/qa/configuration.rb +8 -0
- data/lib/qa/version.rb +1 -1
- data/spec/controllers/linked_data_terms_controller_spec.rb +151 -30
- data/spec/controllers/terms_controller_spec.rb +4 -0
- data/spec/features/linked_data/language_spec.rb +298 -0
- data/spec/fixtures/authorities/linked_data/lod_full_config.json +21 -5
- data/spec/fixtures/authorities/linked_data/lod_lang_defaults.json +4 -4
- data/spec/fixtures/authorities/linked_data/lod_lang_multi_defaults.json +4 -4
- data/spec/fixtures/authorities/linked_data/lod_lang_no_defaults.json +4 -5
- data/spec/fixtures/authorities/linked_data/lod_lang_param.json +4 -4
- data/spec/fixtures/authorities/linked_data/lod_term_uri_param_config.json +1 -1
- data/spec/fixtures/discogs-find-response-json.json +1 -0
- data/spec/fixtures/discogs-find-response-jsonld-master.json +1 -0
- data/spec/fixtures/discogs-find-response-jsonld-release.json +1 -0
- data/spec/fixtures/discogs-id-matches-master.json +1 -0
- data/spec/fixtures/discogs-id-matches-release.json +1 -0
- data/spec/fixtures/discogs-id-not-found-master.json +1 -0
- data/spec/fixtures/discogs-id-not-found-release.json +1 -0
- data/spec/fixtures/discogs-search-response-no-auth.json +1 -0
- data/spec/fixtures/discogs-search-response-no-subauth.json +1 -0
- data/spec/fixtures/discogs-search-response-subauth.json +1 -0
- data/spec/fixtures/lod_lang_search_enesfrde.rdf.xml +60 -0
- data/spec/fixtures/lod_lang_search_sv.rdf.xml +42 -0
- data/spec/fixtures/lod_loc_term_found.rdf.xml +5 -0
- data/spec/lib/authorities/discogs/generic_authority_spec.rb +235 -0
- data/spec/lib/authorities/discogs_spec.rb +17 -0
- data/spec/lib/authorities/linked_data/config_spec.rb +68 -5
- data/spec/lib/authorities/linked_data/find_term_spec.rb +298 -3
- data/spec/lib/authorities/linked_data/generic_authority_spec.rb +46 -485
- data/spec/lib/authorities/linked_data/search_config_spec.rb +154 -3
- data/spec/lib/authorities/linked_data/search_query_spec.rb +240 -3
- data/spec/lib/authorities/linked_data/term_config_spec.rb +193 -5
- data/spec/lib/configuration_spec.rb +18 -0
- data/spec/models/linked_data/config/context_property_map_spec.rb +3 -31
- data/spec/services/iri_template_service_spec.rb +54 -12
- data/spec/{lib/authorities → services}/linked_data/authority_service_spec.rb +47 -0
- data/spec/services/linked_data/language_service_spec.rb +52 -11
- data/spec/services/linked_data/ldpath_service_spec.rb +61 -0
- data/spec/services/linked_data/mapper/graph_ldpath_mapper_service_spec.rb +118 -0
- data/spec/services/linked_data/mapper/graph_predicate_mapper_service_spec.rb +110 -0
- data/spec/services/linked_data/mapper/term_results_mapper_service_spec.rb +94 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/support/matchers/include_hash.rb +5 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +4 -0
- metadata +73 -5
- data/lib/qa/authorities/linked_data/rdf_helper.rb +0 -49
|
@@ -1,7 +1,302 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
RSpec.describe Qa::Authorities::LinkedData::FindTerm do
|
|
4
|
-
#
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
describe '#find' do
|
|
5
|
+
let(:lod_oclc) { described_class.new(term_config(:OCLC_FAST)) }
|
|
6
|
+
let(:lod_loc) { described_class.new(term_config(:LOC)) }
|
|
7
|
+
|
|
8
|
+
context 'basic parameter testing' do
|
|
9
|
+
context 'with bad id' do
|
|
10
|
+
before do
|
|
11
|
+
stub_request(:get, 'http://id.worldcat.org/fast/FAKE_ID')
|
|
12
|
+
.to_return(status: 404, body: '', headers: {})
|
|
13
|
+
end
|
|
14
|
+
it 'raises a TermNotFound exception' do
|
|
15
|
+
expect { lod_oclc.find('FAKE_ID') }.to raise_error Qa::TermNotFound, /.*\/FAKE_ID\ Not Found - Term may not exist at LOD Authority./
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
context 'performance stats' do
|
|
21
|
+
before do
|
|
22
|
+
stub_request(:get, 'http://id.worldcat.org/fast/530369')
|
|
23
|
+
.to_return(status: 200, body: webmock_fixture('lod_oclc_term_found.rdf.xml'), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
24
|
+
end
|
|
25
|
+
context 'when set to true' do
|
|
26
|
+
let :results do
|
|
27
|
+
lod_oclc.find('530369', performance_data: true)
|
|
28
|
+
end
|
|
29
|
+
it 'includes performance in return hash' do
|
|
30
|
+
expect(results.keys).to match_array [:performance, :results]
|
|
31
|
+
expect(results[:performance].keys).to match_array [:predicate_count, :fetch_time_s, :normalization_time_s, :total_time_s]
|
|
32
|
+
expect(results[:performance][:predicate_count]).to eq 7
|
|
33
|
+
expect(results[:performance][:total_time_s]).to eq results[:performance][:fetch_time_s] + results[:performance][:normalization_time_s]
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
context 'when set to false' do
|
|
38
|
+
let :results do
|
|
39
|
+
lod_oclc.find('530369', performance_data: false)
|
|
40
|
+
end
|
|
41
|
+
it 'does NOT include performance in return hash' do
|
|
42
|
+
expect(results.keys).not_to include(:performance)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
context 'when using default setting' do
|
|
47
|
+
let :results do
|
|
48
|
+
lod_oclc.find('530369')
|
|
49
|
+
end
|
|
50
|
+
it 'does NOT include performance in return hash' do
|
|
51
|
+
expect(results.keys).not_to include(:performance)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
context 'in OCLC_FAST authority' do
|
|
57
|
+
context 'term found' do
|
|
58
|
+
let :results do
|
|
59
|
+
stub_request(:get, 'http://id.worldcat.org/fast/530369')
|
|
60
|
+
.to_return(status: 200, body: webmock_fixture('lod_oclc_term_found.rdf.xml'), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
61
|
+
lod_oclc.find('530369')
|
|
62
|
+
end
|
|
63
|
+
it 'has correct primary predicate values' do
|
|
64
|
+
expect(results[:uri]).to eq('http://id.worldcat.org/fast/530369')
|
|
65
|
+
expect(results[:id]).to eq('530369')
|
|
66
|
+
expect(results[:label]).to eq ['Cornell University']
|
|
67
|
+
expect(results[:altlabel]).to include('Ithaca (N.Y.). Cornell University', "Kornel\\xCA\\xB9skii universitet", "K\\xCA\\xBBang-nai-erh ta hs\\xC3\\xBCeh")
|
|
68
|
+
expect(results[:altlabel].size).to eq 3
|
|
69
|
+
expect(results[:sameas]).to include('http://id.loc.gov/authorities/names/n79021621', 'https://viaf.org/viaf/126293486')
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it 'has correct number of predicates in pred-obj list' do
|
|
73
|
+
expect(results['predicates'].count).to eq 7
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it 'has primary predicates in pred-obj list' do
|
|
77
|
+
expect(results['predicates']['http://purl.org/dc/terms/identifier']).to eq ['530369']
|
|
78
|
+
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#prefLabel']).to eq ['Cornell University']
|
|
79
|
+
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#altLabel'])
|
|
80
|
+
.to include('Ithaca (N.Y.). Cornell University', "Kornel\\xCA\\xB9skii universitet",
|
|
81
|
+
"K\\xCA\\xBBang-nai-erh ta hs\\xC3\\xBCeh")
|
|
82
|
+
expect(results['predicates']['http://schema.org/sameAs']).to include('http://id.loc.gov/authorities/names/n79021621', 'https://viaf.org/viaf/126293486')
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it 'has unspecified predicate values' do
|
|
86
|
+
expect(results['predicates']['http://www.w3.org/1999/02/22-rdf-syntax-ns#type']).to eq ['http://schema.org/Organization']
|
|
87
|
+
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#inScheme'])
|
|
88
|
+
.to include('http://id.worldcat.org/fast/ontology/1.0/#fast', 'http://id.worldcat.org/fast/ontology/1.0/#facet-Corporate')
|
|
89
|
+
expect(results['predicates']['http://schema.org/name'])
|
|
90
|
+
.to include('Cornell University', 'Ithaca (N.Y.). Cornell University', "Kornel\\xCA\\xB9skii universitet",
|
|
91
|
+
"K\\xCA\\xBBang-nai-erh ta hs\\xC3\\xBCeh")
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
context 'in LOC authority' do
|
|
97
|
+
context 'term found' do
|
|
98
|
+
let :results do
|
|
99
|
+
stub_request(:get, 'http://id.loc.gov/authorities/subjects/sh85118553')
|
|
100
|
+
.to_return(status: 200, body: webmock_fixture('lod_loc_term_found.rdf.xml'), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
101
|
+
lod_loc.find('sh 85118553', subauth: 'subjects')
|
|
102
|
+
end
|
|
103
|
+
it 'has correct primary predicate values' do
|
|
104
|
+
expect(results[:uri]).to eq 'http://id.loc.gov/authorities/subjects/sh85118553'
|
|
105
|
+
expect(results[:uri]).to be_kind_of String
|
|
106
|
+
expect(results[:id]).to eq 'sh 85118553'
|
|
107
|
+
expect(results[:label]).to eq ['Science']
|
|
108
|
+
expect(results[:altlabel]).to include('Natural science', 'Science of science', 'Sciences')
|
|
109
|
+
expect(results[:narrower]).to include('http://id.loc.gov/authorities/subjects/sh92004048')
|
|
110
|
+
expect(results[:narrower].first).to be_kind_of String
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
it 'has correct number of predicates in pred-obj list' do
|
|
114
|
+
expect(results['predicates'].count).to eq 15
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
it 'has primary predicates in pred-obj list' do
|
|
118
|
+
expect(results['predicates']['http://id.loc.gov/vocabulary/identifiers/lccn']).to eq ['sh 85118553']
|
|
119
|
+
expect(results['predicates']['http://www.loc.gov/mads/rdf/v1#authoritativeLabel']).to eq ['Science']
|
|
120
|
+
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#prefLabel']).to eq ['Science']
|
|
121
|
+
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#altLabel']).to include('Natural science', 'Science of science', 'Sciences')
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it 'has loc mads predicate values' do
|
|
125
|
+
expect(results['predicates']['http://www.loc.gov/mads/rdf/v1#classification']).to eq ['Q']
|
|
126
|
+
expect(results['predicates']['http://www.loc.gov/mads/rdf/v1#isMemberOfMADSCollection'])
|
|
127
|
+
.to include('http://id.loc.gov/authorities/subjects/collection_LCSHAuthorizedHeadings',
|
|
128
|
+
'http://id.loc.gov/authorities/subjects/collection_LCSH_General',
|
|
129
|
+
'http://id.loc.gov/authorities/subjects/collection_SubdivideGeographically')
|
|
130
|
+
expect(results['predicates']['http://www.loc.gov/mads/rdf/v1#hasCloseExternalAuthority'])
|
|
131
|
+
.to include('http://data.bnf.fr/ark:/12148/cb12321484k', 'http://data.bnf.fr/ark:/12148/cb119673416',
|
|
132
|
+
'http://data.bnf.fr/ark:/12148/cb119934236', 'http://data.bnf.fr/ark:/12148/cb12062047t',
|
|
133
|
+
'http://data.bnf.fr/ark:/12148/cb119469567', 'http://data.bnf.fr/ark:/12148/cb11933232c',
|
|
134
|
+
'http://data.bnf.fr/ark:/12148/cb122890536', 'http://data.bnf.fr/ark:/12148/cb121155321',
|
|
135
|
+
'http://data.bnf.fr/ark:/12148/cb15556043g', 'http://data.bnf.fr/ark:/12148/cb123662513',
|
|
136
|
+
'http://d-nb.info/gnd/4066562-8', 'http://data.bnf.fr/ark:/12148/cb120745812',
|
|
137
|
+
'http://data.bnf.fr/ark:/12148/cb11973101n', 'http://data.bnf.fr/ark:/12148/cb13328497r')
|
|
138
|
+
expect(results['predicates']['http://www.loc.gov/mads/rdf/v1#isMemberOfMADSScheme'])
|
|
139
|
+
.to eq ['http://id.loc.gov/authorities/subjects']
|
|
140
|
+
expect(results['predicates']['http://www.loc.gov/mads/rdf/v1#editorialNote'])
|
|
141
|
+
.to eq ['headings beginning with the word [Scientific;] and subdivision [Science] under ethnic groups and individual wars, e.g. [World War, 1939-1945--Science]']
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
it 'has more unspecified predicate values' do
|
|
145
|
+
expect(results['predicates']['http://www.w3.org/1999/02/22-rdf-syntax-ns#type']).to include('http://www.loc.gov/mads/rdf/v1#Topic', 'http://www.loc.gov/mads/rdf/v1#Authority', 'http://www.w3.org/2004/02/skos/core#Concept')
|
|
146
|
+
expect(results['predicates']['http://www.w3.org/2002/07/owl#sameAs']).to include('info:lc/authorities/sh85118553', 'http://id.loc.gov/authorities/sh85118553#concept')
|
|
147
|
+
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#closeMatch'])
|
|
148
|
+
.to include('http://data.bnf.fr/ark:/12148/cb12321484k', 'http://data.bnf.fr/ark:/12148/cb119673416',
|
|
149
|
+
'http://data.bnf.fr/ark:/12148/cb119934236', 'http://data.bnf.fr/ark:/12148/cb12062047t',
|
|
150
|
+
'http://data.bnf.fr/ark:/12148/cb119469567', 'http://data.bnf.fr/ark:/12148/cb11933232c',
|
|
151
|
+
'http://data.bnf.fr/ark:/12148/cb122890536', 'http://data.bnf.fr/ark:/12148/cb121155321',
|
|
152
|
+
'http://data.bnf.fr/ark:/12148/cb15556043g', 'http://data.bnf.fr/ark:/12148/cb123662513',
|
|
153
|
+
'http://d-nb.info/gnd/4066562-8', 'http://data.bnf.fr/ark:/12148/cb120745812',
|
|
154
|
+
'http://data.bnf.fr/ark:/12148/cb11973101n', 'http://data.bnf.fr/ark:/12148/cb13328497r')
|
|
155
|
+
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#editorial'])
|
|
156
|
+
.to eq ['headings beginning with the word [Scientific;] and subdivision [Science] under ethnic groups and individual wars, e.g. [World War, 1939-1945--Science]']
|
|
157
|
+
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#inScheme']).to eq ['http://id.loc.gov/authorities/subjects']
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# rubocop:disable RSpec/NestedGroups
|
|
163
|
+
describe "language processing" do
|
|
164
|
+
context "when filtering #find result" do
|
|
165
|
+
context "and lang NOT passed in" do
|
|
166
|
+
context "and NO language defined in authority config" do
|
|
167
|
+
context "and NO language defined in Qa config" do
|
|
168
|
+
let(:lod_lang_no_defaults) { described_class.new(term_config(:LOD_LANG_NO_DEFAULTS)) }
|
|
169
|
+
let :results do
|
|
170
|
+
stub_request(:get, "http://aims.fao.org/aos/agrovoc/c_9513")
|
|
171
|
+
.to_return(status: 200, body: webmock_fixture("lod_lang_term_enfr.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
172
|
+
lod_lang_no_defaults.find('http://aims.fao.org/aos/agrovoc/c_9513')
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
before do
|
|
176
|
+
Qa.config.default_language = []
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
after do
|
|
180
|
+
Qa.config.default_language = :en
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
it "is not filtered" do
|
|
184
|
+
expect(results[:label]).to eq ['buttermilk', 'Babeurre']
|
|
185
|
+
expect(results[:altlabel]).to eq ['yummy', 'délicieux']
|
|
186
|
+
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#prefLabel"]).to include("buttermilk", "Babeurre")
|
|
187
|
+
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#altLabel"]).to include("yummy", "délicieux")
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
context "and default_language is defined in Qa config" do
|
|
191
|
+
let(:lod_lang_no_defaults) { described_class.new(term_config(:LOD_LANG_NO_DEFAULTS)) }
|
|
192
|
+
let :results do
|
|
193
|
+
stub_request(:get, "http://aims.fao.org/aos/agrovoc/c_9513")
|
|
194
|
+
.to_return(status: 200, body: webmock_fixture("lod_lang_term_enfr.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
195
|
+
lod_lang_no_defaults.find('http://aims.fao.org/aos/agrovoc/c_9513')
|
|
196
|
+
end
|
|
197
|
+
it "filters using Qa configured default for summary but not for predicates list" do
|
|
198
|
+
expect(results[:label]).to eq ['buttermilk']
|
|
199
|
+
expect(results[:altlabel]).to eq ['yummy']
|
|
200
|
+
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#prefLabel"]).to include("buttermilk", "Babeurre")
|
|
201
|
+
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#altLabel"]).to include("yummy", "délicieux")
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
context "and language IS defined in authority config" do
|
|
206
|
+
let(:lod_lang_defaults) { described_class.new(term_config(:LOD_LANG_DEFAULTS)) }
|
|
207
|
+
let :results do
|
|
208
|
+
stub_request(:get, "http://aims.fao.org/aos/agrovoc/c_9513")
|
|
209
|
+
.to_return(status: 200, body: webmock_fixture("lod_lang_term_enfr.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
210
|
+
lod_lang_defaults.find('http://aims.fao.org/aos/agrovoc/c_9513')
|
|
211
|
+
end
|
|
212
|
+
it "filters using authority configured language for summary but not for predicates list" do
|
|
213
|
+
expect(results[:label]).to eq ['Babeurre']
|
|
214
|
+
expect(results[:altlabel]).to eq ['délicieux']
|
|
215
|
+
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#prefLabel"]).to include("buttermilk", "Babeurre")
|
|
216
|
+
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#altLabel"]).to include("yummy", "délicieux")
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
context "and multiple languages ARE defined in authority config" do
|
|
220
|
+
let(:lod_lang_multi_defaults) { described_class.new(term_config(:LOD_LANG_MULTI_DEFAULTS)) }
|
|
221
|
+
let :results do
|
|
222
|
+
stub_request(:get, "http://aims.fao.org/aos/agrovoc/c_9513")
|
|
223
|
+
.to_return(status: 200, body: webmock_fixture("lod_lang_term_enfrde.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
224
|
+
lod_lang_multi_defaults.find('http://aims.fao.org/aos/agrovoc/c_9513')
|
|
225
|
+
end
|
|
226
|
+
it "filters using authority configured languages for summary but not for predicates list" do
|
|
227
|
+
expect(results[:label]).to eq ['buttermilk', 'Babeurre']
|
|
228
|
+
expect(results[:altlabel]).to eq ['yummy', 'délicieux']
|
|
229
|
+
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#prefLabel"]).to include("buttermilk", "Babeurre", "Buttermilch")
|
|
230
|
+
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#altLabel"]).to include("yummy", "délicieux", "lecker")
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
context "and lang IS passed in" do
|
|
236
|
+
let(:lod_lang_defaults) { described_class.new(term_config(:LOD_LANG_DEFAULTS)) }
|
|
237
|
+
let :results do
|
|
238
|
+
stub_request(:get, "http://aims.fao.org/aos/agrovoc/c_9513")
|
|
239
|
+
.to_return(status: 200, body: webmock_fixture("lod_lang_term_enfr.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
240
|
+
lod_lang_defaults.find('http://aims.fao.org/aos/agrovoc/c_9513', language: 'fr')
|
|
241
|
+
end
|
|
242
|
+
it "is filtered to specified language" do
|
|
243
|
+
expect(results[:label]).to eq ['Babeurre']
|
|
244
|
+
expect(results[:altlabel]).to eq ['délicieux']
|
|
245
|
+
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#prefLabel"]).to include("buttermilk", "Babeurre")
|
|
246
|
+
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#altLabel"]).to include("yummy", "délicieux")
|
|
247
|
+
end
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
context "and result does not have altlabel" do
|
|
251
|
+
let(:lod_lang_defaults) { described_class.new(term_config(:LOD_LANG_DEFAULTS)) }
|
|
252
|
+
let :results do
|
|
253
|
+
stub_request(:get, "http://aims.fao.org/aos/agrovoc/c_9513")
|
|
254
|
+
.to_return(status: 200, body: webmock_fixture("lod_lang_term_enfr_noalt.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
255
|
+
lod_lang_defaults.find('http://aims.fao.org/aos/agrovoc/c_9513', language: 'fr')
|
|
256
|
+
end
|
|
257
|
+
it "is filtered to specified language" do
|
|
258
|
+
expect(results[:label]).to eq ['Babeurre']
|
|
259
|
+
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#prefLabel"]).to include("buttermilk", "Babeurre")
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
context "when replacement on authority term URL" do
|
|
264
|
+
context "and using default" do
|
|
265
|
+
let(:lod_lang_param) { described_class.new(term_config(:LOD_LANG_PARAM)) }
|
|
266
|
+
let :results do
|
|
267
|
+
stub_request(:get, "http://aims.fao.org/aos/agrovoc/c_9513?lang=en")
|
|
268
|
+
.to_return(status: 200, body: webmock_fixture("lod_lang_term_en.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
269
|
+
lod_lang_param.find('http://aims.fao.org/aos/agrovoc/c_9513')
|
|
270
|
+
end
|
|
271
|
+
it "is correctly parsed" do
|
|
272
|
+
expect(results[:label]).to eq ['buttermilk']
|
|
273
|
+
expect(results[:altlabel]).to eq ['yummy']
|
|
274
|
+
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#prefLabel"]).to eq ['buttermilk']
|
|
275
|
+
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#altLabel"]).to eq ['yummy']
|
|
276
|
+
end
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
context "and lang specified" do
|
|
280
|
+
let(:lod_lang_param) { described_class.new(term_config(:LOD_LANG_PARAM)) }
|
|
281
|
+
let :results do
|
|
282
|
+
stub_request(:get, "http://aims.fao.org/aos/agrovoc/c_9513?lang=fr")
|
|
283
|
+
.to_return(status: 200, body: webmock_fixture("lod_lang_term_fr.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
284
|
+
lod_lang_param.find('http://aims.fao.org/aos/agrovoc/c_9513', replacements: { 'lang' => 'fr' })
|
|
285
|
+
end
|
|
286
|
+
it "is correctly parsed" do
|
|
287
|
+
expect(results[:label]).to eq ['Babeurre']
|
|
288
|
+
expect(results[:altlabel]).to eq ['délicieux']
|
|
289
|
+
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#prefLabel"]).to eq ['Babeurre']
|
|
290
|
+
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#altLabel"]).to eq ['délicieux']
|
|
291
|
+
end
|
|
292
|
+
end
|
|
293
|
+
end
|
|
294
|
+
end
|
|
295
|
+
end
|
|
296
|
+
# rubocop:enable RSpec/NestedGroups
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
def term_config(authority_name)
|
|
300
|
+
Qa::Authorities::LinkedData::Config.new(authority_name).term
|
|
301
|
+
end
|
|
7
302
|
end
|
|
@@ -1,491 +1,6 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
RSpec.describe Qa::Authorities::LinkedData::GenericAuthority do
|
|
4
|
-
describe '#search' do
|
|
5
|
-
let(:lod_oclc) { described_class.new(:OCLC_FAST) }
|
|
6
|
-
|
|
7
|
-
context 'in OCLC_FAST authority' do
|
|
8
|
-
context '0 search results' do
|
|
9
|
-
let :results do
|
|
10
|
-
stub_request(:get, 'http://experimental.worldcat.org/fast/search?maximumRecords=3&query=cql.any%20all%20%22supercalifragilisticexpialidocious%22&sortKeys=usage')
|
|
11
|
-
.to_return(status: 200, body: webmock_fixture('lod_oclc_query_no_results.rdf.xml'), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
12
|
-
lod_oclc.search('supercalifragilisticexpialidocious', replacements: { 'maximumRecords' => '3' })
|
|
13
|
-
end
|
|
14
|
-
it 'returns an empty array' do
|
|
15
|
-
expect(results).to eq([])
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
context '3 search results' do
|
|
20
|
-
let :results do
|
|
21
|
-
stub_request(:get, 'http://experimental.worldcat.org/fast/search?maximumRecords=3&query=cql.any%20all%20%22cornell%22&sortKeys=usage')
|
|
22
|
-
.to_return(status: 200, body: webmock_fixture('lod_oclc_all_query_3_results.rdf.xml'), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
23
|
-
lod_oclc.search('cornell', replacements: { 'maximumRecords' => '3' })
|
|
24
|
-
end
|
|
25
|
-
it 'is correctly parsed' do
|
|
26
|
-
expect(results.count).to eq(3)
|
|
27
|
-
expect(results.first).to eq(uri: 'http://id.worldcat.org/fast/530369', id: '530369', label: 'Cornell University')
|
|
28
|
-
expect(results.second).to eq(uri: 'http://id.worldcat.org/fast/5140', id: '5140', label: 'Cornell, Joseph')
|
|
29
|
-
expect(results.third).to eq(uri: 'http://id.worldcat.org/fast/557490', id: '557490', label: 'New York State School of Industrial and Labor Relations')
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
context 'in OCLC_FAST authority and personal_name subauthority' do
|
|
35
|
-
context '0 search results' do
|
|
36
|
-
let :results do
|
|
37
|
-
stub_request(:get, 'http://experimental.worldcat.org/fast/search?maximumRecords=3&query=oclc.personalName%20all%20%22supercalifragilisticexpialidocious%22&sortKeys=usage')
|
|
38
|
-
.to_return(status: 200, body: webmock_fixture('lod_oclc_query_no_results.rdf.xml'), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
39
|
-
lod_oclc.search('supercalifragilisticexpialidocious', subauth: 'personal_name', replacements: { 'maximumRecords' => '3' })
|
|
40
|
-
end
|
|
41
|
-
it 'returns an empty array' do
|
|
42
|
-
expect(results).to eq([])
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
context '3 search results' do
|
|
47
|
-
let :results do
|
|
48
|
-
stub_request(:get, 'http://experimental.worldcat.org/fast/search?maximumRecords=3&query=oclc.personalName%20all%20%22cornell%22&sortKeys=usage')
|
|
49
|
-
.to_return(status: 200, body: webmock_fixture('lod_oclc_personalName_query_3_results.rdf.xml'), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
50
|
-
lod_oclc.search('cornell', subauth: 'personal_name', replacements: { 'maximumRecords' => '3' })
|
|
51
|
-
end
|
|
52
|
-
it 'is correctly parsed' do
|
|
53
|
-
expect(results.count).to eq(3)
|
|
54
|
-
expect(results.first).to eq(uri: 'http://id.worldcat.org/fast/409667', id: '409667', label: 'Cornell, Ezra, 1807-1874')
|
|
55
|
-
expect(results.second).to eq(uri: 'http://id.worldcat.org/fast/5140', id: '5140', label: 'Cornell, Joseph')
|
|
56
|
-
expect(results.third).to eq(uri: 'http://id.worldcat.org/fast/72456', id: '72456', label: 'Cornell, Sarah Maria, 1802-1832')
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
context 'when id predicate is not specified' do
|
|
62
|
-
let(:min_authority) { described_class.new(:LOD_MIN_CONFIG) }
|
|
63
|
-
let :results do
|
|
64
|
-
stub_request(:get, 'http://localhost/test_default/search?query=peanuts')
|
|
65
|
-
.to_return(status: 200, body: webmock_fixture('lod_oclc_personalName_query_3_results.rdf.xml'), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
66
|
-
min_authority.search('peanuts')
|
|
67
|
-
end
|
|
68
|
-
it 'uses subject uri for id' do
|
|
69
|
-
expect(results.count).to eq(3)
|
|
70
|
-
expect(results.first).to eq(uri: 'http://id.worldcat.org/fast/409667', id: 'http://id.worldcat.org/fast/409667', label: 'Cornell, Ezra, 1807-1874')
|
|
71
|
-
expect(results.second).to eq(uri: 'http://id.worldcat.org/fast/5140', id: 'http://id.worldcat.org/fast/5140', label: 'Cornell, Joseph')
|
|
72
|
-
expect(results.third).to eq(uri: 'http://id.worldcat.org/fast/72456', id: 'http://id.worldcat.org/fast/72456', label: 'Cornell, Sarah Maria, 1802-1832')
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
# context 'in LOC authority' do
|
|
77
|
-
# ###################################
|
|
78
|
-
# ### SEARCH NOT SUPPORTED BY LOC ###
|
|
79
|
-
# ###################################
|
|
80
|
-
# # let(:lod_loc) { Qa::Authorities::LinkedData::GenericAuthority.new(:LOC) }
|
|
81
|
-
# end
|
|
82
|
-
|
|
83
|
-
# rubocop:disable RSpec/NestedGroups
|
|
84
|
-
describe "language processing" do
|
|
85
|
-
context "when filtering #search results" do
|
|
86
|
-
context "and lang NOT passed in" do
|
|
87
|
-
context "and NO language defined in authority config" do
|
|
88
|
-
context "and NO language defined in Qa config" do
|
|
89
|
-
let(:lod_lang_no_defaults) { described_class.new(:LOD_LANG_NO_DEFAULTS) }
|
|
90
|
-
let :results do
|
|
91
|
-
stub_request(:get, "http://localhost/test_no_default/search?query=milk")
|
|
92
|
-
.to_return(status: 200, body: webmock_fixture("lod_lang_search_enfr.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
93
|
-
lod_lang_no_defaults.search('milk')
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
before do
|
|
97
|
-
Qa.config.default_language = []
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
after do
|
|
101
|
-
Qa.config.default_language = :en
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
it "is not filtered" do
|
|
105
|
-
expect(results.first[:label]).to eq('[buttermilk, Babeurre] (yummy, délicieux)')
|
|
106
|
-
expect(results.second[:label]).to eq('[condensed milk, lait condensé] (creamy, crémeux)')
|
|
107
|
-
expect(results.third[:label]).to eq('[dried milk, lait en poudre] (powdery, poudreux)')
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
context "and default_language is defined in Qa config" do
|
|
112
|
-
let(:lod_lang_no_defaults) { described_class.new(:LOD_LANG_NO_DEFAULTS) }
|
|
113
|
-
let :results do
|
|
114
|
-
stub_request(:get, "http://localhost/test_no_default/search?query=milk")
|
|
115
|
-
.to_return(status: 200, body: webmock_fixture("lod_lang_search_enfr.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
116
|
-
lod_lang_no_defaults.search('milk')
|
|
117
|
-
end
|
|
118
|
-
it "filters using Qa configured default" do
|
|
119
|
-
expect(results.first[:label]).to eq('buttermilk (yummy)')
|
|
120
|
-
expect(results.second[:label]).to eq('condensed milk (creamy)')
|
|
121
|
-
expect(results.third[:label]).to eq('dried milk (powdery)')
|
|
122
|
-
end
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
context "and language IS defined in authority config" do
|
|
127
|
-
let(:lod_lang_defaults) { described_class.new(:LOD_LANG_DEFAULTS) }
|
|
128
|
-
let :results do
|
|
129
|
-
stub_request(:get, "http://localhost/test_default/search?query=milk")
|
|
130
|
-
.to_return(status: 200, body: webmock_fixture("lod_lang_search_enfr.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
131
|
-
lod_lang_defaults.search('milk')
|
|
132
|
-
end
|
|
133
|
-
it "is filtered to authority defined language" do
|
|
134
|
-
expect(results.first[:label]).to eq('Babeurre (délicieux)')
|
|
135
|
-
expect(results.second[:label]).to eq('lait condensé (crémeux)')
|
|
136
|
-
expect(results.third[:label]).to eq('lait en poudre (poudreux)')
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
context "and multiple languages ARE defined in authority config" do
|
|
142
|
-
let(:lod_lang_multi_defaults) { described_class.new(:LOD_LANG_MULTI_DEFAULTS) }
|
|
143
|
-
let :results do
|
|
144
|
-
stub_request(:get, "http://localhost/test_default/search?query=milk")
|
|
145
|
-
.to_return(status: 200, body: webmock_fixture("lod_lang_search_enfrde.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
146
|
-
lod_lang_multi_defaults.search('milk')
|
|
147
|
-
end
|
|
148
|
-
it "is filtered to authority defined languages" do
|
|
149
|
-
expect(results.first[:label]).to eq('[buttermilk, Babeurre] (yummy, délicieux)')
|
|
150
|
-
expect(results.second[:label]).to eq('[condensed milk, lait condensé] (creamy, crémeux)')
|
|
151
|
-
expect(results.third[:label]).to eq('[dried milk, lait en poudre] (powdery, poudreux)')
|
|
152
|
-
end
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
context "and language IS passed in to search" do
|
|
156
|
-
let(:lod_lang_defaults) { described_class.new(:LOD_LANG_DEFAULTS) }
|
|
157
|
-
let :results do
|
|
158
|
-
stub_request(:get, "http://localhost/test_default/search?query=milk")
|
|
159
|
-
.to_return(status: 200, body: webmock_fixture("lod_lang_search_enfr.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
160
|
-
lod_lang_defaults.search('milk', language: :fr)
|
|
161
|
-
end
|
|
162
|
-
it "is filtered to specified language" do
|
|
163
|
-
expect(results.first[:label]).to eq('Babeurre (délicieux)')
|
|
164
|
-
expect(results.second[:label]).to eq('lait condensé (crémeux)')
|
|
165
|
-
expect(results.third[:label]).to eq('lait en poudre (poudreux)')
|
|
166
|
-
end
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
context "when replacement on authority search URL" do
|
|
170
|
-
context "and using default" do
|
|
171
|
-
let(:lod_lang_param) { described_class.new(:LOD_LANG_PARAM) }
|
|
172
|
-
let :results do
|
|
173
|
-
stub_request(:get, "http://localhost/test_replacement/search?lang=en&query=milk")
|
|
174
|
-
.to_return(status: 200, body: webmock_fixture("lod_lang_search_en.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
175
|
-
lod_lang_param.search("milk")
|
|
176
|
-
end
|
|
177
|
-
it "is correctly parsed" do
|
|
178
|
-
expect(results.first[:label]).to eq('buttermilk (yummy)')
|
|
179
|
-
expect(results.second[:label]).to eq('condensed milk (creamy)')
|
|
180
|
-
expect(results.third[:label]).to eq('dried milk (powdery)')
|
|
181
|
-
end
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
context "and lang specified" do
|
|
185
|
-
let(:lod_lang_param) { described_class.new(:LOD_LANG_PARAM) }
|
|
186
|
-
let :results do
|
|
187
|
-
stub_request(:get, "http://localhost/test_replacement/search?query=milk&lang=fr")
|
|
188
|
-
.to_return(status: 200, body: webmock_fixture("lod_lang_search_fr.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
189
|
-
lod_lang_param.search("milk", replacements: { 'lang' => 'fr' })
|
|
190
|
-
end
|
|
191
|
-
it "is correctly parsed" do
|
|
192
|
-
expect(results.first[:label]).to eq('Babeurre (délicieux)')
|
|
193
|
-
expect(results.second[:label]).to eq('lait condensé (crémeux)')
|
|
194
|
-
expect(results.third[:label]).to eq('lait en poudre (poudreux)')
|
|
195
|
-
end
|
|
196
|
-
end
|
|
197
|
-
end
|
|
198
|
-
end
|
|
199
|
-
end
|
|
200
|
-
# rubocop:enable RSpec/NestedGroups
|
|
201
|
-
end
|
|
202
|
-
|
|
203
|
-
describe '#find' do
|
|
204
|
-
let(:lod_oclc) { described_class.new(:OCLC_FAST) }
|
|
205
|
-
let(:lod_loc) { described_class.new(:LOC) }
|
|
206
|
-
|
|
207
|
-
context 'basic parameter testing' do
|
|
208
|
-
context 'with bad id' do
|
|
209
|
-
before do
|
|
210
|
-
stub_request(:get, 'http://id.worldcat.org/fast/FAKE_ID')
|
|
211
|
-
.to_return(status: 404, body: '', headers: {})
|
|
212
|
-
end
|
|
213
|
-
it 'raises a TermNotFound exception' do
|
|
214
|
-
expect { lod_oclc.find('FAKE_ID') }.to raise_error Qa::TermNotFound, /.*\/FAKE_ID\ Not Found - Term may not exist at LOD Authority./
|
|
215
|
-
end
|
|
216
|
-
end
|
|
217
|
-
|
|
218
|
-
# context 'with language specified' do
|
|
219
|
-
# before do
|
|
220
|
-
# stub_request(:get, 'http://id.worldcat.org/fast/FAKE_ID')
|
|
221
|
-
# .to_return(status: 404, body: '', headers: {})
|
|
222
|
-
# end
|
|
223
|
-
# it 'raises a TermNotFound exception' do
|
|
224
|
-
# expect { lod_oclc.find('FAKE_ID', language: :en) }.to raise_error Qa::TermNotFound, /.*\/FAKE_ID\ Not Found - Term may not exist at LOD Authority./
|
|
225
|
-
# end
|
|
226
|
-
# end
|
|
227
|
-
#
|
|
228
|
-
# context 'with replacements specified' do
|
|
229
|
-
# before do
|
|
230
|
-
# stub_request(:get, 'http://id.worldcat.org/fast/FAKE_ID')
|
|
231
|
-
# .to_return(status: 404, body: '', headers: {})
|
|
232
|
-
# end
|
|
233
|
-
# it 'raises a TermNotFound exception' do
|
|
234
|
-
# expect { lod_oclc.find('FAKE_ID') }.to raise_error Qa::TermNotFound, /.*\/FAKE_ID\ Not Found - Term may not exist at LOD Authority./
|
|
235
|
-
# end
|
|
236
|
-
# end
|
|
237
|
-
#
|
|
238
|
-
# context 'with subauth specified' do
|
|
239
|
-
# before do
|
|
240
|
-
# stub_request(:get, 'http://id.worldcat.org/fast/FAKE_ID')
|
|
241
|
-
# .to_return(status: 404, body: '', headers: {})
|
|
242
|
-
# end
|
|
243
|
-
# it 'raises a TermNotFound exception' do
|
|
244
|
-
# expect { lod_oclc.find('FAKE_ID') }.to raise_error Qa::TermNotFound, /.*\/FAKE_ID\ Not Found - Term may not exist at LOD Authority./
|
|
245
|
-
# end
|
|
246
|
-
# end
|
|
247
|
-
end
|
|
248
|
-
|
|
249
|
-
context 'in OCLC_FAST authority' do
|
|
250
|
-
context 'term found' do
|
|
251
|
-
let :results do
|
|
252
|
-
stub_request(:get, 'http://id.worldcat.org/fast/530369')
|
|
253
|
-
.to_return(status: 200, body: webmock_fixture('lod_oclc_term_found.rdf.xml'), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
254
|
-
lod_oclc.find('530369')
|
|
255
|
-
end
|
|
256
|
-
it 'has correct primary predicate values' do
|
|
257
|
-
expect(results[:uri]).to eq('http://id.worldcat.org/fast/530369')
|
|
258
|
-
expect(results[:id]).to eq('530369')
|
|
259
|
-
expect(results[:label]).to eq ['Cornell University']
|
|
260
|
-
expect(results[:altlabel]).to include('Ithaca (N.Y.). Cornell University', "Kornel\\xCA\\xB9skii universitet", "K\\xCA\\xBBang-nai-erh ta hs\\xC3\\xBCeh")
|
|
261
|
-
expect(results[:altlabel].size).to eq 3
|
|
262
|
-
expect(results[:sameas]).to include('http://id.loc.gov/authorities/names/n79021621', 'https://viaf.org/viaf/126293486')
|
|
263
|
-
end
|
|
264
|
-
|
|
265
|
-
it 'has correct number of predicates in pred-obj list' do
|
|
266
|
-
expect(results['predicates'].count).to eq 7
|
|
267
|
-
end
|
|
268
|
-
|
|
269
|
-
it 'has primary predicates in pred-obj list' do
|
|
270
|
-
expect(results['predicates']['http://purl.org/dc/terms/identifier']).to eq ['530369']
|
|
271
|
-
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#prefLabel']).to eq ['Cornell University']
|
|
272
|
-
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#altLabel'])
|
|
273
|
-
.to include('Ithaca (N.Y.). Cornell University', "Kornel\\xCA\\xB9skii universitet",
|
|
274
|
-
"K\\xCA\\xBBang-nai-erh ta hs\\xC3\\xBCeh")
|
|
275
|
-
expect(results['predicates']['http://schema.org/sameAs']).to include('http://id.loc.gov/authorities/names/n79021621', 'https://viaf.org/viaf/126293486')
|
|
276
|
-
end
|
|
277
|
-
|
|
278
|
-
it 'has unspecified predicate values' do
|
|
279
|
-
expect(results['predicates']['http://www.w3.org/1999/02/22-rdf-syntax-ns#type']).to eq ['http://schema.org/Organization']
|
|
280
|
-
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#inScheme'])
|
|
281
|
-
.to include('http://id.worldcat.org/fast/ontology/1.0/#fast', 'http://id.worldcat.org/fast/ontology/1.0/#facet-Corporate')
|
|
282
|
-
expect(results['predicates']['http://schema.org/name'])
|
|
283
|
-
.to include('Cornell University', 'Ithaca (N.Y.). Cornell University', "Kornel\\xCA\\xB9skii universitet",
|
|
284
|
-
"K\\xCA\\xBBang-nai-erh ta hs\\xC3\\xBCeh")
|
|
285
|
-
end
|
|
286
|
-
end
|
|
287
|
-
end
|
|
288
|
-
|
|
289
|
-
context 'in LOC authority' do
|
|
290
|
-
context 'term found' do
|
|
291
|
-
let :results do
|
|
292
|
-
stub_request(:get, 'http://id.loc.gov/authorities/subjects/sh85118553')
|
|
293
|
-
.to_return(status: 200, body: webmock_fixture('lod_loc_term_found.rdf.xml'), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
294
|
-
lod_loc.find('sh85118553', subauth: 'subjects')
|
|
295
|
-
end
|
|
296
|
-
it 'has correct primary predicate values' do
|
|
297
|
-
expect(results[:uri]).to eq 'http://id.loc.gov/authorities/subjects/sh85118553'
|
|
298
|
-
expect(results[:id]).to eq 'sh 85118553'
|
|
299
|
-
expect(results[:label]).to eq ['Science']
|
|
300
|
-
expect(results[:altlabel]).to include('Natural science', 'Science of science', 'Sciences')
|
|
301
|
-
end
|
|
302
|
-
|
|
303
|
-
it 'has correct number of predicates in pred-obj list' do
|
|
304
|
-
expect(results['predicates'].count).to eq 14
|
|
305
|
-
end
|
|
306
|
-
|
|
307
|
-
it 'has primary predicates in pred-obj list' do
|
|
308
|
-
expect(results['predicates']['http://id.loc.gov/vocabulary/identifiers/lccn']).to eq ['sh 85118553']
|
|
309
|
-
expect(results['predicates']['http://www.loc.gov/mads/rdf/v1#authoritativeLabel']).to eq ['Science']
|
|
310
|
-
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#prefLabel']).to eq ['Science']
|
|
311
|
-
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#altLabel']).to include('Natural science', 'Science of science', 'Sciences')
|
|
312
|
-
end
|
|
313
|
-
|
|
314
|
-
it 'has loc mads predicate values' do
|
|
315
|
-
expect(results['predicates']['http://www.loc.gov/mads/rdf/v1#classification']).to eq ['Q']
|
|
316
|
-
expect(results['predicates']['http://www.loc.gov/mads/rdf/v1#isMemberOfMADSCollection'])
|
|
317
|
-
.to include('http://id.loc.gov/authorities/subjects/collection_LCSHAuthorizedHeadings',
|
|
318
|
-
'http://id.loc.gov/authorities/subjects/collection_LCSH_General',
|
|
319
|
-
'http://id.loc.gov/authorities/subjects/collection_SubdivideGeographically')
|
|
320
|
-
expect(results['predicates']['http://www.loc.gov/mads/rdf/v1#hasCloseExternalAuthority'])
|
|
321
|
-
.to include('http://data.bnf.fr/ark:/12148/cb12321484k', 'http://data.bnf.fr/ark:/12148/cb119673416',
|
|
322
|
-
'http://data.bnf.fr/ark:/12148/cb119934236', 'http://data.bnf.fr/ark:/12148/cb12062047t',
|
|
323
|
-
'http://data.bnf.fr/ark:/12148/cb119469567', 'http://data.bnf.fr/ark:/12148/cb11933232c',
|
|
324
|
-
'http://data.bnf.fr/ark:/12148/cb122890536', 'http://data.bnf.fr/ark:/12148/cb121155321',
|
|
325
|
-
'http://data.bnf.fr/ark:/12148/cb15556043g', 'http://data.bnf.fr/ark:/12148/cb123662513',
|
|
326
|
-
'http://d-nb.info/gnd/4066562-8', 'http://data.bnf.fr/ark:/12148/cb120745812',
|
|
327
|
-
'http://data.bnf.fr/ark:/12148/cb11973101n', 'http://data.bnf.fr/ark:/12148/cb13328497r')
|
|
328
|
-
expect(results['predicates']['http://www.loc.gov/mads/rdf/v1#isMemberOfMADSScheme'])
|
|
329
|
-
.to eq ['http://id.loc.gov/authorities/subjects']
|
|
330
|
-
expect(results['predicates']['http://www.loc.gov/mads/rdf/v1#editorialNote'])
|
|
331
|
-
.to eq ['headings beginning with the word [Scientific;] and subdivision [Science] under ethnic groups and individual wars, e.g. [World War, 1939-1945--Science]']
|
|
332
|
-
end
|
|
333
|
-
|
|
334
|
-
it 'has more unspecified predicate values' do
|
|
335
|
-
expect(results['predicates']['http://www.w3.org/1999/02/22-rdf-syntax-ns#type']).to include('http://www.loc.gov/mads/rdf/v1#Topic', 'http://www.loc.gov/mads/rdf/v1#Authority', 'http://www.w3.org/2004/02/skos/core#Concept')
|
|
336
|
-
expect(results['predicates']['http://www.w3.org/2002/07/owl#sameAs']).to include('info:lc/authorities/sh85118553', 'http://id.loc.gov/authorities/sh85118553#concept')
|
|
337
|
-
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#closeMatch'])
|
|
338
|
-
.to include('http://data.bnf.fr/ark:/12148/cb12321484k', 'http://data.bnf.fr/ark:/12148/cb119673416',
|
|
339
|
-
'http://data.bnf.fr/ark:/12148/cb119934236', 'http://data.bnf.fr/ark:/12148/cb12062047t',
|
|
340
|
-
'http://data.bnf.fr/ark:/12148/cb119469567', 'http://data.bnf.fr/ark:/12148/cb11933232c',
|
|
341
|
-
'http://data.bnf.fr/ark:/12148/cb122890536', 'http://data.bnf.fr/ark:/12148/cb121155321',
|
|
342
|
-
'http://data.bnf.fr/ark:/12148/cb15556043g', 'http://data.bnf.fr/ark:/12148/cb123662513',
|
|
343
|
-
'http://d-nb.info/gnd/4066562-8', 'http://data.bnf.fr/ark:/12148/cb120745812',
|
|
344
|
-
'http://data.bnf.fr/ark:/12148/cb11973101n', 'http://data.bnf.fr/ark:/12148/cb13328497r')
|
|
345
|
-
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#editorial'])
|
|
346
|
-
.to eq ['headings beginning with the word [Scientific;] and subdivision [Science] under ethnic groups and individual wars, e.g. [World War, 1939-1945--Science]']
|
|
347
|
-
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#inScheme']).to eq ['http://id.loc.gov/authorities/subjects']
|
|
348
|
-
end
|
|
349
|
-
end
|
|
350
|
-
end
|
|
351
|
-
|
|
352
|
-
# rubocop:disable RSpec/NestedGroups
|
|
353
|
-
describe "language processing" do
|
|
354
|
-
context "when filtering #find result" do
|
|
355
|
-
context "and lang NOT passed in" do
|
|
356
|
-
context "and NO language defined in authority config" do
|
|
357
|
-
context "and NO language defined in Qa config" do
|
|
358
|
-
let(:lod_lang_no_defaults) { described_class.new(:LOD_LANG_NO_DEFAULTS) }
|
|
359
|
-
let :results do
|
|
360
|
-
stub_request(:get, "http://localhost/test_no_default/term/c_9513")
|
|
361
|
-
.to_return(status: 200, body: webmock_fixture("lod_lang_term_enfr.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
362
|
-
lod_lang_no_defaults.find('c_9513')
|
|
363
|
-
end
|
|
364
|
-
|
|
365
|
-
before do
|
|
366
|
-
Qa.config.default_language = []
|
|
367
|
-
end
|
|
368
|
-
|
|
369
|
-
after do
|
|
370
|
-
Qa.config.default_language = :en
|
|
371
|
-
end
|
|
372
|
-
|
|
373
|
-
it "is not filtered" do
|
|
374
|
-
expect(results[:label]).to eq ['buttermilk', 'Babeurre']
|
|
375
|
-
expect(results[:altlabel]).to eq ['yummy', 'délicieux']
|
|
376
|
-
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#prefLabel"]).to include("buttermilk", "Babeurre")
|
|
377
|
-
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#altLabel"]).to include("yummy", "délicieux")
|
|
378
|
-
end
|
|
379
|
-
end
|
|
380
|
-
context "and default_language is defined in Qa config" do
|
|
381
|
-
let(:lod_lang_no_defaults) { described_class.new(:LOD_LANG_NO_DEFAULTS) }
|
|
382
|
-
let :results do
|
|
383
|
-
stub_request(:get, "http://localhost/test_no_default/term/c_9513")
|
|
384
|
-
.to_return(status: 200, body: webmock_fixture("lod_lang_term_enfr.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
385
|
-
lod_lang_no_defaults.find('c_9513')
|
|
386
|
-
end
|
|
387
|
-
it "filters using Qa configured default for summary but not for predicates list" do
|
|
388
|
-
expect(results[:label]).to eq ['buttermilk']
|
|
389
|
-
expect(results[:altlabel]).to eq ['yummy']
|
|
390
|
-
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#prefLabel"]).to include("buttermilk", "Babeurre")
|
|
391
|
-
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#altLabel"]).to include("yummy", "délicieux")
|
|
392
|
-
end
|
|
393
|
-
end
|
|
394
|
-
end
|
|
395
|
-
context "and language IS defined in authority config" do
|
|
396
|
-
let(:lod_lang_defaults) { described_class.new(:LOD_LANG_DEFAULTS) }
|
|
397
|
-
let :results do
|
|
398
|
-
stub_request(:get, "http://localhost/test_default/term/c_9513")
|
|
399
|
-
.to_return(status: 200, body: webmock_fixture("lod_lang_term_enfr.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
400
|
-
lod_lang_defaults.find('c_9513')
|
|
401
|
-
end
|
|
402
|
-
it "filters using authority configured language for summary but not for predicates list" do
|
|
403
|
-
expect(results[:label]).to eq ['Babeurre']
|
|
404
|
-
expect(results[:altlabel]).to eq ['délicieux']
|
|
405
|
-
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#prefLabel"]).to include("buttermilk", "Babeurre")
|
|
406
|
-
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#altLabel"]).to include("yummy", "délicieux")
|
|
407
|
-
end
|
|
408
|
-
end
|
|
409
|
-
context "and multiple languages ARE defined in authority config" do
|
|
410
|
-
let(:lod_lang_multi_defaults) { described_class.new(:LOD_LANG_MULTI_DEFAULTS) }
|
|
411
|
-
let :results do
|
|
412
|
-
stub_request(:get, "http://localhost/test_default/term/c_9513")
|
|
413
|
-
.to_return(status: 200, body: webmock_fixture("lod_lang_term_enfrde.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
414
|
-
lod_lang_multi_defaults.find('c_9513')
|
|
415
|
-
end
|
|
416
|
-
it "filters using authority configured languages for summary but not for predicates list" do
|
|
417
|
-
expect(results[:label]).to eq ['buttermilk', 'Babeurre']
|
|
418
|
-
expect(results[:altlabel]).to eq ['yummy', 'délicieux']
|
|
419
|
-
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#prefLabel"]).to include("buttermilk", "Babeurre", "Buttermilch")
|
|
420
|
-
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#altLabel"]).to include("yummy", "délicieux", "lecker")
|
|
421
|
-
end
|
|
422
|
-
end
|
|
423
|
-
end
|
|
424
|
-
|
|
425
|
-
context "and lang IS passed in" do
|
|
426
|
-
let(:lod_lang_defaults) { described_class.new(:LOD_LANG_DEFAULTS) }
|
|
427
|
-
let :results do
|
|
428
|
-
stub_request(:get, "http://localhost/test_default/term/c_9513")
|
|
429
|
-
.to_return(status: 200, body: webmock_fixture("lod_lang_term_enfr.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
430
|
-
lod_lang_defaults.find('c_9513', language: 'fr')
|
|
431
|
-
end
|
|
432
|
-
it "is filtered to specified language" do
|
|
433
|
-
expect(results[:label]).to eq ['Babeurre']
|
|
434
|
-
expect(results[:altlabel]).to eq ['délicieux']
|
|
435
|
-
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#prefLabel"]).to include("buttermilk", "Babeurre")
|
|
436
|
-
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#altLabel"]).to include("yummy", "délicieux")
|
|
437
|
-
end
|
|
438
|
-
end
|
|
439
|
-
|
|
440
|
-
context "and result does not have altlabel" do
|
|
441
|
-
let(:lod_lang_defaults) { described_class.new(:LOD_LANG_DEFAULTS) }
|
|
442
|
-
let :results do
|
|
443
|
-
stub_request(:get, "http://localhost/test_default/term/c_9513")
|
|
444
|
-
.to_return(status: 200, body: webmock_fixture("lod_lang_term_enfr_noalt.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
445
|
-
lod_lang_defaults.find('c_9513', language: 'fr')
|
|
446
|
-
end
|
|
447
|
-
it "is filtered to specified language" do
|
|
448
|
-
expect(results[:label]).to eq ['Babeurre']
|
|
449
|
-
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#prefLabel"]).to include("buttermilk", "Babeurre")
|
|
450
|
-
end
|
|
451
|
-
end
|
|
452
|
-
|
|
453
|
-
context "when replacement on authority term URL" do
|
|
454
|
-
context "and using default" do
|
|
455
|
-
let(:lod_lang_param) { described_class.new(:LOD_LANG_PARAM) }
|
|
456
|
-
let :results do
|
|
457
|
-
stub_request(:get, "http://localhost/test_replacement/term/c_9513?lang=en")
|
|
458
|
-
.to_return(status: 200, body: webmock_fixture("lod_lang_term_en.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
459
|
-
lod_lang_param.find("c_9513")
|
|
460
|
-
end
|
|
461
|
-
it "is correctly parsed" do
|
|
462
|
-
expect(results[:label]).to eq ['buttermilk']
|
|
463
|
-
expect(results[:altlabel]).to eq ['yummy']
|
|
464
|
-
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#prefLabel"]).to eq ['buttermilk']
|
|
465
|
-
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#altLabel"]).to eq ['yummy']
|
|
466
|
-
end
|
|
467
|
-
end
|
|
468
|
-
|
|
469
|
-
context "and lang specified" do
|
|
470
|
-
let(:lod_lang_param) { described_class.new(:LOD_LANG_PARAM) }
|
|
471
|
-
let :results do
|
|
472
|
-
stub_request(:get, "http://localhost/test_replacement/term/c_9513?lang=fr")
|
|
473
|
-
.to_return(status: 200, body: webmock_fixture("lod_lang_term_fr.rdf.xml"), headers: { 'Content-Type' => 'application/rdf+xml' })
|
|
474
|
-
lod_lang_param.find("c_9513", replacements: { 'lang' => 'fr' })
|
|
475
|
-
end
|
|
476
|
-
it "is correctly parsed" do
|
|
477
|
-
expect(results[:label]).to eq ['Babeurre']
|
|
478
|
-
expect(results[:altlabel]).to eq ['délicieux']
|
|
479
|
-
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#prefLabel"]).to eq ['Babeurre']
|
|
480
|
-
expect(results["predicates"]["http://www.w3.org/2004/02/skos/core#altLabel"]).to eq ['délicieux']
|
|
481
|
-
end
|
|
482
|
-
end
|
|
483
|
-
end
|
|
484
|
-
end
|
|
485
|
-
end
|
|
486
|
-
# rubocop:enable RSpec/NestedGroups
|
|
487
|
-
end
|
|
488
|
-
|
|
489
4
|
describe '#new' do
|
|
490
5
|
context 'without an authority' do
|
|
491
6
|
it 'raises an exception' do
|
|
@@ -599,5 +114,51 @@ RSpec.describe Qa::Authorities::LinkedData::GenericAuthority do
|
|
|
599
114
|
expect(min_authority.term_id_expects_uri?).to eq true
|
|
600
115
|
end
|
|
601
116
|
end
|
|
117
|
+
|
|
118
|
+
describe '#search' do
|
|
119
|
+
it 'responds to delegated search method' do
|
|
120
|
+
expect(min_authority).to respond_to :search
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
describe '#find' do
|
|
125
|
+
it 'responds to delegated search method' do
|
|
126
|
+
expect(min_authority).to respond_to :find
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
describe '#load_authorities' do
|
|
131
|
+
it 'responds to delegated search method' do
|
|
132
|
+
expect(min_authority).to respond_to :load_authorities
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
describe '#authority_names' do
|
|
137
|
+
it 'responds to delegated search method' do
|
|
138
|
+
expect(min_authority).to respond_to :authority_names
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
context 'testing service methods' do
|
|
144
|
+
let(:min_authority) { described_class.new(:LOD_MIN_CONFIG) }
|
|
145
|
+
|
|
146
|
+
describe '#authorities_service' do
|
|
147
|
+
it 'returns Qa::LinkedData::AuthorityService as the authorities service' do
|
|
148
|
+
expect(min_authority.authorities_service).to eq Qa::LinkedData::AuthorityService
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
describe '#search_service' do
|
|
153
|
+
it 'returns Qa::Authorities::LinkedData::SearchQuery as the search service' do
|
|
154
|
+
expect(min_authority.search_service).to be_kind_of Qa::Authorities::LinkedData::SearchQuery
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
describe '#item_service' do
|
|
159
|
+
it 'returns Qa::Authorities::LinkedData::FindTerm as the item service' do
|
|
160
|
+
expect(min_authority.item_service).to be_kind_of Qa::Authorities::LinkedData::FindTerm
|
|
161
|
+
end
|
|
162
|
+
end
|
|
602
163
|
end
|
|
603
164
|
end
|