Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] update loc_full_config fixture to only use ldpath #290

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
project: qa

- samvera/engine_cart_generate:
cache_key: v7-internal-test-app-{{ checksum "qa.gemspec" }}-{{ checksum "spec/test_app_templates/lib/generators/test_app_generator.rb" }}-{{ checksum "lib/generators/qa/install/install_generator.rb" }}-<< parameters.rails_version >>-<< parameters.ruby_version >>
cache_key: v8-internal-test-app-{{ checksum "qa.gemspec" }}-{{ checksum "spec/test_app_templates/lib/generators/test_app_generator.rb" }}-{{ checksum "lib/generators/qa/install/install_generator.rb" }}-<< parameters.rails_version >>-<< parameters.ruby_version >>

- samvera/bundle_for_gem:
ruby_version: << parameters.ruby_version >>
Expand Down
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?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shifting lod_full_config fixture to specify ldpath for sort instead of a predicate revealed the logic on this was incorrect. The test now verifies that if sort ldpath is present, then sorting is supported.

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",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ldpath predefine RDF Schema using rdfs as the namespace. Updated the config to follow this precedence.

"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'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the primary change for the PR. The config specified results as ldpaths instead of predicates.

},
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'
Copy link
Contributor Author

@elrayle elrayle Nov 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the primary change for the PR. The config now specifies results as ldpaths instead of predicates.

},
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/"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rdfs (previously prefixed as schema) and skos are predefined in the ldpath gem and do not need to be defined here. dcterms is not predefined and needs to be defined here to be used in the config.

}
end

Expand Down
50 changes: 25 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
{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ldpath_results_config is no longer needed because lod_full_config fixture now defines them. The predicate definitions were removed from the fixture, so they are defined here for the predicate tests to be able to continue to pass. They will eventually be removed when support for predicates is removed from the config processing classes.

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,14 @@
end

context 'when id specified as ldpath' do
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'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Matches the change to the lod_full_config fixture ldpaths.

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 +231,14 @@
end

context 'when label specified as ldpath' do
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'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ldpaths in loc_full_config fixture do not have ::xsd:string on the ldpaths. It is optional. The ldpath service already tests paths with and without the type (not in this PR).

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 +259,8 @@
end

context 'when altlabel specified as ldpath' do
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 +269,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 +299,8 @@
end

context 'when sort specified as ldpath' do
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