Skip to content

Commit

Permalink
Prefix fixture filenames with item and property IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
mdholloway committed Jan 11, 2025
1 parent dd8c4ad commit 3afb15b
Show file tree
Hide file tree
Showing 44 changed files with 73 additions and 73 deletions.
6 changes: 3 additions & 3 deletions spec/digital_scriptorium/ds_item_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ module DigitalScriptorium
include WikibaseRepresentable::Representers

RSpec.describe DsItem do
let(:holding_json) { read_fixture('items/holding.json') }
let(:manuscript_json) { read_fixture('items/manuscript.json') }
let(:record_json) { read_fixture('items/record.json') }
let(:holding_json) { read_fixture('items/Q542_holding_example.json') }
let(:manuscript_json) { read_fixture('items/Q543_manuscript_example.json') }
let(:record_json) { read_fixture('items/Q544_record_example.json') }

it 'correctly reports if it is a holding' do
item = ItemRepresenter.new(described_class.new).from_json(holding_json)
Expand Down
6 changes: 3 additions & 3 deletions spec/digital_scriptorium/ds_meta_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ module DigitalScriptorium
include WikibaseRepresentable::Representers

RSpec.describe DsMeta do
let(:holding) { ItemRepresenter.new(DsItem.new).from_json(read_fixture('items/holding.json')) }
let(:manuscript) { ItemRepresenter.new(DsItem.new).from_json(read_fixture('items/manuscript.json')) }
let(:record) { ItemRepresenter.new(DsItem.new).from_json(read_fixture('items/record.json')) }
let(:holding) { item_from_fixture('items/Q542_holding_example.json') }
let(:manuscript) { item_from_fixture('items/Q543_manuscript_example.json') }
let(:record) { item_from_fixture('items/Q544_record_example.json') }
let(:meta) do
described_class.new(record, { record.id => record, holding.id => holding, manuscript.id => manuscript })
end
Expand Down
8 changes: 4 additions & 4 deletions spec/digital_scriptorium/export_representer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ module DigitalScriptorium
include WikibaseRepresentable::Representers

RSpec.describe ExportRepresenter do
let(:holding_json) { read_fixture('items/holding.json') }
let(:manuscript_json) { read_fixture('items/manuscript.json') }
let(:record_json) { read_fixture('items/record.json') }
let(:property_json) { read_fixture('properties/instance_of.json') }
let(:holding_json) { read_fixture('items/Q542_holding_example.json') }
let(:manuscript_json) { read_fixture('items/Q543_manuscript_example.json') }
let(:record_json) { read_fixture('items/Q544_record_example.json') }
let(:property_json) { read_fixture('properties/P16_instance_of.json') }
let(:export) do
described_class.new(Export.new).from_json("[#{holding_json},#{manuscript_json},#{record_json},#{property_json}]")
end
Expand Down
8 changes: 4 additions & 4 deletions spec/digital_scriptorium/export_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ module DigitalScriptorium
include WikibaseRepresentable::Representers

RSpec.describe Export do
let(:holding) { item_from_fixture('items/holding.json') }
let(:manuscript) { item_from_fixture('items/manuscript.json') }
let(:record) { item_from_fixture('items/record.json') }
let(:property) { property_from_fixture('properties/instance_of.json') }
let(:holding) { item_from_fixture('items/Q542_holding_example.json') }
let(:manuscript) { item_from_fixture('items/Q543_manuscript_example.json') }
let(:record) { item_from_fixture('items/Q544_record_example.json') }
let(:property) { property_from_fixture('properties/P16_instance_of.json') }

it 'transforms a Wikibase export to a Hash' do
export = described_class.new
Expand Down
8 changes: 4 additions & 4 deletions spec/digital_scriptorium/link_claim_transformer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ module DigitalScriptorium
include WikibaseRepresentable::Representers

