-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
normalize content types in pre-assembly to match current set
- Loading branch information
Showing
9 changed files
with
85 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ | |
['File', 'file'], | ||
['Media', 'media'], | ||
['3D', '3d'], | ||
['Map', 'maps'] | ||
] | ||
%> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe 'Create Map object', type: :feature do | ||
let(:user) { create(:user) } | ||
let(:user_id) { "#{user.sunet_id}@stanford.edu" } | ||
let(:project_name) { "image-#{RandomWord.nouns.next}" } | ||
let(:bundle_dir) { Rails.root.join('spec/test_data/image_jpg') } | ||
let(:bare_druid) { 'pr666rr9999' } | ||
let(:object_staging_dir) { Rails.root.join(Settings.assembly_staging_dir, 'pr', '666', 'rr', '9999', bare_druid) } | ||
let(:cocina_model_world_access) { instance_double(Cocina::Models::Access, access: 'world') } | ||
let(:item) { instance_double(Cocina::Models::DRO, type: Cocina::Models::Vocab.map, access: cocina_model_world_access) } | ||
let(:dsc_object_version) { instance_double(Dor::Services::Client::ObjectVersion, openable?: true) } | ||
let(:dsc_object) { instance_double(Dor::Services::Client::Object, version: dsc_object_version, find: item) } | ||
let(:exp_content_md) do | ||
<<~XML | ||
<contentMetadata objectId="pr666rr9999" type="map"> | ||
<resource id="pr666rr9999_1" sequence="1" type="image"> | ||
<label>Image 1</label> | ||
<file id="image.jpg"> | ||
<checksum type="md5">3e9498107f73ff827e718d5c743f8813</checksum> | ||
</file> | ||
</resource> | ||
</contentMetadata> | ||
XML | ||
end | ||
|
||
before do | ||
FileUtils.remove_dir(object_staging_dir) if Dir.exist?(object_staging_dir) | ||
|
||
login_as(user, scope: :user) | ||
|
||
allow(Dor::Services::Client).to receive(:object).and_return(dsc_object) | ||
allow(StartAccession).to receive(:run).with(druid: "druid:#{bare_druid}", user: user.sunet_id) | ||
end | ||
|
||
# have background jobs run synchronously | ||
include ActiveJob::TestHelper | ||
around do |example| | ||
perform_enqueued_jobs do | ||
example.run | ||
end | ||
end | ||
|
||
it do | ||
visit '/' | ||
expect(page).to have_selector('h3', text: 'Complete the form below') | ||
|
||
fill_in 'Project name', with: project_name | ||
select 'Pre Assembly Run', from: 'Job type' | ||
select 'Map', from: 'Content structure' | ||
fill_in 'Bundle dir', with: bundle_dir | ||
|
||
click_button 'Submit' | ||
exp_str = 'Success! Your job is queued. A link to job output will be emailed to you upon completion.' | ||
expect(page).to have_content exp_str | ||
|
||
# go to job details page, wait for preassembly to finish | ||
first('td > a').click | ||
expect(page).to have_content project_name | ||
expect(page).to have_link('Download') | ||
|
||
result_file = Rails.root.join(Settings.job_output_parent_dir, user_id, project_name, "#{project_name}_progress.yml") | ||
yaml = YAML.load_file(result_file) | ||
expect(yaml[:status]).to eq 'success' | ||
|
||
# we got all the expected content files | ||
expect(Dir.children(File.join(object_staging_dir, 'content')).size).to eq 1 | ||
|
||
metadata_dir = File.join(object_staging_dir, 'metadata') | ||
expect(Dir.children(metadata_dir).size).to eq 1 | ||
|
||
content_md_xml = File.open(File.join(metadata_dir, 'contentMetadata.xml')).read | ||
expect(noko_doc(content_md_xml)).to be_equivalent_to exp_content_md | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,7 +63,8 @@ | |
'file' => 3, | ||
'media' => 4, | ||
'3d' => 5, | ||
'document' => 6 | ||
'document' => 6, | ||
'maps' => 7 | ||
) | ||
end | ||
|
||
|