qa 5.1.0 → 5.5.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 +99 -73
- data/app/services/qa/linked_data/graph_service.rb +1 -0
- data/app/services/qa/linked_data/request_header_service.rb +20 -1
- data/lib/generators/qa/install/templates/config/initializers/qa.rb +5 -0
- data/lib/qa/authorities/discogs/discogs_utils.rb +35 -0
- data/lib/qa/authorities/discogs/generic_authority.rb +33 -38
- data/lib/qa/authorities/geonames.rb +30 -4
- data/lib/qa/authorities/linked_data/find_term.rb +6 -4
- data/lib/qa/authorities/linked_data/search_query.rb +6 -4
- data/lib/qa/authorities/loc/generic_authority.rb +2 -2
- data/lib/qa/authorities/loc_subauthority.rb +4 -4
- data/lib/qa/configuration.rb +9 -0
- data/lib/qa/version.rb +1 -1
- data/spec/controllers/linked_data_terms_controller_spec.rb +15 -0
- data/spec/controllers/terms_controller_spec.rb +2 -2
- data/spec/fixtures/discogs-search-response-per-page.json +1 -0
- data/spec/fixtures/discogs-search-response-set-record.json +1 -0
- data/spec/lib/authorities/discogs/generic_authority_spec.rb +62 -4
- data/spec/lib/authorities/geonames_spec.rb +30 -2
- data/spec/lib/authorities/getty/aat_spec.rb +2 -2
- data/spec/lib/authorities/getty/tgn_spec.rb +2 -2
- data/spec/lib/authorities/loc_spec.rb +9 -9
- data/spec/lib/mesh_data_parser_spec.rb +2 -2
- data/spec/services/linked_data/request_header_service_spec.rb +49 -0
- metadata +60 -11
@@ -77,7 +77,7 @@ describe Qa::Authorities::Getty::AAT do
|
|
77
77
|
subject { authority.request_options }
|
78
78
|
it { is_expected.to eq(accept: "application/sparql-results+json") }
|
79
79
|
end
|
80
|
-
# rubocop:disable
|
80
|
+
# rubocop:disable Layout/LineLength
|
81
81
|
describe "#sparql" do
|
82
82
|
context "using a single subject term" do
|
83
83
|
subject { authority.sparql('search_term') }
|
@@ -92,5 +92,5 @@ describe Qa::Authorities::Getty::AAT do
|
|
92
92
|
}
|
93
93
|
end
|
94
94
|
end
|
95
|
-
# rubocop:enable
|
95
|
+
# rubocop:enable Layout/LineLength
|
96
96
|
end
|
@@ -77,7 +77,7 @@ describe Qa::Authorities::Getty::TGN do
|
|
77
77
|
subject { authority.request_options }
|
78
78
|
it { is_expected.to eq(accept: "application/sparql-results+json") }
|
79
79
|
end
|
80
|
-
# rubocop:disable
|
80
|
+
# rubocop:disable Layout/LineLength
|
81
81
|
describe "#sparql" do
|
82
82
|
context "using a single subject term" do
|
83
83
|
subject { authority.sparql('search_term') }
|
@@ -92,5 +92,5 @@ describe Qa::Authorities::Getty::TGN do
|
|
92
92
|
}
|
93
93
|
end
|
94
94
|
end
|
95
|
-
# rubocop:enable
|
95
|
+
# rubocop:enable Layout/LineLength
|
96
96
|
end
|
@@ -28,14 +28,14 @@ describe Qa::Authorities::Loc do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
context "for searching" do
|
31
|
-
let(:url) { '
|
31
|
+
let(:url) { 'https://id.loc.gov/search/?q=foo&q=cs%3Ahttps%3A%2F%2Fid.loc.gov%2Fauthorities%2Fsubjects&format=json' }
|
32
32
|
it "returns a url" do
|
33
33
|
expect(authority.build_query_url("foo")).to eq(url)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
context "for returning single terms" do
|
38
|
-
let(:url) { "
|
38
|
+
let(:url) { "https://id.loc.gov/authorities/subjects/sh2002003586.json" }
|
39
39
|
it "returns a url with an authority and id" do
|
40
40
|
expect(authority.find_url("sh2002003586")).to eq(url)
|
41
41
|
end
|
@@ -49,15 +49,15 @@ describe Qa::Authorities::Loc do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
before do
|
52
|
-
stub_request(:get, "
|
52
|
+
stub_request(:get, "https://id.loc.gov/search/?format=json&q=cs:https://id.loc.gov/authorities/subjects")
|
53
53
|
.with(headers: { 'Accept' => 'application/json' })
|
54
54
|
.to_return(status: 200, body: "")
|
55
55
|
end
|
56
56
|
|
57
57
|
context "with flat params encoded" do
|
58
|
-
let(:url) { '
|
58
|
+
let(:url) { 'https://id.loc.gov/search/?q=foo&q=cs%3Ahttps%3A%2F%2Fid.loc.gov%2Fauthorities%2Fsubjects&format=json' }
|
59
59
|
it "returns a response" do
|
60
|
-
flat_params_url = "
|
60
|
+
flat_params_url = "https://id.loc.gov/search/?format=json&q=foo&q=cs%3Ahttps%3A%2F%2Fid.loc.gov%2Fauthorities%2Fsubjects"
|
61
61
|
expect(subject.env.url.to_s).to eq(flat_params_url)
|
62
62
|
end
|
63
63
|
end
|
@@ -66,7 +66,7 @@ describe Qa::Authorities::Loc do
|
|
66
66
|
describe "#search" do
|
67
67
|
context "any LOC authorities" do
|
68
68
|
let :authority do
|
69
|
-
stub_request(:get, "
|
69
|
+
stub_request(:get, "https://id.loc.gov/search/?format=json&q=s&q=cs:https://id.loc.gov/vocabulary/geographicAreas")
|
70
70
|
.with(headers: { 'Accept' => 'application/json' })
|
71
71
|
.to_return(body: webmock_fixture("loc-response.txt"), status: 200)
|
72
72
|
described_class.subauthority_for("geographicAreas")
|
@@ -95,7 +95,7 @@ describe Qa::Authorities::Loc do
|
|
95
95
|
|
96
96
|
context "subject terms" do
|
97
97
|
let :results do
|
98
|
-
stub_request(:get, "
|
98
|
+
stub_request(:get, "https://id.loc.gov/search/?format=json&q=History--&q=cs:https://id.loc.gov/authorities/subjects")
|
99
99
|
.with(headers: { 'Accept' => 'application/json' })
|
100
100
|
.to_return(body: webmock_fixture("loc-subjects-response.txt"), status: 200)
|
101
101
|
described_class.subauthority_for("subjects").search("History--")
|
@@ -111,7 +111,7 @@ describe Qa::Authorities::Loc do
|
|
111
111
|
|
112
112
|
context "name terms" do
|
113
113
|
let :results do
|
114
|
-
stub_request(:get, "
|
114
|
+
stub_request(:get, "https://id.loc.gov/search/?format=json&q=Berry&q=cs:https://id.loc.gov/authorities/names")
|
115
115
|
.with(headers: { 'Accept' => 'application/json' })
|
116
116
|
.to_return(body: webmock_fixture("loc-names-response.txt"), status: 200)
|
117
117
|
described_class.subauthority_for("names").search("Berry")
|
@@ -125,7 +125,7 @@ describe Qa::Authorities::Loc do
|
|
125
125
|
describe "#find" do
|
126
126
|
context "using a subject id" do
|
127
127
|
let :results do
|
128
|
-
stub_request(:get, "
|
128
|
+
stub_request(:get, "https://id.loc.gov/authorities/subjects/sh2002003586.json")
|
129
129
|
.with(headers: { 'Accept' => 'application/json' })
|
130
130
|
.to_return(status: 200, body: webmock_fixture("loc-subject-find-response.txt"), headers: {})
|
131
131
|
described_class.subauthority_for("subjects").find("sh2002003586")
|
@@ -47,7 +47,7 @@ EOS
|
|
47
47
|
expect(records[1]).to eq({})
|
48
48
|
end
|
49
49
|
|
50
|
-
# rubocop:disable
|
50
|
+
# rubocop:disable Layout/LineLength
|
51
51
|
it 'parses a sample mesh file' do
|
52
52
|
mesh = described_class.new(webmock_fixture('mesh.txt'))
|
53
53
|
records = mesh.all_records
|
@@ -117,5 +117,5 @@ EOS
|
|
117
117
|
"DX" => ["19840101"],
|
118
118
|
"UI" => ["D000001"])
|
119
119
|
end
|
120
|
-
# rubocop:enable
|
120
|
+
# rubocop:enable Layout/LineLength
|
121
121
|
end
|
@@ -2,8 +2,44 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
RSpec.describe Qa::LinkedData::RequestHeaderService do
|
4
4
|
let(:request) { double }
|
5
|
+
let(:request_id) { 'anID' }
|
6
|
+
let(:some_params) { double }
|
7
|
+
let(:location) { double }
|
8
|
+
let(:fake_ip) { '111.22.33.4444' }
|
9
|
+
let(:city) { 'Ithaca' }
|
10
|
+
let(:state) { 'New York' }
|
11
|
+
let(:country) { 'US' }
|
12
|
+
before do
|
13
|
+
allow(request).to receive(:request_id).and_return(request_id)
|
14
|
+
allow(request).to receive_message_chain(:path_parameters, :[]).with(:action).and_return('search') # rubocop:disable RSpec/MessageChain
|
15
|
+
allow(request).to receive(:location).and_return(location)
|
16
|
+
allow(request).to receive(:ip).and_return(fake_ip)
|
17
|
+
allow(location).to receive(:city).and_return(city)
|
18
|
+
allow(location).to receive(:state).and_return(state)
|
19
|
+
allow(location).to receive(:country).and_return(country)
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#initialize' do
|
23
|
+
context 'when Qa.config.suppress_ip_data_from_log is true' do
|
24
|
+
before { allow(Qa).to receive_message_chain(:config, :suppress_ip_data_from_log).and_return(true) } # rubocop:disable RSpec/MessageChain
|
25
|
+
it 'does not include IP info in log message' do
|
26
|
+
expect(Rails.logger).to receive(:info).with("******** SEARCH")
|
27
|
+
described_class.new(request: request, params: some_params)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'when Qa.config.suppress_ip_data_from_log is false' do
|
32
|
+
before { allow(Qa).to receive_message_chain(:config, :suppress_ip_data_from_log).and_return(false) } # rubocop:disable RSpec/MessageChain
|
33
|
+
it 'does include IP info in log message' do
|
34
|
+
expect(Rails.logger).to receive(:info).with("******** SEARCH from IP #{fake_ip} in {city: #{city}, state: #{state}, country: #{country}}")
|
35
|
+
described_class.new(request: request, params: some_params)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
5
39
|
|
6
40
|
describe '#search_header' do
|
41
|
+
let(:request_id) { 's1' }
|
42
|
+
|
7
43
|
context 'when optional params are defined' do
|
8
44
|
let(:search_params) do
|
9
45
|
{
|
@@ -20,6 +56,8 @@ RSpec.describe Qa::LinkedData::RequestHeaderService do
|
|
20
56
|
it 'uses passed in params' do
|
21
57
|
expected_results =
|
22
58
|
{
|
59
|
+
request: request,
|
60
|
+
request_id: request_id,
|
23
61
|
context: true,
|
24
62
|
performance_data: true,
|
25
63
|
replacements: { 'maxRecords' => '4' },
|
@@ -37,6 +75,8 @@ RSpec.describe Qa::LinkedData::RequestHeaderService do
|
|
37
75
|
it 'returns defaults' do
|
38
76
|
expected_results =
|
39
77
|
{
|
78
|
+
request: request,
|
79
|
+
request_id: request_id,
|
40
80
|
context: false,
|
41
81
|
performance_data: false,
|
42
82
|
replacements: {},
|
@@ -53,6 +93,8 @@ RSpec.describe Qa::LinkedData::RequestHeaderService do
|
|
53
93
|
it 'returns defaults with language set to request language' do
|
54
94
|
expected_results =
|
55
95
|
{
|
96
|
+
request: request,
|
97
|
+
request_id: request_id,
|
56
98
|
context: false,
|
57
99
|
performance_data: false,
|
58
100
|
replacements: {},
|
@@ -67,6 +109,7 @@ RSpec.describe Qa::LinkedData::RequestHeaderService do
|
|
67
109
|
end
|
68
110
|
|
69
111
|
describe '#fetch_header' do
|
112
|
+
let(:request_id) { 'f1' }
|
70
113
|
context 'when optional params are defined' do
|
71
114
|
let(:fetch_params) do
|
72
115
|
{
|
@@ -84,6 +127,8 @@ RSpec.describe Qa::LinkedData::RequestHeaderService do
|
|
84
127
|
it 'uses passed in params' do
|
85
128
|
expected_results =
|
86
129
|
{
|
130
|
+
request: request,
|
131
|
+
request_id: request_id,
|
87
132
|
format: 'n3',
|
88
133
|
performance_data: true,
|
89
134
|
replacements: { 'extra' => 'data', 'even' => 'more data' },
|
@@ -101,6 +146,8 @@ RSpec.describe Qa::LinkedData::RequestHeaderService do
|
|
101
146
|
it 'returns defaults' do
|
102
147
|
expected_results =
|
103
148
|
{
|
149
|
+
request: request,
|
150
|
+
request_id: request_id,
|
104
151
|
format: 'json',
|
105
152
|
performance_data: false,
|
106
153
|
replacements: {},
|
@@ -117,6 +164,8 @@ RSpec.describe Qa::LinkedData::RequestHeaderService do
|
|
117
164
|
it 'returns defaults with language set to request language' do
|
118
165
|
expected_results =
|
119
166
|
{
|
167
|
+
request: request,
|
168
|
+
request_id: request_id,
|
120
169
|
format: 'json',
|
121
170
|
performance_data: false,
|
122
171
|
replacements: {},
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Anderson
|
@@ -13,10 +13,10 @@ authors:
|
|
13
13
|
- Mike Stroming
|
14
14
|
- Adam Wead
|
15
15
|
- E. Lynette Rayle
|
16
|
-
autorequire:
|
16
|
+
autorequire:
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
|
-
date:
|
19
|
+
date: 2020-08-13 00:00:00.000000000 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: activerecord-import
|
@@ -60,6 +60,20 @@ dependencies:
|
|
60
60
|
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: geocoder
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
63
77
|
- !ruby/object:Gem::Dependency
|
64
78
|
name: ldpath
|
65
79
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,16 +106,22 @@ dependencies:
|
|
92
106
|
name: rails
|
93
107
|
requirement: !ruby/object:Gem::Requirement
|
94
108
|
requirements:
|
95
|
-
- - "
|
109
|
+
- - ">="
|
96
110
|
- !ruby/object:Gem::Version
|
97
111
|
version: '5.0'
|
112
|
+
- - "<"
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '6.1'
|
98
115
|
type: :runtime
|
99
116
|
prerelease: false
|
100
117
|
version_requirements: !ruby/object:Gem::Requirement
|
101
118
|
requirements:
|
102
|
-
- - "
|
119
|
+
- - ">="
|
103
120
|
- !ruby/object:Gem::Version
|
104
121
|
version: '5.0'
|
122
|
+
- - "<"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '6.1'
|
105
125
|
- !ruby/object:Gem::Dependency
|
106
126
|
name: rdf
|
107
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,14 +142,40 @@ dependencies:
|
|
122
142
|
requirements:
|
123
143
|
- - "~>"
|
124
144
|
- !ruby/object:Gem::Version
|
125
|
-
version:
|
145
|
+
version: 3.0.0
|
126
146
|
type: :development
|
127
147
|
prerelease: false
|
128
148
|
version_requirements: !ruby/object:Gem::Requirement
|
129
149
|
requirements:
|
130
150
|
- - "~>"
|
131
151
|
- !ruby/object:Gem::Version
|
132
|
-
version:
|
152
|
+
version: 3.0.0
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rails
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "!="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 5.2.0
|
160
|
+
- - "!="
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: 5.2.1
|
163
|
+
- - "!="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: 5.2.2
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - "!="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: 5.2.0
|
173
|
+
- - "!="
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
version: 5.2.1
|
176
|
+
- - "!="
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: 5.2.2
|
133
179
|
- !ruby/object:Gem::Dependency
|
134
180
|
name: byebug
|
135
181
|
requirement: !ruby/object:Gem::Requirement
|
@@ -455,6 +501,8 @@ files:
|
|
455
501
|
- spec/fixtures/discogs-id-not-found-release.json
|
456
502
|
- spec/fixtures/discogs-search-response-no-auth.json
|
457
503
|
- spec/fixtures/discogs-search-response-no-subauth.json
|
504
|
+
- spec/fixtures/discogs-search-response-per-page.json
|
505
|
+
- spec/fixtures/discogs-search-response-set-record.json
|
458
506
|
- spec/fixtures/discogs-search-response-subauth.json
|
459
507
|
- spec/fixtures/funders-find-response.json
|
460
508
|
- spec/fixtures/funders-noquery.json
|
@@ -569,7 +617,7 @@ homepage: https://github.com/projecthydra/questioning_authority
|
|
569
617
|
licenses:
|
570
618
|
- APACHE-2
|
571
619
|
metadata: {}
|
572
|
-
post_install_message:
|
620
|
+
post_install_message:
|
573
621
|
rdoc_options: []
|
574
622
|
require_paths:
|
575
623
|
- lib
|
@@ -584,9 +632,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
584
632
|
- !ruby/object:Gem::Version
|
585
633
|
version: '0'
|
586
634
|
requirements: []
|
587
|
-
|
588
|
-
|
589
|
-
signing_key:
|
635
|
+
rubygems_version: 3.0.8
|
636
|
+
signing_key:
|
590
637
|
specification_version: 4
|
591
638
|
summary: You should question your authorities.
|
592
639
|
test_files:
|
@@ -633,6 +680,7 @@ test_files:
|
|
633
680
|
- spec/lib/services/rdf_authority_parser_spec.rb
|
634
681
|
- spec/fixtures/lod_lang_search_enesfrde.rdf.xml
|
635
682
|
- spec/fixtures/oclcts-response-mesh-3.txt
|
683
|
+
- spec/fixtures/discogs-search-response-set-record.json
|
636
684
|
- spec/fixtures/loc-names-response.txt
|
637
685
|
- spec/fixtures/oclcts-response-mesh-2.txt
|
638
686
|
- spec/fixtures/lod_loc_term_bad_id.rdf.xml
|
@@ -653,6 +701,7 @@ test_files:
|
|
653
701
|
- spec/fixtures/getty-aat-find-response.json
|
654
702
|
- spec/fixtures/lod_lang_term_enfr_noalt.rdf.xml
|
655
703
|
- spec/fixtures/assign-fast-noresults.json
|
704
|
+
- spec/fixtures/discogs-search-response-per-page.json
|
656
705
|
- spec/fixtures/getty-error-response.txt
|
657
706
|
- spec/fixtures/lod_loc_term_found.rdf.xml
|
658
707
|
- spec/fixtures/lod_lang_term_enfr.rdf.xml
|