qa 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/app/controllers/qa/linked_data_terms_controller.rb +18 -10
- data/config/authorities/linked_data/agrovoc.json +2 -2
- data/lib/qa.rb +4 -1
- data/lib/qa/authorities/linked_data/rdf_helper.rb +3 -4
- data/lib/qa/authorities/local/file_based_authority.rb +1 -1
- data/lib/qa/version.rb +1 -1
- data/spec/controllers/linked_data_terms_controller_spec.rb +123 -29
- data/spec/lib/authorities/file_based_authority_spec.rb +9 -9
- data/spec/lib/authorities/linked_data/generic_authority_spec.rb +3 -3
- data/spec/test_app_templates/Gemfile.extra +5 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd95864495b3db88e02bf7a8261cfc53387c8db2
|
4
|
+
data.tar.gz: a5c462c41d39c58650be960dee85708952ad1cf5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7769289d6084b3211ae2dbf68a2b0978baed528e61c7e9fd288016bdee6d5915e315d8637ac7f38ed9eab90308f926afa5d569c1615d014f8d3bb898fe390730
|
7
|
+
data.tar.gz: 8694569bddcaccf386e6c2ae1b14cd6ca63703f945034533bbc1a4d7a48c60729790d428998cb257f174254ac8f0956f8b13af52136c7d0dd5ead5c52cb27d65
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Questioning Authority
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/
|
4
|
-
[![Coverage Status](https://coveralls.io/repos/github/
|
3
|
+
[![Build Status](https://travis-ci.org/samvera/questioning_authority.png?branch=master)](https://travis-ci.org/samvera/questioning_authority) [![Gem Version](https://badge.fury.io/rb/qa.png)](http://badge.fury.io/rb/qa)
|
4
|
+
[![Coverage Status](https://coveralls.io/repos/github/samvera/questioning_authority/badge.svg?branch=master)](https://coveralls.io/github/samvera/questioning_authority?branch=master)
|
5
5
|
|
6
6
|
You should question your authorities.
|
7
7
|
|
@@ -387,7 +387,7 @@ gem 'rdf-rdfxml'
|
|
387
387
|
|
388
388
|
Access to LOD authorities can be configured. Currently, a configuration exists in QA for OCLC Fast Linked Data, Library of
|
389
389
|
Congress (terms only), and Agrovoc. Look for configuration files in
|
390
|
-
[/config/authorities/linked_data](https://github.com/
|
390
|
+
[/config/authorities/linked_data](https://github.com/samvera/questioning_authority/tree/master/config/authorities/linked_data).
|
391
391
|
|
392
392
|
Example configuration...
|
393
393
|
|
@@ -611,7 +611,7 @@ NOTE: All predicates with the URI as the subject will be included under "predica
|
|
611
611
|
|
612
612
|
#### Add javascript to support autocomplete
|
613
613
|
|
614
|
-
See [Using with autocomplete in Sufia](https://github.com/
|
614
|
+
See [Using with autocomplete in Sufia](https://github.com/samvera/questioning_authority/wiki/Using-with-autocomplete-in-Sufia) in the wiki documentation for QA.
|
615
615
|
|
616
616
|
|
617
617
|
|
@@ -19,11 +19,15 @@ class Qa::LinkedDataTermsController < ApplicationController
|
|
19
19
|
terms = @authority.search(query, subauth: subauthority, language: language, replacements: replacement_params)
|
20
20
|
rescue Qa::ServiceUnavailable
|
21
21
|
logger.warn "Service Unavailable - Search query #{query} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}"
|
22
|
-
head :
|
22
|
+
head :service_unavailable
|
23
|
+
return
|
24
|
+
rescue Qa::ServiceError
|
25
|
+
logger.warn "Internal Server Error - Search query #{query} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}"
|
26
|
+
head :internal_server_error
|
23
27
|
return
|
24
28
|
rescue RDF::FormatError
|
25
29
|
logger.warn "RDF Format Error - Results from search query #{query} for#{subauth_warn_msg} authority #{vocab_param} was not identified as a valid RDF format. You may need to include the linkeddata gem."
|
26
|
-
head :
|
30
|
+
head :internal_server_error
|
27
31
|
return
|
28
32
|
end
|
29
33
|
render json: terms
|
@@ -40,11 +44,15 @@ class Qa::LinkedDataTermsController < ApplicationController
|
|
40
44
|
return
|
41
45
|
rescue Qa::ServiceUnavailable
|
42
46
|
logger.warn "Service Unavailable - Fetch term #{id} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}"
|
43
|
-
head :
|
47
|
+
head :service_unavailable
|
48
|
+
return
|
49
|
+
rescue Qa::ServiceError
|
50
|
+
logger.warn "Internal Server Error - Fetch term #{id} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}"
|
51
|
+
head :internal_server_error
|
44
52
|
return
|
45
53
|
rescue RDF::FormatError
|
46
54
|
logger.warn "RDF Format Error - Results from fetch term #{id} for#{subauth_warn_msg} authority #{vocab_param} was not identified as a valid RDF format. You may need to include the linkeddata gem."
|
47
|
-
head :
|
55
|
+
head :internal_server_error
|
48
56
|
return
|
49
57
|
end
|
50
58
|
render json: term
|
@@ -55,7 +63,7 @@ class Qa::LinkedDataTermsController < ApplicationController
|
|
55
63
|
def check_authority
|
56
64
|
if params[:vocab].nil? || !params[:vocab].size.positive?
|
57
65
|
logger.warn "Required param 'vocab' is missing or empty"
|
58
|
-
head :
|
66
|
+
head :bad_request
|
59
67
|
end
|
60
68
|
end
|
61
69
|
|
@@ -63,7 +71,7 @@ class Qa::LinkedDataTermsController < ApplicationController
|
|
63
71
|
return if subauthority.nil?
|
64
72
|
unless @authority.search_subauthority?(subauthority)
|
65
73
|
logger.warn "Unable to initialize linked data search sub-authority '#{subauthority}' for authority '#{vocab_param}'"
|
66
|
-
head :
|
74
|
+
head :bad_request
|
67
75
|
end
|
68
76
|
end
|
69
77
|
|
@@ -71,7 +79,7 @@ class Qa::LinkedDataTermsController < ApplicationController
|
|
71
79
|
return if subauthority.nil?
|
72
80
|
unless @authority.term_subauthority?(subauthority)
|
73
81
|
logger.warn "Unable to initialize linked data term sub-authority '#{subauthority}' for authority '#{vocab_param}'"
|
74
|
-
head :
|
82
|
+
head :bad_request
|
75
83
|
end
|
76
84
|
end
|
77
85
|
|
@@ -79,7 +87,7 @@ class Qa::LinkedDataTermsController < ApplicationController
|
|
79
87
|
@authority = Qa::Authorities::LinkedData::GenericAuthority.new(vocab_param)
|
80
88
|
rescue Qa::InvalidLinkedDataAuthority => e
|
81
89
|
logger.warn e.message
|
82
|
-
head :
|
90
|
+
head :bad_request
|
83
91
|
end
|
84
92
|
|
85
93
|
def vocab_param
|
@@ -89,7 +97,7 @@ class Qa::LinkedDataTermsController < ApplicationController
|
|
89
97
|
def check_query_param
|
90
98
|
if params[:q].nil? || !params[:q].size.positive?
|
91
99
|
logger.warn "Required search param 'q' is missing or empty"
|
92
|
-
head :
|
100
|
+
head :bad_request
|
93
101
|
end
|
94
102
|
end
|
95
103
|
|
@@ -101,7 +109,7 @@ class Qa::LinkedDataTermsController < ApplicationController
|
|
101
109
|
def check_id_param
|
102
110
|
if params[:id].nil? || !params[:id].size.positive?
|
103
111
|
logger.warn "Required show param 'id' is missing or empty"
|
104
|
-
head :
|
112
|
+
head :bad_request
|
105
113
|
end
|
106
114
|
end
|
107
115
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
"url": {
|
4
4
|
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
|
5
5
|
"@type": "IriTemplate",
|
6
|
-
"template": "http://
|
6
|
+
"template": "http://artemide.art.uniroma2.it:8081/agrovoc/rest/v1/data?uri=http://aims.fao.org/aos/agrovoc/{?term_id}",
|
7
7
|
"variableRepresentation": "BasicRepresentation",
|
8
8
|
"mapping": [
|
9
9
|
{
|
@@ -31,7 +31,7 @@
|
|
31
31
|
"url": {
|
32
32
|
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
|
33
33
|
"@type": "IriTemplate",
|
34
|
-
"template": "http://
|
34
|
+
"template": "http://artemide.art.uniroma2.it:8081/agrovoc/rest/v1/search/?query=*{?query}*&lang={?lang}",
|
35
35
|
"variableRepresentation": "BasicRepresentation",
|
36
36
|
"mapping": [
|
37
37
|
{
|
data/lib/qa.rb
CHANGED
@@ -26,9 +26,12 @@ module Qa
|
|
26
26
|
# Raised when a configuration parameter is incorrect or is required and missing
|
27
27
|
class InvalidConfiguration < ArgumentError; end
|
28
28
|
|
29
|
-
# Raised when a linked data request to a server returns a
|
29
|
+
# Raised when a linked data request to a server returns a 503 error
|
30
30
|
class ServiceUnavailable < ArgumentError; end
|
31
31
|
|
32
|
+
# Raised when a linked data request to a server returns a 500 error
|
33
|
+
class ServiceError < ArgumentError; end
|
34
|
+
|
32
35
|
# Raised when the server returns 404 for a find term request
|
33
36
|
class TermNotFound < ArgumentError; end
|
34
37
|
end
|
@@ -35,18 +35,17 @@ module Qa::Authorities
|
|
35
35
|
|
36
36
|
def process_error(e, url)
|
37
37
|
uri = URI(url)
|
38
|
+
raise RDF::FormatError, "Unknown RDF format of results returned by #{uri}. (RDF::FormatError) You may need to include gem 'linkeddata'." if e.is_a? RDF::FormatError
|
38
39
|
response_code = ioerror_code(e)
|
39
40
|
case response_code
|
40
|
-
when 'format'
|
41
|
-
raise RDF::FormatError, "Unknown RDF format of results returned by #{uri}. (RDF::FormatError) You may need to include gem 'linkeddata'."
|
42
41
|
when '404'
|
43
42
|
raise Qa::TermNotFound, "#{uri} Not Found - Term may not exist at LOD Authority. (HTTPNotFound - 404)"
|
44
43
|
when '500'
|
45
|
-
raise Qa::
|
44
|
+
raise Qa::ServiceError, "#{uri.hostname} on port #{uri.port} is not responding. Try again later. (HTTPServerError - 500)"
|
46
45
|
when '503'
|
47
46
|
raise Qa::ServiceUnavailable, "#{uri.hostname} on port #{uri.port} is not responding. Try again later. (HTTPServiceUnavailable - 503)"
|
48
47
|
else
|
49
|
-
raise Qa::
|
48
|
+
raise Qa::ServiceError, "Unknown error for #{uri.hostname} on port #{uri.port}. Try again later. (Cause - #{e.message})"
|
50
49
|
end
|
51
50
|
end
|
52
51
|
|
data/lib/qa/version.rb
CHANGED
@@ -6,72 +6,122 @@ describe Qa::LinkedDataTermsController, type: :controller do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
describe '#check_authority' do
|
9
|
-
it 'returns
|
9
|
+
it 'returns 400 if the vocabulary is not specified' do
|
10
10
|
expect(Rails.logger).to receive(:warn).with("Required param 'vocab' is missing or empty")
|
11
11
|
get :search, params: { q: 'a query', vocab: '' }
|
12
|
-
expect(response.code).to eq('
|
12
|
+
expect(response.code).to eq('400')
|
13
13
|
end
|
14
14
|
|
15
|
-
it 'returns
|
15
|
+
it 'returns 400 if the vocabulary is not specified' do
|
16
16
|
expect(Rails.logger).to receive(:warn).with("Required param 'vocab' is missing or empty")
|
17
17
|
get :show, params: { id: 'C_1234', vocab: '' }
|
18
|
-
expect(response.code).to eq('
|
18
|
+
expect(response.code).to eq('400')
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
describe '#check_search_subauthority' do
|
23
|
-
it 'returns
|
23
|
+
it 'returns 400 if the query subauthority is missing' do
|
24
24
|
expect(Rails.logger).to receive(:warn).with("Unable to initialize linked data search sub-authority '' for authority 'OCLC_FAST'")
|
25
25
|
get :search, params: { q: 'test', vocab: 'OCLC_FAST', subauthority: '' }
|
26
|
-
expect(response.code).to eq('
|
26
|
+
expect(response.code).to eq('400')
|
27
27
|
end
|
28
|
-
it 'returns
|
28
|
+
it 'returns 400 if the query subauthority is invalid' do
|
29
29
|
expect(Rails.logger).to receive(:warn).with("Unable to initialize linked data search sub-authority 'FAKE_SUBAUTHORITY' for authority 'OCLC_FAST'")
|
30
30
|
get :search, params: { vocab: 'OCLC_FAST', subauthority: 'FAKE_SUBAUTHORITY' }
|
31
|
-
expect(response.code).to eq('
|
31
|
+
expect(response.code).to eq('400')
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
describe '#check_show_subauthority' do
|
36
|
-
it 'returns
|
36
|
+
it 'returns 400 if the show subauthority is missing' do
|
37
37
|
expect(Rails.logger).to receive(:warn).with("Unable to initialize linked data term sub-authority '' for authority 'OCLC_FAST'")
|
38
38
|
get :show, params: { id: 'C_123', vocab: 'OCLC_FAST', subauthority: '' }
|
39
|
-
expect(response.code).to eq('
|
39
|
+
expect(response.code).to eq('400')
|
40
40
|
end
|
41
|
-
it 'returns
|
41
|
+
it 'returns 400 if the show subauthority is invalid' do
|
42
42
|
expect(Rails.logger).to receive(:warn).with("Unable to initialize linked data term sub-authority 'FAKE_SUBAUTHORITY' for authority 'OCLC_FAST'")
|
43
43
|
get :show, params: { id: 'C_123', vocab: 'OCLC_FAST', subauthority: 'FAKE_SUBAUTHORITY' }
|
44
|
-
expect(response.code).to eq('
|
44
|
+
expect(response.code).to eq('400')
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
describe '#check_query_param' do
|
49
|
-
it 'returns
|
49
|
+
it 'returns 400 if the query is missing' do
|
50
50
|
expect(Rails.logger).to receive(:warn).with("Required search param 'q' is missing or empty")
|
51
51
|
get :search, params: { vocab: 'OCLC_FAST' }
|
52
|
-
expect(response.code).to eq('
|
52
|
+
expect(response.code).to eq('400')
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
describe '#check_id_param' do
|
57
|
-
it 'returns
|
57
|
+
it 'returns 400 if the id is missing' do
|
58
58
|
expect(Rails.logger).to receive(:warn).with("Required show param 'id' is missing or empty")
|
59
59
|
get :show, params: { id: '', vocab: 'OCLC_FAST' }
|
60
|
-
expect(response.code).to eq('
|
60
|
+
expect(response.code).to eq('400')
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
64
|
describe '#init_authority' do
|
65
65
|
context 'when the authority does not exist' do
|
66
|
-
it 'returns
|
66
|
+
it 'returns 400' do
|
67
67
|
expect(Rails.logger).to receive(:warn).with("Unable to initialize linked data authority 'FAKE_AUTHORITY'")
|
68
68
|
get :search, params: { q: 'a query', vocab: 'fake_authority' }
|
69
|
-
expect(response.code).to eq('
|
69
|
+
expect(response.code).to eq('400')
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
74
|
describe '#search' do
|
75
|
+
context 'producing internal server error' do
|
76
|
+
context 'when server returns 500' do
|
77
|
+
before do
|
78
|
+
stub_request(:get, 'http://experimental.worldcat.org/fast/search?maximumRecords=3&query=cql.any%20all%20%22my_query%22&sortKeys=usage')
|
79
|
+
.to_return(status: 500)
|
80
|
+
end
|
81
|
+
it 'returns 500' do
|
82
|
+
expect(Rails.logger).to receive(:warn).with("Internal Server Error - Search query my_query unsuccessful for authority OCLC_FAST")
|
83
|
+
get :search, params: { q: 'my_query', vocab: 'OCLC_FAST', maximumRecords: '3' }
|
84
|
+
expect(response.code).to eq('500')
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'when rdf format error' do
|
89
|
+
before do
|
90
|
+
stub_request(:get, 'http://experimental.worldcat.org/fast/search?maximumRecords=3&query=cql.any%20all%20%22my_query%22&sortKeys=usage')
|
91
|
+
.to_return(status: 200)
|
92
|
+
allow(RDF::Graph).to receive(:load).and_raise(RDF::FormatError)
|
93
|
+
end
|
94
|
+
it 'returns 500' do
|
95
|
+
expect(Rails.logger).to receive(:warn).with("RDF Format Error - Results from search query my_query for authority OCLC_FAST was not identified as a valid RDF format. You may need to include the linkeddata gem.")
|
96
|
+
get :search, params: { q: 'my_query', vocab: 'OCLC_FAST', maximumRecords: '3' }
|
97
|
+
expect(response.code).to eq('500')
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
context "when error isn't specifically handled" do
|
102
|
+
before do
|
103
|
+
stub_request(:get, 'http://experimental.worldcat.org/fast/search?maximumRecords=3&query=cql.any%20all%20%22my_query%22&sortKeys=usage')
|
104
|
+
.to_return(status: 501)
|
105
|
+
end
|
106
|
+
it 'returns 500' do
|
107
|
+
expect(Rails.logger).to receive(:warn).with("Internal Server Error - Search query my_query unsuccessful for authority OCLC_FAST")
|
108
|
+
get :search, params: { q: 'my_query', vocab: 'OCLC_FAST', maximumRecords: '3' }
|
109
|
+
expect(response.code).to eq('500')
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
context 'when service unavailable' do
|
115
|
+
before do
|
116
|
+
stub_request(:get, 'http://experimental.worldcat.org/fast/search?maximumRecords=3&query=cql.any%20all%20%22my_query%22&sortKeys=usage')
|
117
|
+
.to_return(status: 503)
|
118
|
+
end
|
119
|
+
it 'returns 503' do
|
120
|
+
expect(Rails.logger).to receive(:warn).with("Service Unavailable - Search query my_query unsuccessful for authority OCLC_FAST")
|
121
|
+
get :search, params: { q: 'my_query', vocab: 'OCLC_FAST', maximumRecords: '3' }
|
122
|
+
expect(response.code).to eq('503')
|
123
|
+
end
|
124
|
+
end
|
75
125
|
context 'in OCLC_FAST authority' do
|
76
126
|
context '0 search results' do
|
77
127
|
before do
|
@@ -123,7 +173,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
|
|
123
173
|
context 'in AGROVOC authority' do
|
124
174
|
context '0 search results' do
|
125
175
|
before do
|
126
|
-
stub_request(:get, 'http://
|
176
|
+
stub_request(:get, 'http://artemide.art.uniroma2.it:8081/agrovoc/rest/v1/search/?lang=en&query=*supercalifragilisticexpialidocious*')
|
127
177
|
.to_return(status: 200, body: webmock_fixture('lod_agrovoc_query_no_results.json'), headers: { 'Content-Type' => 'application/json' })
|
128
178
|
end
|
129
179
|
it 'succeeds' do
|
@@ -134,7 +184,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
|
|
134
184
|
|
135
185
|
context '3 search results' do
|
136
186
|
before do
|
137
|
-
stub_request(:get, 'http://
|
187
|
+
stub_request(:get, 'http://artemide.art.uniroma2.it:8081/agrovoc/rest/v1/search/?lang=en&query=*milk*')
|
138
188
|
.to_return(status: 200, body: webmock_fixture('lod_agrovoc_query_many_results.json'), headers: { 'Content-Type' => 'application/json' })
|
139
189
|
end
|
140
190
|
it 'succeeds' do
|
@@ -146,20 +196,64 @@ describe Qa::LinkedDataTermsController, type: :controller do
|
|
146
196
|
end
|
147
197
|
|
148
198
|
describe '#show' do
|
149
|
-
context '
|
150
|
-
context '
|
199
|
+
context 'producing internal server error' do
|
200
|
+
context 'when server returns 500' do
|
201
|
+
before do
|
202
|
+
stub_request(:get, 'http://id.worldcat.org/fast/530369').to_return(status: 500)
|
203
|
+
end
|
204
|
+
it 'returns 500' do
|
205
|
+
expect(Rails.logger).to receive(:warn).with("Internal Server Error - Fetch term 530369 unsuccessful for authority OCLC_FAST")
|
206
|
+
get :show, params: { id: '530369', vocab: 'OCLC_FAST' }
|
207
|
+
expect(response.code).to eq('500')
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
context 'when rdf format error' do
|
212
|
+
before do
|
213
|
+
stub_request(:get, 'http://id.worldcat.org/fast/530369').to_return(status: 200)
|
214
|
+
allow(RDF::Graph).to receive(:load).and_raise(RDF::FormatError)
|
215
|
+
end
|
216
|
+
it 'returns 500' do
|
217
|
+
expect(Rails.logger).to receive(:warn).with("RDF Format Error - Results from fetch term 530369 for authority OCLC_FAST was not identified as a valid RDF format. You may need to include the linkeddata gem.")
|
218
|
+
get :show, params: { id: '530369', vocab: 'OCLC_FAST' }
|
219
|
+
expect(response.code).to eq('500')
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
context "when error isn't specifically handled" do
|
151
224
|
before do
|
152
|
-
stub_request(:get, 'http://id.worldcat.org/fast/
|
153
|
-
.to_return(status: 404, body: '', headers: {})
|
225
|
+
stub_request(:get, 'http://id.worldcat.org/fast/530369').to_return(status: 501)
|
154
226
|
end
|
155
|
-
it 'returns
|
156
|
-
expect(Rails.logger).to receive(:warn).with(
|
157
|
-
get :show, params: { id: '
|
158
|
-
expect(response.code).to eq('
|
227
|
+
it 'returns 500' do
|
228
|
+
expect(Rails.logger).to receive(:warn).with("Internal Server Error - Fetch term 530369 unsuccessful for authority OCLC_FAST")
|
229
|
+
get :show, params: { id: '530369', vocab: 'OCLC_FAST' }
|
230
|
+
expect(response.code).to eq('500')
|
159
231
|
end
|
160
232
|
end
|
161
233
|
end
|
162
234
|
|
235
|
+
context 'when service unavailable' do
|
236
|
+
before do
|
237
|
+
stub_request(:get, 'http://id.worldcat.org/fast/530369').to_return(status: 503)
|
238
|
+
end
|
239
|
+
it 'returns 503' do
|
240
|
+
expect(Rails.logger).to receive(:warn).with("Service Unavailable - Fetch term 530369 unsuccessful for authority OCLC_FAST")
|
241
|
+
get :show, params: { id: '530369', vocab: 'OCLC_FAST' }
|
242
|
+
expect(response.code).to eq('503')
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
context 'when requested term is not found at the server' do
|
247
|
+
before do
|
248
|
+
stub_request(:get, 'http://id.worldcat.org/fast/FAKE_ID').to_return(status: 404, body: '', headers: {})
|
249
|
+
end
|
250
|
+
it 'returns 404' do
|
251
|
+
expect(Rails.logger).to receive(:warn).with('Term Not Found - Fetch term FAKE_ID unsuccessful for authority OCLC_FAST')
|
252
|
+
get :show, params: { id: 'FAKE_ID', vocab: 'OCLC_FAST' }
|
253
|
+
expect(response.code).to eq('404')
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
163
257
|
context 'in OCLC_FAST authority' do
|
164
258
|
context 'term found' do
|
165
259
|
before do
|
@@ -176,7 +270,7 @@ describe Qa::LinkedDataTermsController, type: :controller do
|
|
176
270
|
context 'in AGROVOC authority' do
|
177
271
|
context 'term found' do
|
178
272
|
before do
|
179
|
-
stub_request(:get, 'http://
|
273
|
+
stub_request(:get, 'http://artemide.art.uniroma2.it:8081/agrovoc/rest/v1/data?uri=http://aims.fao.org/aos/agrovoc/c_9513')
|
180
274
|
.to_return(status: 200, body: webmock_fixture('lod_agrovoc_term_found.rdf.xml'), headers: { 'Content-Type' => 'application/rdf+xml' })
|
181
275
|
end
|
182
276
|
it 'succeeds' do
|
@@ -7,24 +7,24 @@ describe Qa::Authorities::Local::FileBasedAuthority do
|
|
7
7
|
let(:authority_d) { Qa::Authorities::Local.subauthority_for("authority_D") }
|
8
8
|
|
9
9
|
describe "#all" do
|
10
|
-
let(:expected) { [{ 'id' => "A1", 'label' => "Abc Term A1" },
|
11
|
-
{ 'id' => "A2", 'label' => "Term A2" },
|
12
|
-
{ 'id' => "A3", 'label' => "Abc Term A3" }] }
|
10
|
+
let(:expected) { [{ 'id' => "A1", 'label' => "Abc Term A1", 'active' => true },
|
11
|
+
{ 'id' => "A2", 'label' => "Term A2", 'active' => false },
|
12
|
+
{ 'id' => "A3", 'label' => "Abc Term A3", 'active' => true }] }
|
13
13
|
it "returns all the entries" do
|
14
14
|
expect(authority_a.all).to eq(expected)
|
15
15
|
end
|
16
16
|
context "when terms do not have ids" do
|
17
|
-
let(:expected) { [{ 'id' => "Term B1", 'label' => "Term B1" },
|
18
|
-
{ 'id' => "Term B2", 'label' => "Term B2" },
|
19
|
-
{ 'id' => "Term B3", 'label' => "Term B3" }] }
|
17
|
+
let(:expected) { [{ 'id' => "Term B1", 'label' => "Term B1", 'active' => true },
|
18
|
+
{ 'id' => "Term B2", 'label' => "Term B2", 'active' => true },
|
19
|
+
{ 'id' => "Term B3", 'label' => "Term B3", 'active' => true }] }
|
20
20
|
it "sets the id to be same as the label" do
|
21
21
|
expect(authority_b.all).to eq(expected)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
context "authority YAML file is a list of terms" do
|
25
|
-
let(:expected) { [{ 'id' => "Term C1", 'label' => "Term C1" },
|
26
|
-
{ 'id' => "Term C2", 'label' => "Term C2" },
|
27
|
-
{ 'id' => "Term C3", 'label' => "Term C3" }] }
|
25
|
+
let(:expected) { [{ 'id' => "Term C1", 'label' => "Term C1", 'active' => true },
|
26
|
+
{ 'id' => "Term C2", 'label' => "Term C2", 'active' => true },
|
27
|
+
{ 'id' => "Term C3", 'label' => "Term C3", 'active' => true }] }
|
28
28
|
it "uses the terms as labels" do
|
29
29
|
expect(authority_c.all).to eq(expected)
|
30
30
|
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://
|
65
|
+
stub_request(:get, 'http://artemide.art.uniroma2.it:8081/agrovoc/rest/v1/search/?lang=en&query=*supercalifragilisticexpialidocious*')
|
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://
|
76
|
+
stub_request(:get, 'http://artemide.art.uniroma2.it:8081/agrovoc/rest/v1/search/?lang=en&query=*milk*')
|
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
|
@@ -271,7 +271,7 @@ RSpec.describe Qa::Authorities::LinkedData::GenericAuthority do
|
|
271
271
|
context 'in AGROVOC authority' do
|
272
272
|
context 'term found' do
|
273
273
|
let :results do
|
274
|
-
stub_request(:get, 'http://
|
274
|
+
stub_request(:get, 'http://artemide.art.uniroma2.it:8081/agrovoc/rest/v1/data?uri=http://aims.fao.org/aos/agrovoc/c_9513')
|
275
275
|
.to_return(status: 200, body: webmock_fixture('lod_agrovoc_term_found.rdf.xml'), headers: { 'Content-Type' => 'application/rdf+xml' })
|
276
276
|
lod_agrovoc.find('c_9513')
|
277
277
|
end
|
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: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Anderson
|
@@ -15,7 +15,7 @@ authors:
|
|
15
15
|
autorequire:
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
|
-
date: 2017-
|
18
|
+
date: 2017-06-23 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rails
|
@@ -442,6 +442,7 @@ files:
|
|
442
442
|
- spec/routing/linked_data_route_spec.rb
|
443
443
|
- spec/routing/route_spec.rb
|
444
444
|
- spec/spec_helper.rb
|
445
|
+
- spec/test_app_templates/Gemfile.extra
|
445
446
|
- spec/test_app_templates/lib/generators/test_app_generator.rb
|
446
447
|
homepage: https://github.com/projecthydra/questioning_authority
|
447
448
|
licenses:
|
@@ -463,7 +464,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
463
464
|
version: '0'
|
464
465
|
requirements: []
|
465
466
|
rubyforge_project:
|
466
|
-
rubygems_version: 2.
|
467
|
+
rubygems_version: 2.5.2
|
467
468
|
signing_key:
|
468
469
|
specification_version: 4
|
469
470
|
summary: You should question your authorities.
|
@@ -561,4 +562,5 @@ test_files:
|
|
561
562
|
- spec/routing/linked_data_route_spec.rb
|
562
563
|
- spec/routing/route_spec.rb
|
563
564
|
- spec/spec_helper.rb
|
565
|
+
- spec/test_app_templates/Gemfile.extra
|
564
566
|
- spec/test_app_templates/lib/generators/test_app_generator.rb
|