qa 2.0.0 → 2.3.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 +5 -5
- data/README.md +54 -6
- data/app/controllers/qa/application_controller.rb +24 -0
- data/app/controllers/qa/linked_data_terms_controller.rb +116 -51
- data/app/controllers/qa/terms_controller.rb +7 -2
- data/app/models/qa/mesh_tree.rb +5 -9
- data/app/models/qa/subject_mesh_term.rb +2 -7
- data/config/authorities/linked_data/agrovoc.json +8 -1
- data/config/initializers/linked_data_authorities.rb +1 -17
- data/config/routes.rb +11 -0
- data/lib/generators/qa/apidoc/USAGE +11 -0
- data/lib/generators/qa/apidoc/apidoc_generator.rb +22 -0
- data/lib/generators/qa/apidoc/templates/public/qa/apidoc/apidoc.json +1322 -0
- data/lib/generators/qa/apidoc/templates/public/qa/apidoc/favicon-16x16.png +0 -0
- data/lib/generators/qa/apidoc/templates/public/qa/apidoc/favicon-32x32.png +0 -0
- data/lib/generators/qa/apidoc/templates/public/qa/apidoc/index.html +61 -0
- data/lib/generators/qa/apidoc/templates/public/qa/apidoc/oauth2-redirect.html +67 -0
- data/lib/generators/qa/apidoc/templates/public/qa/apidoc/swagger-ui-bundle.js +93 -0
- data/lib/generators/qa/apidoc/templates/public/qa/apidoc/swagger-ui-bundle.js.map +1 -0
- data/lib/generators/qa/apidoc/templates/public/qa/apidoc/swagger-ui-standalone-preset.js +14 -0
- data/lib/generators/qa/apidoc/templates/public/qa/apidoc/swagger-ui-standalone-preset.js.map +1 -0
- data/lib/generators/qa/apidoc/templates/public/qa/apidoc/swagger-ui.css +3 -0
- data/lib/generators/qa/apidoc/templates/public/qa/apidoc/swagger-ui.css.map +1 -0
- data/lib/generators/qa/apidoc/templates/public/qa/apidoc/swagger-ui.js +9 -0
- data/lib/generators/qa/apidoc/templates/public/qa/apidoc/swagger-ui.js.map +1 -0
- data/lib/generators/qa/install/install_generator.rb +11 -0
- data/lib/generators/qa/install/templates/config/initializers/qa.rb +13 -0
- data/lib/generators/qa/local/tables/mysql/mysql_generator.rb +1 -1
- data/lib/generators/qa/local/tables/tables_generator.rb +1 -1
- data/lib/qa.rb +16 -0
- data/lib/qa/authorities/assign_fast_subauthority.rb +3 -3
- data/lib/qa/authorities/getty/aat.rb +13 -6
- data/lib/qa/authorities/getty/tgn.rb +11 -22
- data/lib/qa/authorities/getty/ulan.rb +13 -16
- data/lib/qa/authorities/linked_data.rb +1 -0
- data/lib/qa/authorities/linked_data/authority_service.rb +47 -0
- data/lib/qa/authorities/linked_data/config.rb +9 -3
- data/lib/qa/authorities/linked_data/config/search_config.rb +16 -2
- data/lib/qa/authorities/linked_data/config/term_config.rb +17 -3
- data/lib/qa/authorities/linked_data/find_term.rb +4 -3
- data/lib/qa/authorities/linked_data/generic_authority.rb +8 -1
- data/lib/qa/authorities/linked_data/rdf_helper.rb +15 -0
- data/lib/qa/authorities/linked_data/search_query.rb +19 -3
- data/lib/qa/authorities/loc/generic_authority.rb +2 -2
- data/lib/qa/authorities/loc_subauthority.rb +2 -2
- data/lib/qa/authorities/local.rb +2 -4
- data/lib/qa/authorities/local/file_based_authority.rb +1 -1
- data/lib/qa/authorities/local/mysql_table_based_authority.rb +11 -2
- data/lib/qa/authorities/local/table_based_authority.rb +2 -1
- data/lib/qa/authorities/mesh_tools/mesh_data_parser.rb +1 -1
- data/lib/qa/authorities/mesh_tools/mesh_importer.rb +1 -1
- data/lib/qa/authorities/oclcts/generic_oclc_authority.rb +1 -3
- data/lib/qa/configuration.rb +34 -0
- data/lib/qa/version.rb +1 -1
- data/lib/tasks/mesh.rake +3 -3
- data/spec/controllers/linked_data_terms_controller_spec.rb +247 -18
- data/spec/controllers/terms_controller_spec.rb +87 -12
- data/spec/fixtures/authorities/linked_data/lod_encoding_config.json +91 -0
- data/spec/fixtures/authorities/linked_data/lod_term_id_param_config.json +27 -0
- data/spec/fixtures/authorities/linked_data/lod_term_uri_param_config.json +27 -0
- data/spec/fixtures/{lexvo_snippet.rdf → lexvo_snippet.rdf.xml} +1 -0
- data/spec/lib/authorities/assign_fast_spec.rb +3 -1
- data/spec/lib/authorities/file_based_authority_spec.rb +19 -11
- data/spec/lib/authorities/geonames_spec.rb +3 -3
- data/spec/lib/authorities/getty/aat_spec.rb +14 -8
- data/spec/lib/authorities/getty/tgn_spec.rb +8 -15
- data/spec/lib/authorities/getty/ulan_spec.rb +8 -6
- data/spec/lib/authorities/getty_spec.rb +2 -1
- data/spec/lib/authorities/linked_data/authority_service_spec.rb +47 -0
- data/spec/lib/authorities/linked_data/generic_authority_spec.rb +56 -14
- data/spec/lib/authorities/linked_data/search_config_spec.rb +33 -19
- data/spec/lib/authorities/linked_data/search_query_spec.rb +67 -15
- data/spec/lib/authorities/linked_data/term_config_spec.rb +34 -20
- data/spec/lib/authorities/loc_spec.rb +9 -9
- data/spec/lib/authorities/local_spec.rb +7 -8
- data/spec/lib/authorities/oclcts_spec.rb +27 -20
- data/spec/lib/authorities/table_based_authority_spec.rb +5 -3
- data/spec/lib/authorities_loc_subauthorities.rb +2 -2
- data/spec/lib/configuration_spec.rb +58 -0
- data/spec/lib/mesh_data_parser_spec.rb +2 -0
- data/spec/lib/services/rdf_authority_parser_spec.rb +1 -1
- data/spec/lib/tasks/mesh.rake_spec.rb +13 -12
- data/spec/models/subject_mesh_term_spec.rb +2 -0
- data/spec/requests/cors_headers_spec.rb +118 -0
- data/spec/spec_helper.rb +2 -2
- metadata +167 -137
|
@@ -69,25 +69,27 @@ describe Qa::Authorities::Getty::Ulan do
|
|
|
69
69
|
describe "#sparql" do
|
|
70
70
|
context "using a single subject term" do
|
|
71
71
|
subject { authority.sparql('search_term') }
|
|
72
|
-
it {
|
|
72
|
+
it {
|
|
73
|
+
is_expected.to eq 'SELECT DISTINCT ?s ?name ?bio {
|
|
73
74
|
?s a skos:Concept; luc:term "search_term";
|
|
74
75
|
skos:inScheme <http://vocab.getty.edu/ulan/> ;
|
|
75
76
|
gvp:prefLabelGVP [skosxl:literalForm ?name] ;
|
|
76
77
|
foaf:focus/gvp:biographyPreferred [schema:description ?bio] ;
|
|
77
78
|
skos:altLabel ?alt .
|
|
78
79
|
FILTER regex(?name, "search_term", "i") .
|
|
79
|
-
} ORDER BY ?name' }
|
|
80
|
+
} ORDER BY ?name'.gsub(/[\s\n]+/, ' ') }
|
|
80
81
|
end
|
|
81
82
|
context "using a two subject terms" do
|
|
82
83
|
subject { authority.sparql('search term') }
|
|
83
|
-
it {
|
|
84
|
-
|
|
84
|
+
it {
|
|
85
|
+
is_expected.to eq %(SELECT DISTINCT ?s ?name ?bio {
|
|
86
|
+
?s a skos:Concept; luc:term "search term";
|
|
85
87
|
skos:inScheme <http://vocab.getty.edu/ulan/> ;
|
|
86
88
|
gvp:prefLabelGVP [skosxl:literalForm ?name] ;
|
|
87
89
|
foaf:focus/gvp:biographyPreferred [schema:description ?bio] ;
|
|
88
90
|
skos:altLabel ?alt .
|
|
89
|
-
FILTER (regex(
|
|
90
|
-
} ORDER BY ?name
|
|
91
|
+
FILTER ((regex(?name, "search", "i") || regex(?alt, "search", "i")) && (regex(?name, "term", "i") || regex(?alt, "term", "i"))) .
|
|
92
|
+
} ORDER BY ?name).gsub(/[\s\n]+/, ' ') }
|
|
91
93
|
end
|
|
92
94
|
end
|
|
93
95
|
end
|
|
@@ -3,7 +3,8 @@ require 'spec_helper'
|
|
|
3
3
|
describe Qa::Authorities::Getty do
|
|
4
4
|
describe "#new" do
|
|
5
5
|
it "raises an exception" do
|
|
6
|
-
|
|
6
|
+
msg = "Initializing with as sub authority is removed. use Module.subauthority_for(nil) instead"
|
|
7
|
+
expect { described_class.new }.to raise_error RuntimeError, msg
|
|
7
8
|
end
|
|
8
9
|
end
|
|
9
10
|
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Qa::Authorities::LinkedData::AuthorityService do
|
|
4
|
+
let(:auth_names) do
|
|
5
|
+
[:AGROVOC,
|
|
6
|
+
:LOC,
|
|
7
|
+
:LOD_ENCODING_CONFIG,
|
|
8
|
+
:LOD_FULL_CONFIG,
|
|
9
|
+
:LOD_LANG_DEFAULTS,
|
|
10
|
+
:LOD_LANG_MULTI_DEFAULTS,
|
|
11
|
+
:LOD_LANG_NO_DEFAULTS,
|
|
12
|
+
:LOD_LANG_PARAM,
|
|
13
|
+
:LOD_MIN_CONFIG,
|
|
14
|
+
:LOD_SEARCH_ONLY_CONFIG,
|
|
15
|
+
:LOD_SORT,
|
|
16
|
+
:LOD_TERM_ID_PARAM_CONFIG,
|
|
17
|
+
:LOD_TERM_ONLY_CONFIG,
|
|
18
|
+
:LOD_TERM_URI_PARAM_CONFIG,
|
|
19
|
+
:OCLC_FAST]
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe '#authority_configs' do
|
|
23
|
+
let(:result) { described_class.authority_configs }
|
|
24
|
+
it 'returns all authorities' do
|
|
25
|
+
expect(result).to be_kind_of(Hash)
|
|
26
|
+
expect(result.keys).to match_array auth_names
|
|
27
|
+
expect(result.values.first).to be_kind_of(Hash)
|
|
28
|
+
expect(result.values.first).to have_key(:term)
|
|
29
|
+
expect(result.values.first).to have_key(:search)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe '#authority_config' do
|
|
34
|
+
let(:result) { described_class.authority_config(:LOD_FULL_CONFIG) }
|
|
35
|
+
it 'returns a single authority' do
|
|
36
|
+
expect(result).to be_kind_of(Hash)
|
|
37
|
+
expect(result).to have_key(:term)
|
|
38
|
+
expect(result).to have_key(:search)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe '#authority_names' do
|
|
43
|
+
it "returns a list of all authorities' names" do
|
|
44
|
+
expect(described_class.authority_names).to eq auth_names
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -62,7 +62,7 @@ RSpec.describe Qa::Authorities::LinkedData::GenericAuthority do
|
|
|
62
62
|
context 'in AGROVOC authority' do
|
|
63
63
|
context '0 search results' do
|
|
64
64
|
let :results do
|
|
65
|
-
stub_request(:get, 'http://artemide.art.uniroma2.it:8081/agrovoc/rest/v1/search/?lang=en&query=*supercalifragilisticexpialidocious
|
|
65
|
+
stub_request(:get, 'http://artemide.art.uniroma2.it:8081/agrovoc/rest/v1/search/?lang=en&query=*supercalifragilisticexpialidocious*&maxhits=20')
|
|
66
66
|
.to_return(status: 200, body: webmock_fixture('lod_agrovoc_query_no_results.json'), headers: { 'Content-Type' => 'application/json' })
|
|
67
67
|
lod_agrovoc.search('supercalifragilisticexpialidocious')
|
|
68
68
|
end
|
|
@@ -73,7 +73,7 @@ RSpec.describe Qa::Authorities::LinkedData::GenericAuthority do
|
|
|
73
73
|
|
|
74
74
|
context '3 search results' do
|
|
75
75
|
let :results do
|
|
76
|
-
stub_request(:get, 'http://artemide.art.uniroma2.it:8081/agrovoc/rest/v1/search/?lang=en&query=*milk
|
|
76
|
+
stub_request(:get, 'http://artemide.art.uniroma2.it:8081/agrovoc/rest/v1/search/?lang=en&query=*milk*&maxhits=20')
|
|
77
77
|
.to_return(status: 200, body: webmock_fixture('lod_agrovoc_query_many_results.json'), headers: { 'Content-Type' => 'application/json' })
|
|
78
78
|
lod_agrovoc.search('milk')
|
|
79
79
|
end
|
|
@@ -93,6 +93,7 @@ RSpec.describe Qa::Authorities::LinkedData::GenericAuthority do
|
|
|
93
93
|
# # let(:lod_loc) { Qa::Authorities::LinkedData::GenericAuthority.new(:LOC) }
|
|
94
94
|
# end
|
|
95
95
|
|
|
96
|
+
# rubocop:disable RSpec/NestedGroups
|
|
96
97
|
describe "language processing" do
|
|
97
98
|
context "when filtering #search results" do
|
|
98
99
|
context "and lang NOT passed in" do
|
|
@@ -184,6 +185,7 @@ RSpec.describe Qa::Authorities::LinkedData::GenericAuthority do
|
|
|
184
185
|
end
|
|
185
186
|
end
|
|
186
187
|
end
|
|
188
|
+
# rubocop:enable RSpec/NestedGroups
|
|
187
189
|
end
|
|
188
190
|
|
|
189
191
|
describe '#find' do
|
|
@@ -195,7 +197,7 @@ RSpec.describe Qa::Authorities::LinkedData::GenericAuthority do
|
|
|
195
197
|
context 'with bad id' do
|
|
196
198
|
before do
|
|
197
199
|
stub_request(:get, 'http://id.worldcat.org/fast/FAKE_ID')
|
|
198
|
-
.to_return(status: 404, body: '', headers:
|
|
200
|
+
.to_return(status: 404, body: '', headers: {})
|
|
199
201
|
end
|
|
200
202
|
it 'raises a TermNotFound exception' do
|
|
201
203
|
expect { lod_oclc.find('FAKE_ID') }.to raise_error Qa::TermNotFound, /.*\/FAKE_ID\ Not Found - Term may not exist at LOD Authority./
|
|
@@ -256,14 +258,19 @@ RSpec.describe Qa::Authorities::LinkedData::GenericAuthority do
|
|
|
256
258
|
it 'has primary predicates in pred-obj list' do
|
|
257
259
|
expect(results['predicates']['http://purl.org/dc/terms/identifier']).to eq ['530369']
|
|
258
260
|
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#prefLabel']).to eq ['Cornell University']
|
|
259
|
-
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#altLabel'])
|
|
261
|
+
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#altLabel'])
|
|
262
|
+
.to include('Ithaca (N.Y.). Cornell University', "Kornel\\xCA\\xB9skii universitet",
|
|
263
|
+
"K\\xCA\\xBBang-nai-erh ta hs\\xC3\\xBCeh")
|
|
260
264
|
expect(results['predicates']['http://schema.org/sameAs']).to include('http://id.loc.gov/authorities/names/n79021621', 'https://viaf.org/viaf/126293486')
|
|
261
265
|
end
|
|
262
266
|
|
|
263
267
|
it 'has unspecified predicate values' do
|
|
264
268
|
expect(results['predicates']['http://www.w3.org/1999/02/22-rdf-syntax-ns#type']).to eq ['http://schema.org/Organization']
|
|
265
|
-
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#inScheme'])
|
|
266
|
-
|
|
269
|
+
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#inScheme'])
|
|
270
|
+
.to include('http://id.worldcat.org/fast/ontology/1.0/#fast', 'http://id.worldcat.org/fast/ontology/1.0/#facet-Corporate')
|
|
271
|
+
expect(results['predicates']['http://schema.org/name'])
|
|
272
|
+
.to include('Cornell University', 'Ithaca (N.Y.). Cornell University', "Kornel\\xCA\\xB9skii universitet",
|
|
273
|
+
"K\\xCA\\xBBang-nai-erh ta hs\\xC3\\xBCeh")
|
|
267
274
|
end
|
|
268
275
|
end
|
|
269
276
|
end
|
|
@@ -290,11 +297,24 @@ RSpec.describe Qa::Authorities::LinkedData::GenericAuthority do
|
|
|
290
297
|
it 'has primary predicates in pred-obj list' do
|
|
291
298
|
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#prefLabel']).to eq ['buttermilk']
|
|
292
299
|
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#broader']).to eq ['http://aims.fao.org/aos/agrovoc/c_4830']
|
|
293
|
-
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#exactMatch'])
|
|
300
|
+
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#exactMatch'])
|
|
301
|
+
.to include('http://cat.aii.caas.cn/concept/c_26308', 'http://lod.nal.usda.gov/nalt/20627',
|
|
302
|
+
'http://d-nb.info/gnd/4147072-2')
|
|
294
303
|
end
|
|
295
304
|
|
|
296
305
|
it 'has skos predicate values' do
|
|
297
|
-
expect(results['predicates']['http://www.w3.org/2008/05/skos-xl#prefLabel'])
|
|
306
|
+
expect(results['predicates']['http://www.w3.org/2008/05/skos-xl#prefLabel'])
|
|
307
|
+
.to include('http://aims.fao.org/aos/agrovoc/xl_es_1299487482038', 'http://aims.fao.org/aos/agrovoc/xl_it_1299487482154',
|
|
308
|
+
'http://aims.fao.org/aos/agrovoc/xl_ko_1299487482210', 'http://aims.fao.org/aos/agrovoc/xl_pl_1299487482273',
|
|
309
|
+
'http://aims.fao.org/aos/agrovoc/xl_sk_1299487482378', 'http://aims.fao.org/aos/agrovoc/xl_en_1299487482019',
|
|
310
|
+
'http://aims.fao.org/aos/agrovoc/xl_tr_9513_1321792194941',
|
|
311
|
+
'http://aims.fao.org/aos/agrovoc/xl_de_1299487482000', 'http://aims.fao.org/aos/agrovoc/xl_fa_1299487482058',
|
|
312
|
+
'http://aims.fao.org/aos/agrovoc/xl_th_1299487482417', 'http://aims.fao.org/aos/agrovoc/xl_fr_1299487482080',
|
|
313
|
+
'http://aims.fao.org/aos/agrovoc/xl_hi_1299487482102', 'http://aims.fao.org/aos/agrovoc/xl_ar_1299487481966',
|
|
314
|
+
'http://aims.fao.org/aos/agrovoc/xl_ja_1299487482181', 'http://aims.fao.org/aos/agrovoc/xl_lo_1299487482240',
|
|
315
|
+
'http://aims.fao.org/aos/agrovoc/xl_ru_1299487482341', 'http://aims.fao.org/aos/agrovoc/xl_cs_1299487481982',
|
|
316
|
+
'http://aims.fao.org/aos/agrovoc/xl_zh_1299487482458', 'http://aims.fao.org/aos/agrovoc/xl_pt_1299487482307',
|
|
317
|
+
'http://aims.fao.org/aos/agrovoc/xl_hu_1299487482127')
|
|
298
318
|
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#inScheme']).to eq ['http://aims.fao.org/aos/agrovoc']
|
|
299
319
|
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#closeMatch']).to eq ['http://dbpedia.org/resource/Buttermilk']
|
|
300
320
|
expect(results['predicates']['http://www.w3.org/2008/05/skos-xl#altLabel']).to eq ['http://aims.fao.org/aos/agrovoc/xl_fa_1299487482544']
|
|
@@ -337,22 +357,43 @@ RSpec.describe Qa::Authorities::LinkedData::GenericAuthority do
|
|
|
337
357
|
|
|
338
358
|
it 'has loc mads predicate values' do
|
|
339
359
|
expect(results['predicates']['http://www.loc.gov/mads/rdf/v1#classification']).to eq ['Q']
|
|
340
|
-
expect(results['predicates']['http://www.loc.gov/mads/rdf/v1#isMemberOfMADSCollection'])
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
360
|
+
expect(results['predicates']['http://www.loc.gov/mads/rdf/v1#isMemberOfMADSCollection'])
|
|
361
|
+
.to include('http://id.loc.gov/authorities/subjects/collection_LCSHAuthorizedHeadings',
|
|
362
|
+
'http://id.loc.gov/authorities/subjects/collection_LCSH_General',
|
|
363
|
+
'http://id.loc.gov/authorities/subjects/collection_SubdivideGeographically')
|
|
364
|
+
expect(results['predicates']['http://www.loc.gov/mads/rdf/v1#hasCloseExternalAuthority'])
|
|
365
|
+
.to include('http://data.bnf.fr/ark:/12148/cb12321484k', 'http://data.bnf.fr/ark:/12148/cb119673416',
|
|
366
|
+
'http://data.bnf.fr/ark:/12148/cb119934236', 'http://data.bnf.fr/ark:/12148/cb12062047t',
|
|
367
|
+
'http://data.bnf.fr/ark:/12148/cb119469567', 'http://data.bnf.fr/ark:/12148/cb11933232c',
|
|
368
|
+
'http://data.bnf.fr/ark:/12148/cb122890536', 'http://data.bnf.fr/ark:/12148/cb121155321',
|
|
369
|
+
'http://data.bnf.fr/ark:/12148/cb15556043g', 'http://data.bnf.fr/ark:/12148/cb123662513',
|
|
370
|
+
'http://d-nb.info/gnd/4066562-8', 'http://data.bnf.fr/ark:/12148/cb120745812',
|
|
371
|
+
'http://data.bnf.fr/ark:/12148/cb11973101n', 'http://data.bnf.fr/ark:/12148/cb13328497r')
|
|
372
|
+
expect(results['predicates']['http://www.loc.gov/mads/rdf/v1#isMemberOfMADSScheme'])
|
|
373
|
+
.to eq ['http://id.loc.gov/authorities/subjects']
|
|
374
|
+
expect(results['predicates']['http://www.loc.gov/mads/rdf/v1#editorialNote'])
|
|
375
|
+
.to eq ['headings beginning with the word [Scientific;] and subdivision [Science] under ethnic groups and individual wars, e.g. [World War, 1939-1945--Science]']
|
|
344
376
|
end
|
|
345
377
|
|
|
346
378
|
it 'has more unspecified predicate values' do
|
|
347
379
|
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')
|
|
348
380
|
expect(results['predicates']['http://www.w3.org/2002/07/owl#sameAs']).to include('info:lc/authorities/sh85118553', 'http://id.loc.gov/authorities/sh85118553#concept')
|
|
349
|
-
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#closeMatch'])
|
|
350
|
-
|
|
381
|
+
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#closeMatch'])
|
|
382
|
+
.to include('http://data.bnf.fr/ark:/12148/cb12321484k', 'http://data.bnf.fr/ark:/12148/cb119673416',
|
|
383
|
+
'http://data.bnf.fr/ark:/12148/cb119934236', 'http://data.bnf.fr/ark:/12148/cb12062047t',
|
|
384
|
+
'http://data.bnf.fr/ark:/12148/cb119469567', 'http://data.bnf.fr/ark:/12148/cb11933232c',
|
|
385
|
+
'http://data.bnf.fr/ark:/12148/cb122890536', 'http://data.bnf.fr/ark:/12148/cb121155321',
|
|
386
|
+
'http://data.bnf.fr/ark:/12148/cb15556043g', 'http://data.bnf.fr/ark:/12148/cb123662513',
|
|
387
|
+
'http://d-nb.info/gnd/4066562-8', 'http://data.bnf.fr/ark:/12148/cb120745812',
|
|
388
|
+
'http://data.bnf.fr/ark:/12148/cb11973101n', 'http://data.bnf.fr/ark:/12148/cb13328497r')
|
|
389
|
+
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#editorial'])
|
|
390
|
+
.to eq ['headings beginning with the word [Scientific;] and subdivision [Science] under ethnic groups and individual wars, e.g. [World War, 1939-1945--Science]']
|
|
351
391
|
expect(results['predicates']['http://www.w3.org/2004/02/skos/core#inScheme']).to eq ['http://id.loc.gov/authorities/subjects']
|
|
352
392
|
end
|
|
353
393
|
end
|
|
354
394
|
end
|
|
355
395
|
|
|
396
|
+
# rubocop:disable RSpec/NestedGroups
|
|
356
397
|
describe "language processing" do
|
|
357
398
|
context "when filtering #find result" do
|
|
358
399
|
context "and lang NOT passed in" do
|
|
@@ -461,6 +502,7 @@ RSpec.describe Qa::Authorities::LinkedData::GenericAuthority do
|
|
|
461
502
|
end
|
|
462
503
|
end
|
|
463
504
|
end
|
|
505
|
+
# rubocop:enable RSpec/NestedGroups
|
|
464
506
|
end
|
|
465
507
|
|
|
466
508
|
describe '#new' do
|
|
@@ -4,6 +4,7 @@ RSpec.describe Qa::Authorities::LinkedData::SearchConfig do
|
|
|
4
4
|
let(:full_config) { Qa::Authorities::LinkedData::Config.new(:LOD_FULL_CONFIG).search }
|
|
5
5
|
let(:min_config) { Qa::Authorities::LinkedData::Config.new(:LOD_MIN_CONFIG).search }
|
|
6
6
|
let(:term_only_config) { Qa::Authorities::LinkedData::Config.new(:LOD_TERM_ONLY_CONFIG).search }
|
|
7
|
+
let(:encoding_config) { Qa::Authorities::LinkedData::Config.new(:LOD_ENCODING_CONFIG).search }
|
|
7
8
|
|
|
8
9
|
describe '#search_config' do
|
|
9
10
|
let(:full_search_config) do
|
|
@@ -335,29 +336,32 @@ RSpec.describe Qa::Authorities::LinkedData::SearchConfig do
|
|
|
335
336
|
end
|
|
336
337
|
end
|
|
337
338
|
|
|
339
|
+
# rubocop:disable RSpec/RepeatedExample
|
|
338
340
|
describe '#search_url_with_replacements' do
|
|
339
341
|
it 'returns nil if only term configuration is defined' do
|
|
340
342
|
expect(term_only_config.url_with_replacements('Smith')).to eq nil
|
|
341
343
|
end
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
344
|
+
context 'when subauthorities ARE defined' do
|
|
345
|
+
it 'returns the url with query substitution applied' do
|
|
346
|
+
expected_url = 'http://localhost/test_default/search?subauth=search_sub1_name&query=Smith¶m1=delta¶m2=echo'
|
|
347
|
+
expect(full_config.url_with_replacements('Smith')).to eq expected_url
|
|
348
|
+
end
|
|
349
|
+
it 'returns the url with default subauthority when NOT specified' do
|
|
350
|
+
expected_url = 'http://localhost/test_default/search?subauth=search_sub1_name&query=Smith¶m1=delta¶m2=echo'
|
|
351
|
+
expect(full_config.url_with_replacements('Smith')).to eq expected_url
|
|
352
|
+
end
|
|
353
|
+
it 'returns the url with subauthority substitution when specified' do
|
|
354
|
+
expected_url = 'http://localhost/test_default/search?subauth=search_sub3_name&query=Smith¶m1=delta¶m2=echo'
|
|
355
|
+
expect(full_config.url_with_replacements('Smith', 'search_sub3_key')).to eq expected_url
|
|
356
|
+
end
|
|
357
|
+
it 'returns the url with default values when replacements are NOT specified' do
|
|
358
|
+
expected_url = 'http://localhost/test_default/search?subauth=search_sub1_name&query=Smith¶m1=delta¶m2=echo'
|
|
359
|
+
expect(full_config.url_with_replacements('Smith')).to eq expected_url
|
|
360
|
+
end
|
|
361
|
+
it 'returns the url with replacement substitution values when replacements are specified' do
|
|
362
|
+
expected_url = 'http://localhost/test_default/search?subauth=search_sub1_name&query=Smith¶m1=golf¶m2=hotel'
|
|
363
|
+
expect(full_config.url_with_replacements('Smith', nil, param1: 'golf', param2: 'hotel')).to eq expected_url
|
|
364
|
+
end
|
|
361
365
|
end
|
|
362
366
|
|
|
363
367
|
context 'when subauthorities are not defined' do
|
|
@@ -381,5 +385,15 @@ RSpec.describe Qa::Authorities::LinkedData::SearchConfig do
|
|
|
381
385
|
expect(min_config.url_with_replacements('Smith', nil, fake_replacement_key: 'fake_value')).to eq expected_url
|
|
382
386
|
end
|
|
383
387
|
end
|
|
388
|
+
|
|
389
|
+
context 'with encoding specified in config' do
|
|
390
|
+
it 'returns the uri as the url' do
|
|
391
|
+
expected_url = 'http://localhost/test_default/search?query=encoded%20because%3Aencode%3Dtrue&yes%3Aencoded%20here&no:encoding here&defaults:to not encoded'
|
|
392
|
+
query = 'encoded because:encode=true'
|
|
393
|
+
replacements = { encode_true: 'yes:encoded here', encode_false: 'no:encoding here', encode_not_specified: 'defaults:to not encoded' }
|
|
394
|
+
expect(encoding_config.url_with_replacements(query, nil, replacements)).to eq expected_url
|
|
395
|
+
end
|
|
396
|
+
end
|
|
384
397
|
end
|
|
398
|
+
# rubocop:enable RSpec/RepeatedExample
|
|
385
399
|
end
|
|
@@ -14,7 +14,9 @@ RSpec.describe Qa::Authorities::LinkedData::SearchQuery do
|
|
|
14
14
|
let(:auth_name) { :LOD_MIN_CONFIG }
|
|
15
15
|
|
|
16
16
|
it "does not change order" do
|
|
17
|
-
json_results = [{ label: "[#{term_b}, #{term_c}]", sort: [term_b, term_c] },
|
|
17
|
+
json_results = [{ label: "[#{term_b}, #{term_c}]", sort: [term_b, term_c] },
|
|
18
|
+
{ label: "[#{term_b}, #{term_d}]", sort: [term_b, term_d] },
|
|
19
|
+
{ label: "[#{term_b}, #{term_a}]", sort: [term_b, term_a] }]
|
|
18
20
|
expect(instance.send(:sort_search_results, json_results)).to eq json_results
|
|
19
21
|
end
|
|
20
22
|
end
|
|
@@ -22,28 +24,58 @@ RSpec.describe Qa::Authorities::LinkedData::SearchQuery do
|
|
|
22
24
|
context 'when sort predicate is specified in configuration' do
|
|
23
25
|
let(:auth_name) { :LOD_SORT }
|
|
24
26
|
|
|
25
|
-
context "
|
|
27
|
+
context "and sort term is empty" do
|
|
26
28
|
context "for all" do
|
|
27
29
|
it "does not change order" do
|
|
28
|
-
json_results = [{ label: "[#{term_b}]", sort: [""] },
|
|
30
|
+
json_results = [{ label: "[#{term_b}]", sort: [""] },
|
|
31
|
+
{ label: "[#{term_a}]", sort: [""] },
|
|
32
|
+
{ label: "[#{term_c}]", sort: [""] }]
|
|
29
33
|
expect(instance.send(:sort_search_results, json_results)).to eq json_results
|
|
30
34
|
end
|
|
31
35
|
end
|
|
32
36
|
|
|
33
37
|
context "for one" do
|
|
34
|
-
it "puts empty first" do
|
|
35
|
-
json_results = [{ label: "[
|
|
36
|
-
|
|
38
|
+
it "puts empty first when empty is in 1st position" do
|
|
39
|
+
json_results = [{ label: "['_empty_1_']", sort: [""] },
|
|
40
|
+
{ label: "[#{term_c}]", sort: [term_c] },
|
|
41
|
+
{ label: "[#{term_a}]", sort: [term_a] }]
|
|
42
|
+
expected_results = [{ label: "['_empty_1_']" },
|
|
43
|
+
{ label: "[#{term_a}]" },
|
|
44
|
+
{ label: "[#{term_c}]" }]
|
|
45
|
+
expect(instance.send(:sort_search_results, json_results)).to eq expected_results
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "puts empty first when empty is in 2nd position" do
|
|
49
|
+
json_results = [{ label: "[#{term_b}]", sort: [term_b] },
|
|
50
|
+
{ label: "['_empty_2_']", sort: [""] },
|
|
51
|
+
{ label: "[#{term_a}]", sort: [term_a] }]
|
|
52
|
+
expected_results = [{ label: "['_empty_2_']" },
|
|
53
|
+
{ label: "[#{term_a}]" },
|
|
54
|
+
{ label: "[#{term_b}]" }]
|
|
55
|
+
expect(instance.send(:sort_search_results, json_results)).to eq expected_results
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "puts empty first when empty is in last position" do
|
|
59
|
+
json_results = [{ label: "[#{term_b}]", sort: [term_b] },
|
|
60
|
+
{ label: "[#{term_c}]", sort: [term_c] },
|
|
61
|
+
{ label: "['_empty_last_']", sort: [""] }]
|
|
62
|
+
expected_results = [{ label: "['_empty_last_']" },
|
|
63
|
+
{ label: "[#{term_b}]" },
|
|
64
|
+
{ label: "[#{term_c}]" }]
|
|
37
65
|
expect(instance.send(:sort_search_results, json_results)).to eq expected_results
|
|
38
66
|
end
|
|
39
67
|
end
|
|
40
68
|
end
|
|
41
69
|
|
|
42
|
-
context "
|
|
70
|
+
context "and sort term is single value" do
|
|
43
71
|
context "for all" do
|
|
44
72
|
it "sorts on the single value" do
|
|
45
|
-
json_results = [{ label: "[#{term_b}]", sort: [term_b] },
|
|
46
|
-
|
|
73
|
+
json_results = [{ label: "[#{term_b}]", sort: [term_b] },
|
|
74
|
+
{ label: "[#{term_c}]", sort: [term_c] },
|
|
75
|
+
{ label: "[#{term_a}]", sort: [term_a] }]
|
|
76
|
+
expected_results = [{ label: "[#{term_a}]" },
|
|
77
|
+
{ label: "[#{term_b}]" },
|
|
78
|
+
{ label: "[#{term_c}]" }]
|
|
47
79
|
expect(instance.send(:sort_search_results, json_results)).to eq expected_results
|
|
48
80
|
end
|
|
49
81
|
end
|
|
@@ -51,8 +83,12 @@ RSpec.describe Qa::Authorities::LinkedData::SearchQuery do
|
|
|
51
83
|
|
|
52
84
|
context "when first sort term is same" do
|
|
53
85
|
it "sorts on second sort term" do
|
|
54
|
-
json_results = [{ label: "[#{term_b}, #{term_c}]", sort: [term_b, term_c] },
|
|
55
|
-
|
|
86
|
+
json_results = [{ label: "[#{term_b}, #{term_c}]", sort: [term_b, term_c] },
|
|
87
|
+
{ label: "[#{term_b}, #{term_d}]", sort: [term_b, term_d] },
|
|
88
|
+
{ label: "[#{term_b}, #{term_a}]", sort: [term_b, term_a] }]
|
|
89
|
+
expected_results = [{ label: "[#{term_b}, #{term_a}]" },
|
|
90
|
+
{ label: "[#{term_b}, #{term_c}]" },
|
|
91
|
+
{ label: "[#{term_b}, #{term_d}]" }]
|
|
56
92
|
expect(instance.send(:sort_search_results, json_results)).to eq expected_results
|
|
57
93
|
end
|
|
58
94
|
end
|
|
@@ -60,20 +96,36 @@ RSpec.describe Qa::Authorities::LinkedData::SearchQuery do
|
|
|
60
96
|
context "when different number of sort terms" do
|
|
61
97
|
context "and initial terms match" do
|
|
62
98
|
it "puts shorter set of terms before longer set" do
|
|
63
|
-
json_results = [{ label: "[#{term_b}, #{term_c}]", sort: [term_b, term_c] },
|
|
64
|
-
|
|
99
|
+
json_results = [{ label: "[#{term_b}, #{term_c}]", sort: [term_b, term_c] },
|
|
100
|
+
{ label: "[#{term_b}]", sort: [term_b] },
|
|
101
|
+
{ label: "[#{term_b}, #{term_a}]", sort: [term_b, term_a] }]
|
|
102
|
+
expected_results = [{ label: "[#{term_b}]" },
|
|
103
|
+
{ label: "[#{term_b}, #{term_a}]" },
|
|
104
|
+
{ label: "[#{term_b}, #{term_c}]" }]
|
|
65
105
|
expect(instance.send(:sort_search_results, json_results)).to eq expected_results
|
|
66
106
|
end
|
|
67
107
|
end
|
|
68
108
|
|
|
69
109
|
context "and a difference happens before end of term sets" do
|
|
70
110
|
it "stops ordering as soon as a difference is found" do
|
|
71
|
-
json_results = [{ label: "[#{term_b}, #{term_d}, #{term_c}]", sort: [term_b, term_d, term_c] },
|
|
72
|
-
|
|
111
|
+
json_results = [{ label: "[#{term_b}, #{term_d}, #{term_c}]", sort: [term_b, term_d, term_c] },
|
|
112
|
+
{ label: "[#{term_a}, #{term_c}]", sort: [term_a, term_c] },
|
|
113
|
+
{ label: "[#{term_b}, #{term_d}, #{term_a}]", sort: [term_b, term_d, term_a] }]
|
|
114
|
+
expected_results = [{ label: "[#{term_a}, #{term_c}]" },
|
|
115
|
+
{ label: "[#{term_b}, #{term_d}, #{term_a}]" },
|
|
116
|
+
{ label: "[#{term_b}, #{term_d}, #{term_c}]" }]
|
|
73
117
|
expect(instance.send(:sort_search_results, json_results)).to eq expected_results
|
|
74
118
|
end
|
|
75
119
|
end
|
|
76
120
|
end
|
|
121
|
+
|
|
122
|
+
context "and sort values are numeric" do
|
|
123
|
+
it "does numeric compare" do
|
|
124
|
+
json_results = [{ label: "['22']", sort: ["22"] }, { label: "['1']", sort: ["1"] }, { label: "['215']", sort: ["215"] }]
|
|
125
|
+
expected_results = [{ label: "['1']" }, { label: "['22']" }, { label: "['215']" }]
|
|
126
|
+
expect(instance.send(:sort_search_results, json_results)).to eq expected_results
|
|
127
|
+
end
|
|
128
|
+
end
|
|
77
129
|
end
|
|
78
130
|
end
|
|
79
131
|
end
|
|
@@ -4,6 +4,7 @@ describe Qa::Authorities::LinkedData::TermConfig do
|
|
|
4
4
|
let(:full_config) { Qa::Authorities::LinkedData::Config.new(:LOD_FULL_CONFIG).term }
|
|
5
5
|
let(:min_config) { Qa::Authorities::LinkedData::Config.new(:LOD_MIN_CONFIG).term }
|
|
6
6
|
let(:search_only_config) { Qa::Authorities::LinkedData::Config.new(:LOD_SEARCH_ONLY_CONFIG).term }
|
|
7
|
+
let(:encoding_config) { Qa::Authorities::LinkedData::Config.new(:LOD_ENCODING_CONFIG).term }
|
|
7
8
|
|
|
8
9
|
describe '#term_config' do
|
|
9
10
|
let(:full_term_config) do
|
|
@@ -369,32 +370,35 @@ describe Qa::Authorities::LinkedData::TermConfig do
|
|
|
369
370
|
end
|
|
370
371
|
end
|
|
371
372
|
|
|
373
|
+
# rubocop:disable RSpec/RepeatedExample
|
|
372
374
|
describe '#term_url_with_replacements' do
|
|
373
375
|
it 'returns nil if only search configuration is defined' do
|
|
374
376
|
expect(search_only_config.term_url_with_replacements('C123')).to eq nil
|
|
375
377
|
end
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
378
|
+
context 'when subauthorities ARE defined' do
|
|
379
|
+
it 'returns the url with query substitution applied' do
|
|
380
|
+
expected_url = 'http://localhost/test_default/term/term_sub2_name/C123?param1=alpha¶m2=beta'
|
|
381
|
+
expect(full_config.term_url_with_replacements('C123')).to eq expected_url
|
|
382
|
+
end
|
|
383
|
+
it 'returns the url with default subauthority when NOT specified' do
|
|
384
|
+
expected_url = 'http://localhost/test_default/term/term_sub2_name/C123?param1=alpha¶m2=beta'
|
|
385
|
+
expect(full_config.term_url_with_replacements('C123')).to eq expected_url
|
|
386
|
+
end
|
|
387
|
+
it 'returns the url with subauthority substitution when specified' do
|
|
388
|
+
expected_url = 'http://localhost/test_default/term/term_sub3_name/C123?param1=alpha¶m2=beta'
|
|
389
|
+
expect(full_config.term_url_with_replacements('C123', 'term_sub3_key')).to eq expected_url
|
|
390
|
+
end
|
|
391
|
+
it 'returns the url with default values when replacements are NOT specified' do
|
|
392
|
+
expected_url = 'http://localhost/test_default/term/term_sub2_name/C123?param1=alpha¶m2=beta'
|
|
393
|
+
expect(full_config.term_url_with_replacements('C123')).to eq expected_url
|
|
394
|
+
end
|
|
395
|
+
it 'returns the url with replacement substitution values when replacements are specified' do
|
|
396
|
+
expected_url = 'http://localhost/test_default/term/term_sub2_name/C123?param1=golf¶m2=hotel'
|
|
397
|
+
expect(full_config.term_url_with_replacements('C123', nil, param1: 'golf', param2: 'hotel')).to eq expected_url
|
|
398
|
+
end
|
|
395
399
|
end
|
|
396
400
|
|
|
397
|
-
context 'when subauthorities are
|
|
401
|
+
context 'when subauthorities are NOT defined' do
|
|
398
402
|
it 'returns the url with query substitution applied' do
|
|
399
403
|
expected_url = 'http://localhost/test_default/term/C123'
|
|
400
404
|
expect(min_config.term_url_with_replacements('C123')).to eq expected_url
|
|
@@ -415,5 +419,15 @@ describe Qa::Authorities::LinkedData::TermConfig do
|
|
|
415
419
|
expect(min_config.term_url_with_replacements('C123', nil, fake_replacement_key: 'fake_value')).to eq expected_url
|
|
416
420
|
end
|
|
417
421
|
end
|
|
422
|
+
|
|
423
|
+
context 'with encoding specified in config' do
|
|
424
|
+
it 'returns the uri as the url' do
|
|
425
|
+
expected_url = 'http://localhost/test_default/term?uri=http%3A%2F%2Fencoded%2Ebecause%3Fencode%3Dtrue&yes%3Aencoded%20here&no:encoding here&defaults:to not encoded'
|
|
426
|
+
term_uri = 'http://encoded.because?encode=true'
|
|
427
|
+
replacements = { encode_true: 'yes:encoded here', encode_false: 'no:encoding here', encode_not_specified: 'defaults:to not encoded' }
|
|
428
|
+
expect(encoding_config.term_url_with_replacements(term_uri, nil, replacements)).to eq expected_url
|
|
429
|
+
end
|
|
430
|
+
end
|
|
418
431
|
end
|
|
432
|
+
# rubocop:enable RSpec/RepeatedExample
|
|
419
433
|
end
|