Skip to content

Commit

Permalink
update loc_full_config fixture to only use ldpath
Browse files Browse the repository at this point in the history
**[WIP] Step 1 in removing deprecated predicate support**

----

Partially addresses #289

* changes loc_full_config fixture to only use ldpath
* updates config specs to check for ldpath
* temporarily update predicate tests in config specs to test against hardcoded predicate hash (This will be removed when the config processing code no longer supports predicates.)
  • Loading branch information
elrayle committed Nov 21, 2019
1 parent 941dec5 commit 2bbf2fc
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 86 deletions.
2 changes: 1 addition & 1 deletion lib/qa/authorities/linked_data/config/search_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def results_altlabel_predicate
# Does this authority configuration support sorting of search results?
# @return [True|False] true if sorting of search results is supported; otherwise, false
def supports_sort?
return true unless results_sort_ldpath.present? || !results_sort_predicate.present?
return true if results_sort_ldpath.present? || results_sort_predicate.present?
false
end

Expand Down
25 changes: 12 additions & 13 deletions spec/fixtures/authorities/linked_data/lod_full_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"QA_CONFIG_VERSION": "2.2",
"service_uri": "http://ld4l.org/ld4l_services/cache",
"prefixes": {
"schema": "http://www.w3.org/2000/01/rdf-schema#",
"skos": "http://www.w3.org/2004/02/skos/core#"
"dcterms": "http://purl.org/dc/terms/"
},
"term": {
"url": {
Expand Down Expand Up @@ -56,12 +55,12 @@
"term_id": "ID",
"language": [ "es" ],
"results": {
"id_predicate": "http://purl.org/dc/terms/identifier",
"label_predicate": "http://www.w3.org/2004/02/skos/core#prefLabel",
"altlabel_predicate": "http://www.w3.org/2004/02/skos/core#altLabel",
"broader_predicate": "http://www.w3.org/2004/02/skos/core#broader",
"narrower_predicate": "http://www.w3.org/2004/02/skos/core#narrower",
"sameas_predicate": "http://www.w3.org/2004/02/skos/core#exactMatch"
"id_ldpath": "dcterms:identifier",
"label_ldpath": "skos:prefLabel",
"altlabel_ldpath": "skos:altLabel",
"broader_ldpath": "skos:broader",
"narrower_ldpath": "skos:narrower",
"sameas_ldpath": "skos:exactMatch"
},
"subauthorities": {
"term_sub1_key": "term_sub1_name",
Expand Down Expand Up @@ -122,10 +121,10 @@
"language": [ "en", "fr", "de" ],
"total_count_ldpath": "vivo:count",
"results": {
"id_predicate": "http://purl.org/dc/terms/identifier",
"label_predicate": "http://www.w3.org/2004/02/skos/core#prefLabel",
"altlabel_predicate": "http://www.w3.org/2004/02/skos/core#altLabel",
"sort_predicate": "http://www.w3.org/2004/02/skos/core#prefLabel"
"id_ldpath": "dcterms:identifier",
"label_ldpath": "skos:prefLabel",
"altlabel_ldpath": "skos:altLabel",
"sort_ldpath": "skos:prefLabel"
},
"context": {
"groups": {
Expand All @@ -150,7 +149,7 @@
"group_id": "dates",
"property_label_i18n": "qa.linked_data.authority.locnames_ld4l_cache.birth_date",
"property_label_default": "Birth",
"ldpath": "madsrdf:identifiesRWO/madsrdf:birthDate/schema:label",
"ldpath": "madsrdf:identifiesRWO/madsrdf:birthDate/rdfs:label",
"selectable": false,
"drillable": false
},
Expand Down
28 changes: 13 additions & 15 deletions spec/lib/authorities/linked_data/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
QA_CONFIG_VERSION: "2.2",
service_uri: "http://ld4l.org/ld4l_services/cache",
prefixes: {
schema: "http://www.w3.org/2000/01/rdf-schema#",
skos: "http://www.w3.org/2004/02/skos/core#"
dcterms: "http://purl.org/dc/terms/"
},
term: {
url: {
Expand Down Expand Up @@ -82,12 +81,12 @@
term_id: 'ID',
language: ['es'],
results: {
id_predicate: 'http://purl.org/dc/terms/identifier',
label_predicate: 'http://www.w3.org/2004/02/skos/core#prefLabel',
altlabel_predicate: 'http://www.w3.org/2004/02/skos/core#altLabel',
broader_predicate: 'http://www.w3.org/2004/02/skos/core#broader',
narrower_predicate: 'http://www.w3.org/2004/02/skos/core#narrower',
sameas_predicate: 'http://www.w3.org/2004/02/skos/core#exactMatch'
id_ldpath: 'dcterms:identifier',
label_ldpath: 'skos:prefLabel',
altlabel_ldpath: 'skos:altLabel',
broader_ldpath: 'skos:broader',
narrower_ldpath: 'skos:narrower',
sameas_ldpath: 'skos:exactMatch'
},
subauthorities: {
term_sub1_key: 'term_sub1_name',
Expand Down Expand Up @@ -148,10 +147,10 @@
language: ['en', 'fr', 'de'],
total_count_ldpath: "vivo:count",
results: {
id_predicate: 'http://purl.org/dc/terms/identifier',
label_predicate: 'http://www.w3.org/2004/02/skos/core#prefLabel',
altlabel_predicate: 'http://www.w3.org/2004/02/skos/core#altLabel',
sort_predicate: 'http://www.w3.org/2004/02/skos/core#prefLabel'
id_ldpath: 'dcterms:identifier',
label_ldpath: 'skos:prefLabel',
altlabel_ldpath: 'skos:altLabel',
sort_ldpath: 'skos:prefLabel'
},
context: {
groups: {
Expand All @@ -176,7 +175,7 @@
group_id: "dates",
property_label_i18n: "qa.linked_data.authority.locnames_ld4l_cache.birth_date",
property_label_default: "Birth",
ldpath: "madsrdf:identifiesRWO/madsrdf:birthDate/schema:label",
ldpath: "madsrdf:identifiesRWO/madsrdf:birthDate/rdfs:label",
selectable: false,
drillable: false
},
Expand Down Expand Up @@ -405,8 +404,7 @@
describe '#prefixes' do
let(:expected_results) do
{
schema: "http://www.w3.org/2000/01/rdf-schema#",
skos: "http://www.w3.org/2004/02/skos/core#"
dcterms: "http://purl.org/dc/terms/"
}
end

Expand Down
54 changes: 29 additions & 25 deletions spec/lib/authorities/linked_data/search_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
let(:term_only_config) { Qa::Authorities::LinkedData::Config.new(:LOD_TERM_ONLY_CONFIG).search }
let(:encoding_config) { Qa::Authorities::LinkedData::Config.new(:LOD_ENCODING_CONFIG).search }

let(:ldpath_results_config) do
let(:predicate_results_config) do
{
id_ldpath: 'schema:identifier ::xsd:string',
label_ldpath: 'skos:prefLabel ::xsd:string',
altlabel_ldpath: 'skos:altLabel ::xsd:string',
sort_ldpath: 'skos:prefLabel ::xsd:string'
id_predicate: 'http://purl.org/dc/terms/identifier',
label_predicate: 'http://www.w3.org/2004/02/skos/core#prefLabel',
altlabel_predicate: 'http://www.w3.org/2004/02/skos/core#altLabel',
sort_predicate: 'http://www.w3.org/2004/02/skos/core#prefLabel'
}
end

Expand Down Expand Up @@ -75,10 +75,10 @@
language: ['en', 'fr', 'de'],
total_count_ldpath: "vivo:count",
results: {
id_predicate: 'http://purl.org/dc/terms/identifier',
label_predicate: 'http://www.w3.org/2004/02/skos/core#prefLabel',
altlabel_predicate: 'http://www.w3.org/2004/02/skos/core#altLabel',
sort_predicate: 'http://www.w3.org/2004/02/skos/core#prefLabel'
id_ldpath: 'dcterms:identifier',
label_ldpath: 'skos:prefLabel',
altlabel_ldpath: 'skos:altLabel',
sort_ldpath: 'skos:prefLabel'
},
context: {
groups: {
Expand All @@ -103,7 +103,7 @@
group_id: "dates",
property_label_i18n: "qa.linked_data.authority.locnames_ld4l_cache.birth_date",
property_label_default: "Birth",
ldpath: "madsrdf:identifiesRWO/madsrdf:birthDate/schema:label",
ldpath: "madsrdf:identifiesRWO/madsrdf:birthDate/rdfs:label",
selectable: false,
drillable: false
},
Expand Down Expand Up @@ -178,22 +178,23 @@
describe '#results' do
let(:results_config) do
{
id_predicate: 'http://purl.org/dc/terms/identifier',
label_predicate: 'http://www.w3.org/2004/02/skos/core#prefLabel',
altlabel_predicate: 'http://www.w3.org/2004/02/skos/core#altLabel',
sort_predicate: 'http://www.w3.org/2004/02/skos/core#prefLabel'
id_ldpath: 'dcterms:identifier',
label_ldpath: 'skos:prefLabel',
altlabel_ldpath: 'skos:altLabel',
sort_ldpath: 'skos:prefLabel'
}
end

it 'returns nil if only term configuration is defined' do
expect(term_only_config.results).to eq nil
end
it 'returns hash of predicates' do
it 'returns hash of ldpaths' do
expect(full_config.results).to eq results_config
end
end

describe '#results_id_predicate' do
before { allow(full_config).to receive(:results).and_return(predicate_results_config) }
it 'returns nil if only term configuration is defined' do
expect(term_only_config.results_id_predicate).to eq nil
end
Expand All @@ -208,14 +209,15 @@
end

context 'when id specified as ldpath' do
before { allow(full_config).to receive(:results).and_return(ldpath_results_config) }
# before { allow(full_config).to receive(:results).and_return(ldpath_results_config) }
it 'returns the ldpath' do
expect(full_config.results_id_ldpath).to eq 'schema:identifier ::xsd:string'
expect(full_config.results_id_ldpath).to eq 'dcterms:identifier'
end
end
end

describe '#results_label_predicate' do
before { allow(full_config).to receive(:results).and_return(predicate_results_config) }
it 'returns nil if only term configuration is defined' do
expect(term_only_config.results_label_predicate).to eq nil
end
Expand All @@ -230,14 +232,15 @@
end

context 'when label specified as ldpath' do
before { allow(full_config).to receive(:results).and_return(ldpath_results_config) }
# before { allow(full_config).to receive(:results).and_return(ldpath_results_config) }
it 'returns the ldpath' do
expect(full_config.results_label_ldpath).to eq 'skos:prefLabel ::xsd:string'
expect(full_config.results_label_ldpath).to eq 'skos:prefLabel'
end
end
end

describe '#results_altlabel_predicate' do
before { allow(full_config).to receive(:results).and_return(predicate_results_config) }
it 'returns nil if only term configuration is defined' do
expect(term_only_config.results_altlabel_predicate).to eq nil
end
Expand All @@ -258,9 +261,9 @@
end

context 'when altlabel specified as ldpath' do
before { allow(full_config).to receive(:results).and_return(ldpath_results_config) }
# before { allow(full_config).to receive(:results).and_return(ldpath_results_config) }
it 'returns the ldpath' do
expect(full_config.results_altlabel_ldpath).to eq 'skos:altLabel ::xsd:string'
expect(full_config.results_altlabel_ldpath).to eq 'skos:altLabel'
end
end
end
Expand All @@ -269,15 +272,16 @@
it 'returns false if only term configuration is defined' do
expect(term_only_config.supports_sort?).to eq false
end
it 'returns false if sort predicate is NOT defined' do
it 'returns false if sort ldpath is NOT defined' do
expect(min_config.supports_sort?).to eq false
end
it 'returns true if sort predicate IS defined' do
it 'returns true if sort ldpath IS defined' do
expect(full_config.supports_sort?).to eq true
end
end

describe '#results_sort_predicate' do
before { allow(full_config).to receive(:results).and_return(predicate_results_config) }
it 'returns nil if only term configuration is defined' do
expect(term_only_config.results_sort_predicate).to eq nil
end
Expand All @@ -298,9 +302,9 @@
end

context 'when sort specified as ldpath' do
before { allow(full_config).to receive(:results).and_return(ldpath_results_config) }
# before { allow(full_config).to receive(:results).and_return(ldpath_results_config) }
it 'returns the ldpath' do
expect(full_config.results_sort_ldpath).to eq 'skos:prefLabel ::xsd:string'
expect(full_config.results_sort_ldpath).to eq 'skos:prefLabel'
end
end
end
Expand Down
Loading

0 comments on commit 2bbf2fc

Please sign in to comment.