RSpec.describe LinkClaimTransformer do
context 'with an institutional record claim' do
json = read_fixture('claims/unqualified/institutional_record.json')
context 'with an institutional record (P9) claim' do
json = read_fixture('claims/unqualified/P9_institutional_record.json')
claim = StatementRepresenter.new(Statement.new).from_json(json)
expected = {
'institutional_record_link' => ['https://franklin.library.upenn.edu/catalog/FRANKLIN_9949945603503681']
Expand All @@ -21,8 +21,8 @@ module DigitalScriptorium
end
end

context 'with an IIIF manifest claim' do
json = read_fixture('claims/unqualified/iiif_manifest.json')
context 'with an IIIF manifest (P41) claim' do
json = read_fixture('claims/unqualified/P41_iiif_manifest.json')
claim = StatementRepresenter.new(Statement.new).from_json(json)
expected = {
'iiif_manifest_link' => ['https://colenda.library.upenn.edu/phalt/iiif/2/81431-p33p8v/manifest'],
Expand Down
12 changes: 6 additions & 6 deletions spec/digital_scriptorium/name_claim_transformer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

module DigitalScriptorium
RSpec.describe NameClaimTransformer do
context 'with a single qualifier' do
json = read_fixture('claims/qualified/name.json')
context 'with a single name in authority file (P17) qualifier' do
json = read_fixture('claims/qualified/P14_name.json')
claim = StatementRepresenter.new(Statement.new).from_json(json)
expected = {
'owner_display' => ['{"recorded_value":"Schoenberg, Lawrence J","linked_terms":[{"label":"Lawrence J. Schoenberg","source_url":"https://www.wikidata.org/wiki/Q107542788"}]}'],
Expand All @@ -20,8 +20,8 @@ module DigitalScriptorium
end
end

context 'with multiple qualifiers' do
json = read_fixture('claims/qualified/name_multiple_qualifier_values.json')
context 'with multiple name in authority file (P17) qualifiers' do
json = read_fixture('claims/qualified/P14_name_multiple_qualifier_values.json')
claim = StatementRepresenter.new(Statement.new).from_json(json)
expected = {
'owner_display' => [
Expand All @@ -44,8 +44,8 @@ module DigitalScriptorium
end
end

context 'with an original script qualifier' do
json = read_fixture('claims/qualified/name_original_script.json')
context 'with an original script (P13) qualifier' do
json = read_fixture('claims/qualified/P14_name_original_script.json')
claim = StatementRepresenter.new(Statement.new).from_json(json)
expected = {
'author_display' => ['{"recorded_value":"Dioscorides Pedanius, of Anazarbos","original_script":"ديسقوريدس. of Anazarbos","linked_terms":[{"label":"Pedanius Dioscorides","source_url":"https://www.wikidata.org/wiki/Q297776"}]}'],
Expand Down
60 changes: 30 additions & 30 deletions spec/digital_scriptorium/qualified_claim_transformer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def build_claim(json)
StatementRepresenter.new(Statement.new).from_json(json)
end

context 'with an institution claim' do
json = read_fixture('claims/qualified/institution.json')
context 'with an institution (P5) claim' do
json = read_fixture('claims/qualified/P5_institution.json')
expected = {
'institution_display' => ['{"recorded_value":"University of Pennsylvania","linked_terms":[{"label":"University of Pennsylvania","source_url":"https://www.wikidata.org/wiki/Q49117"}]}'],
'institution_search' => ['University of Pennsylvania'],
Expand All @@ -26,8 +26,8 @@ def build_claim(json)
end
end

context 'with a title claim with standard title and original script qualifiers' do
json = read_fixture('claims/qualified/title.json')
context 'with a title (P10) claim with standard title (P11) and original script (P13) qualifiers' do
json = read_fixture('claims/qualified/P10_title.json')
expected = {
'title_display' => ['{"recorded_value":"Kitāb al-Majisṭī","original_script":"كتاب المجسطي.","linked_terms":[{"label":"Almagest"}]}'],
'title_search' => ['Kitāb al-Majisṭī', 'كتاب المجسطي.', 'Almagest'],
Expand All @@ -40,8 +40,8 @@ def build_claim(json)
end
end

context 'with a qualified genre claim' do
json = read_fixture('claims/qualified/genre.json')
context 'with a qualified genre (P18) claim' do
json = read_fixture('claims/qualified/P18_genre.json')
expected = {
'term_display' => ['{"recorded_value":"Deeds","linked_terms":[{"label":"deeds","source_url":"http://vocab.getty.edu/aat/300027249"}]}'],
'term_search' => %w[Deeds deeds],
Expand All @@ -54,8 +54,8 @@ def build_claim(json)
end
end

context 'with a qualified language claim' do
json = read_fixture('claims/qualified/language.json')
context 'with a qualified language (P21) claim' do
json = read_fixture('claims/qualified/P21_language.json')
expected = {
'language_display' => ['{"recorded_value":"In Latin","linked_terms":[{"label":"Latin","source_url":"https://www.wikidata.org/wiki/Q397"}]}'],
'language_search' => ['In Latin', 'Latin'],
Expand All @@ -68,8 +68,26 @@ def build_claim(json)
end
end

context 'with a place claim with multi-valued qualifier' do
json = read_fixture('claims/qualified/place.json')
context 'with a date (P23) claim' do
json = read_fixture('claims/qualified/P23_date.json')
expected = {
'date_meta' => ['1358.'],
'date_display' => ['{"recorded_value":"1358.","linked_terms":[{"label":"fourteenth century (dates CE)","source_url":"http://vocab.getty.edu/aat/300404506"}]}'],
'date_search' => ['1358.', 'fourteenth century (dates CE)'],
'date_facet' => ['fourteenth century (dates CE)'],
'century_int' => [1301],
'earliest_int' => [1358],
'latest_int' => [1358]
}

it 'extracts display, search, facet and extra date fields' do
solr_item = described_class.transform(build_claim(json), export_hash, config[PropertyId::PRODUCTION_DATE_AS_RECORDED])
expect(solr_item).to eq(expected)
end
end

context 'with a place (P27) claim with multi-valued qualifier' do
json = read_fixture('claims/qualified/P27_place.json')
expected = {
'place_display' => ['{"recorded_value":"[Provence or Spain],","linked_terms":[{"label":"Provence","source_url":"http://vocab.getty.edu/tgn/7012209"},{"label":"Spain","source_url":"http://vocab.getty.edu/tgn/1000095"}]}'],
'place_search' => ['[Provence or Spain],', 'Provence', 'Spain'],
Expand All @@ -82,8 +100,8 @@ def build_claim(json)
end
end

context 'with a qualified material claim' do
json = read_fixture('claims/qualified/material.json')
context 'with a qualified material (P30) claim' do
json = read_fixture('claims/qualified/P30_material.json')
expected = {
'material_display' => ['{"recorded_value":"parchment","linked_terms":[{"label":"Parchment","source_url":"http://vocab.getty.edu/aat/300011851"}]}'],
'material_search' => %w[parchment Parchment],
Expand All @@ -95,23 +113,5 @@ def build_claim(json)
expect(solr_item).to eq(expected)
end
end

context 'with a date claim' do
json = read_fixture('claims/qualified/date.json')
expected = {
'date_meta' => ['1358.'],
'date_display' => ['{"recorded_value":"1358.","linked_terms":[{"label":"fourteenth century (dates CE)","source_url":"http://vocab.getty.edu/aat/300404506"}]}'],
'date_search' => ['1358.', 'fourteenth century (dates CE)'],
'date_facet' => ['fourteenth century (dates CE)'],
'century_int' => [1301],
'earliest_int' => [1358],
'latest_int' => [1358]
}

it 'extracts display, search, facet and extra date fields' do
solr_item = described_class.transform(build_claim(json), export_hash, config[PropertyId::PRODUCTION_DATE_AS_RECORDED])
expect(solr_item).to eq(expected)
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module DigitalScriptorium

RSpec.describe UnqualifiedClaimTransformer do
context 'with a holding status claim' do
json = read_fixture('claims/unqualified/status.json')
json = read_fixture('claims/unqualified/P6_status.json')
claim = StatementRepresenter.new(Statement.new).from_json(json)
expected = {
'holding_status_display' => ['{"recorded_value":"Current","linked_terms":[]}'],
Expand All @@ -24,7 +24,7 @@ module DigitalScriptorium
end

context 'with a shelfmark claim' do
json = read_fixture('claims/unqualified/shelfmark.json')
json = read_fixture('claims/unqualified/P8_shelfmark.json')
claim = StatementRepresenter.new(Statement.new).from_json(json)
expected = {
'shelfmark_display' => ['{"recorded_value":"Oversize LJS 110","linked_terms":[]}'],
Expand All @@ -38,7 +38,7 @@ module DigitalScriptorium
end

context 'with a physical description claim' do
json = read_fixture('claims/unqualified/physical_description.json')
json = read_fixture('claims/unqualified/P29_physical_description.json')
claim = StatementRepresenter.new(Statement.new).from_json(json)
expected = {
'physical_description_display' => ['{"recorded_value":"Extent: 1 parchment ; 170 x 245 mm.","linked_terms":[]}'],
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
32 changes: 16 additions & 16 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def read_fixture(file)
end

def item_from_fixture(file)
item = WikibaseRepresentable::Model::Item.new
item = DigitalScriptorium::DsItem.new
WikibaseRepresentable::Representers::ItemRepresenter.new(item).from_json(read_fixture(file))
end

Expand All @@ -39,21 +39,21 @@ def property_from_fixture(file)
end

EXPORT_HASH = {
'Q4' => item_from_fixture('items/current.json'),
'Q18' => item_from_fixture('items/author.json'),
'Q21' => item_from_fixture('items/former_owner.json'),
'Q33' => item_from_fixture('items/parchment.json'),
'Q96' => item_from_fixture('items/14c.json'),
'Q113' => item_from_fixture('items/latin.json'),
'Q128' => item_from_fixture('items/provence.json'),
'Q129' => item_from_fixture('items/spain.json'),
'Q283' => item_from_fixture('items/deeds.json'),
'Q354' => item_from_fixture('items/almagest.json'),
'Q374' => item_from_fixture('items/penn.json'),
'Q383' => item_from_fixture('items/schoenberg.json'),
'Q394' => item_from_fixture('items/dioscorides.json'),
'Q1105' => item_from_fixture('items/deste.json'),
'Q1106' => item_from_fixture('items/llangattock.json')
'Q4' => item_from_fixture('items/Q4_holding_status_current.json'),
'Q18' => item_from_fixture('items/Q18_author.json'),
'Q21' => item_from_fixture('items/Q21_former_owner.json'),
'Q33' => item_from_fixture('items/Q33_parchment.json'),
'Q96' => item_from_fixture('items/Q96_14th_century.json'),
'Q113' => item_from_fixture('items/Q113_latin.json'),
'Q128' => item_from_fixture('items/Q128_provence.json'),
'Q129' => item_from_fixture('items/Q129_spain.json'),
'Q283' => item_from_fixture('items/Q283_deeds.json'),
'Q354' => item_from_fixture('items/Q354_almagest.json'),
'Q374' => item_from_fixture('items/Q374_upenn.json'),
'Q383' => item_from_fixture('items/Q383_schoenberg.json'),
'Q394' => item_from_fixture('items/Q394_dioscorides.json'),
'Q1105' => item_from_fixture('items/Q1105_deste.json'),
'Q1106' => item_from_fixture('items/Q1106_llangattock.json')
}.freeze

def export_hash
Expand Down

0 comments on commit 3afb15b

Please sign in to comment.