Skip to content

Commit

Permalink
Merge 07c4fbe into 9d83cd6
Browse files Browse the repository at this point in the history
  • Loading branch information
ndushay committed Aug 22, 2019
2 parents 9d83cd6 + 07c4fbe commit 15c99aa
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 6 deletions.
16 changes: 10 additions & 6 deletions app/services/discovery_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,16 @@ def process_dobj(dobj)

if using_media_manifest? # if we are using a media manifest, let's add how many files were found
bundle_id = File.basename(dobj.container)
cm_files = media.manifest[bundle_id].fetch(:files, [])
counts[:files_in_manifest] = cm_files.count
relative_paths = dobj.object_files.map(&:relative_path)
counts[:files_found] = (cm_files.pluck(:filename) & relative_paths).count
errors[:empty_manifest] = true unless counts[:files_in_manifest] > 0
errors[:files_found_mismatch] = true unless counts[:files_in_manifest] == counts[:files_found]
if bundle_id && media.manifest[bundle_id]
cm_files = media.manifest[bundle_id].fetch(:files, [])
counts[:files_in_manifest] = cm_files.count
relative_paths = dobj.object_files.map(&:relative_path)
counts[:files_found] = (cm_files.pluck(:filename) & relative_paths).count
errors[:empty_manifest] = true unless counts[:files_in_manifest] > 0
errors[:files_found_mismatch] = true unless counts[:files_in_manifest] == counts[:files_found]
else
errors[:missing_media_container_name_or_manifest] = true
end
end

errors[:empty_object] = true unless counts[:total_size] > 0
Expand Down
15 changes: 15 additions & 0 deletions spec/services/discovery_report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,21 @@
expect(report.process_dobj(dobj)).not_to include(a_hash_including(empty_object: true))
end
end

context 'missing_media_container_name_or_manifest' do
let(:bundle) { bundle_setup(:media_missing) }
let(:obj_file) { instance_double(PreAssembly::ObjectFile, path: '', filesize: 324, mimetype: '') }

before do
allow(dobj).to receive(:object_files).and_return([obj_file, obj_file])
allow(report).to receive(:using_media_manifest?).and_return(true)
allow(report).to receive(:registration_check).and_return({}) # pretend everything is in Dor
end

it 'adds missing_media_container_name_or_manifest error' do
expect(report.process_dobj(dobj)).to match a_hash_including(errors: a_hash_including(missing_media_container_name_or_manifest: true))
end
end
end

context 'integration test' do
Expand Down
2 changes: 2 additions & 0 deletions spec/test_data/media_missing/manifest.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
druid,sourceid,object,label,description
"druid:aa111aa1111","bar-1.0","aa111aa1111","Label 1","This is a description for label 1"
1 change: 1 addition & 0 deletions spec/test_data/media_missing/media_manifest.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
source_id,filename,label,sequence,publish,preserve,shelve,resource_type
24 changes: 24 additions & 0 deletions spec/test_data/project_config_files/media_missing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# An example of a project which has already registered objects, but for which
# you want to provide a manifest to provide descriptive metadata and a MODS template.
# Object discovery also occurs via the manifest.

project_name: 'Media_Missing'

project_style:
content_structure: 'media'

bundle_dir: 'spec/test_data/media_missing'

content_md_creation:
style: 'media'
media_manifest: 'media_manifest.csv'

object_discovery:
use_manifest: true
glob: '*'
regex: '^[a-z][a-z]\d\d\d[a-z][a-z]\d\d\d\d$'

stageable_discovery:
use_container: false
glob: '**/*/*'
regex: '^((?!.md5).)*$'

0 comments on commit 15c99aa

Please sign in to comment.